20 #ifndef GEOS_FINITEELEMENT_KERNELBASE_HPP_
21 #define GEOS_FINITEELEMENT_KERNELBASE_HPP_
25 #include "constitutive/ConstitutivePassThru.hpp"
26 #include "finiteElement/FiniteElementDispatch.hpp"
28 #include "common/GEOS_RAJA_Interface.hpp"
34 #ifndef SELECTED_FE_TYPES
35 #define SELECTED_FE_TYPES BASE_FE_TYPES
80 template<
typename SUBREGION_TYPE,
81 typename CONSTITUTIVE_TYPE,
83 int NUM_DOF_PER_TEST_SP,
84 int NUM_DOF_PER_TRIAL_SP >
116 FE_TYPE
const & finiteElementSpace,
117 CONSTITUTIVE_TYPE & inputConstitutiveType ):
225 template<
typename POLICY,
226 typename KERNEL_TYPE >
230 KERNEL_TYPE
const & kernelComponent )
235 RAJA::ReduceMax< ReducePolicy< POLICY >,
real64 > maxResidual( 0 );
237 forAll< POLICY >( numElems,
240 typename KERNEL_TYPE::StackVariables stack;
242 kernelComponent.setup( k, stack );
246 kernelComponent.quadraturePointKernel( k, q, stack );
248 maxResidual.max( kernelComponent.complete( k, stack ) );
250 return maxResidual.get();
256 traits::ViewTypeConst< typename SUBREGION_TYPE::NodeMapType::base_type >
const m_elemsToNodes;
276 template<
template<
typename SUBREGION_TYPE,
277 typename CONSTITUTIVE_TYPE,
278 typename FE_TYPE >
class KERNEL_TYPE,
306 template<
typename SUBREGION_TYPE,
typename CONSTITUTIVE_TYPE,
typename FE_TYPE >
307 KERNEL_TYPE< SUBREGION_TYPE, CONSTITUTIVE_TYPE, FE_TYPE >
createKernel(
312 SUBREGION_TYPE
const & elementSubRegion,
313 FE_TYPE
const & finiteElementSpace,
314 CONSTITUTIVE_TYPE & inputConstitutiveType )
320 SUBREGION_TYPE
const &,
322 CONSTITUTIVE_TYPE & > standardArgs { nodeManager,
328 inputConstitutiveType };
330 auto allArgs = camp::tuple_cat_pair( standardArgs, m_args );
331 return camp::make_from_tuple< KERNEL_TYPE< SUBREGION_TYPE, CONSTITUTIVE_TYPE, FE_TYPE > >( allArgs );
336 camp::tuple< ARGS ... > m_args;
366 template<
typename POLICY,
367 typename CONSTITUTIVE_BASE,
368 typename SUBREGION_TYPE,
369 typename KERNEL_FACTORY >
373 string const & finiteElementName,
374 string const & constitutiveStringName,
375 KERNEL_FACTORY & kernelFactory )
379 real64 maxResidualContribution = 0;
388 [&constitutiveStringName,
389 &maxResidualContribution,
395 (
localIndex const targetRegionIndex,
auto & elementSubRegion )
397 localIndex const numElems = elementSubRegion.size();
401 constitutive::ConstitutiveBase * constitutiveRelation =
nullptr;
402 constitutive::NullModel * nullConstitutiveModel =
nullptr;
403 if( elementSubRegion.template hasWrapper< string >( constitutiveStringName ) )
405 string const & constitutiveName = elementSubRegion.template getReference< string >( constitutiveStringName );
406 constitutiveRelation = &elementSubRegion.template getConstitutiveModel( constitutiveName );
410 nullConstitutiveModel = &elementSubRegion.template registerGroup< constitutive::NullModel >(
"nullModelGroup" );
411 constitutiveRelation = nullConstitutiveModel;
415 constitutive::ConstitutivePassThru< CONSTITUTIVE_BASE >::execute( *constitutiveRelation,
416 [&maxResidualContribution,
425 (
auto & castedConstitutiveRelation )
428 subRegionFE = elementSubRegion.template getReference< FiniteElementBase >( finiteElementName );
430 finiteElement::FiniteElementDispatchHandler< SELECTED_FE_TYPES >::dispatch3D( subRegionFE,
431 [&maxResidualContribution,
441 auto kernel = kernelFactory.createKernel( nodeManager,
447 castedConstitutiveRelation );
449 using KERNEL_TYPE = decltype( kernel );
452 maxResidualContribution =
453 std::max( maxResidualContribution,
454 KERNEL_TYPE::template kernelLaunch< POLICY, KERNEL_TYPE >( numElems, kernel ) );
459 if( nullConstitutiveModel )
461 elementSubRegion.deregisterGroup(
"nullModelGroup" );
466 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.
Define the base interface for finite element kernels.
traits::ViewTypeConst< typename SUBREGION_TYPE::NodeMapType::base_type > const m_elemsToNodes
The element to nodes map.
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
FE_TYPE const & m_finiteElementSpace
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.
std::int32_t integer
Signed integer type.
GEOSX_LOCALINDEX_TYPE localIndex
Local index type (for indexing objects within an MPI partition).
Kernel variables allocated on the stack.