21 #ifndef GEOS_FINITEELEMENT_KERNELBASE_HPP_
22 #define GEOS_FINITEELEMENT_KERNELBASE_HPP_
26 #include "constitutive/ConstitutivePassThru.hpp"
27 #include "finiteElement/FiniteElementDispatch.hpp"
29 #include "common/GEOS_RAJA_Interface.hpp"
35 #ifndef SELECTED_FE_TYPES
36 #define SELECTED_FE_TYPES BASE_FE_TYPES
81 template<
typename SUBREGION_TYPE,
82 typename CONSTITUTIVE_TYPE,
84 int NUM_DOF_PER_TEST_SP,
85 int NUM_DOF_PER_TRIAL_SP >
117 FE_TYPE
const & finiteElementSpace,
118 CONSTITUTIVE_TYPE & inputConstitutiveType ):
226 template<
typename POLICY,
227 typename KERNEL_TYPE >
231 KERNEL_TYPE
const & kernelComponent )
236 RAJA::ReduceMax< ReducePolicy< POLICY >,
real64 > maxResidual( 0 );
238 forAll< POLICY >( numElems,
241 typename KERNEL_TYPE::StackVariables stack;
243 kernelComponent.setup( k, stack );
247 kernelComponent.quadraturePointKernel( k, q, stack );
249 maxResidual.max( kernelComponent.complete( k, stack ) );
251 return maxResidual.get();
257 traits::ViewTypeConst< typename SUBREGION_TYPE::NodeMapType::base_type >
const m_elemsToNodes;
277 template<
template<
typename SUBREGION_TYPE,
278 typename CONSTITUTIVE_TYPE,
279 typename FE_TYPE >
class KERNEL_TYPE,
307 template<
typename SUBREGION_TYPE,
typename CONSTITUTIVE_TYPE,
typename FE_TYPE >
308 KERNEL_TYPE< SUBREGION_TYPE, CONSTITUTIVE_TYPE, FE_TYPE >
createKernel(
313 SUBREGION_TYPE
const & elementSubRegion,
314 FE_TYPE
const & finiteElementSpace,
315 CONSTITUTIVE_TYPE & inputConstitutiveType )
321 SUBREGION_TYPE
const &,
323 CONSTITUTIVE_TYPE & > standardArgs { nodeManager,
329 inputConstitutiveType };
331 auto allArgs = camp::tuple_cat_pair( standardArgs, m_args );
332 return camp::make_from_tuple< KERNEL_TYPE< SUBREGION_TYPE, CONSTITUTIVE_TYPE, FE_TYPE > >( allArgs );
337 camp::tuple< ARGS ... > m_args;
367 template<
typename POLICY,
368 typename CONSTITUTIVE_BASE,
369 typename SUBREGION_TYPE,
370 typename KERNEL_FACTORY >
374 string const & finiteElementName,
375 string const & constitutiveStringName,
376 KERNEL_FACTORY & kernelFactory )
380 real64 maxResidualContribution = 0;
389 [&constitutiveStringName,
390 &maxResidualContribution,
396 (
localIndex const targetRegionIndex,
auto & elementSubRegion )
398 localIndex const numElems = elementSubRegion.size();
402 constitutive::ConstitutiveBase * constitutiveRelation =
nullptr;
403 constitutive::NullModel * nullConstitutiveModel =
nullptr;
404 if( elementSubRegion.template hasWrapper< string >( constitutiveStringName ) )
406 string const & constitutiveName = elementSubRegion.template getReference< string >( constitutiveStringName );
407 constitutiveRelation = &elementSubRegion.template getConstitutiveModel( constitutiveName );
411 nullConstitutiveModel = &elementSubRegion.template registerGroup< constitutive::NullModel >(
"nullModelGroup" );
412 constitutiveRelation = nullConstitutiveModel;
416 constitutive::ConstitutivePassThru< CONSTITUTIVE_BASE >::execute( *constitutiveRelation,
417 [&maxResidualContribution,
426 (
auto & castedConstitutiveRelation )
429 subRegionFE = elementSubRegion.template getReference< FiniteElementBase >( finiteElementName );
431 finiteElement::FiniteElementDispatchHandler< SELECTED_FE_TYPES >::dispatch3D( subRegionFE,
432 [&maxResidualContribution,
442 auto kernel = kernelFactory.createKernel( nodeManager,
448 castedConstitutiveRelation );
450 using KERNEL_TYPE = decltype( kernel );
453 maxResidualContribution =
454 std::max( maxResidualContribution,
455 KERNEL_TYPE::template kernelLaunch< POLICY, KERNEL_TYPE >( numElems, kernel ) );
460 if( nullConstitutiveModel )
462 elementSubRegion.deregisterGroup(
"nullModelGroup" );
467 return maxResidualContribution;
#define GEOS_HOST_DEVICE
Marks a host-device function.
#define GEOS_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
#define GEOS_FORCE_INLINE
Marks a function or lambda for inlining.
static real64 regionBasedKernelApplication(MeshLevel &mesh, arrayView1d< string const > const &targetRegions, string const &finiteElementName, string const &constitutiveStringName, KERNEL_FACTORY &kernelFactory)
Performs a loop over specific regions (by type and name) and calls a kernel launch on the subregions ...
#define GEOS_MARK_FUNCTION
Mark function with both Caliper and NVTX if enabled.
This class provides an interface to ObjectManagerBase in order to manage edge data.
The ElementRegionManager class provides an interface to ObjectManagerBase in order to manage ElementR...
void forElementSubRegions(LAMBDA &&lambda)
This function is used to launch kernel function over the element subregions of all the subregion type...
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data.
Class facilitating the representation of a multi-level discretization of a MeshBody.
NodeManager const & getNodeManager() const
Get the node manager.
FaceManager const & getFaceManager() const
Get the face manager.
ElementRegionManager const & getElemManager() const
Get the element region manager.
EdgeManager const & getEdgeManager() const
Get the edge manager.
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data.
Base class for FEM element implementations.
Define the base interface for finite element kernels.
traits::ViewTypeConst< typename SUBREGION_TYPE::NodeMapType::base_type > const m_elemsToNodes
The element to nodes map.
FE_TYPE const m_finiteElementSpace
GEOS_HOST_DEVICE void setup(localIndex const k, StackVariables &stack) const
Performs the setup phase for the kernel.
static constexpr int numQuadraturePointsPerElem
Compile time value for the number of quadrature points per element.
static constexpr int numDofPerTestSupportPoint
static constexpr int numDofPerTrialSupportPoint
GEOS_HOST_DEVICE GEOS_FORCE_INLINE void quadraturePointKernel(localIndex const k, localIndex const q, StackVariables &stack) const
Performs a state update at a quadrature point.
static real64 kernelLaunch(localIndex const numElems, KERNEL_TYPE const &kernelComponent)
Kernel Launcher.
GEOS_HOST_DEVICE real64 complete(localIndex const k, StackVariables &stack) const
Performs the complete phase for the kernel.
static constexpr int maxNumTrialSupportPointsPerElem
arrayView1d< integer const > const m_elemGhostRank
The element ghost rank array.
CONSTITUTIVE_TYPE::KernelWrapper const m_constitutiveUpdate
KernelBase(SUBREGION_TYPE const &elementSubRegion, FE_TYPE const &finiteElementSpace, CONSTITUTIVE_TYPE &inputConstitutiveType)
Constructor.
static constexpr int maxNumTestSupportPointsPerElem
Used to forward arguments to a class that implements the KernelBase interface.
KERNEL_TYPE< SUBREGION_TYPE, CONSTITUTIVE_TYPE, FE_TYPE > createKernel(NodeManager &nodeManager, EdgeManager const &edgeManager, FaceManager const &faceManager, localIndex const targetRegionIndex, SUBREGION_TYPE const &elementSubRegion, FE_TYPE const &finiteElementSpace, CONSTITUTIVE_TYPE &inputConstitutiveType)
Create a new kernel with the given standard arguments.
KernelFactory(ARGS ... args)
Initialize the factory.
ArrayView< T, 1 > arrayView1d
Alias for 1D array view.
double real64
64-bit floating point type.
GEOS_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
std::int32_t integer
Signed integer type.
Kernel variables allocated on the stack.