20 #ifndef GEOSX_FINITEELEMENT_KERNELBASE_HPP_ 21 #define GEOSX_FINITEELEMENT_KERNELBASE_HPP_ 25 #include "constitutive/ConstitutivePassThru.hpp" 26 #include "finiteElement/FiniteElementDispatch.hpp" 28 #include "rajaInterface/GEOS_RAJA_Interface.hpp" 32 #if defined(__APPLE__) 33 #define CONSTRUCTOR_PARAM_OPTION 2 36 #define CONSTRUCTOR_PARAM_OPTION 1 40 #if CONSTRUCTOR_PARAM_OPTION==1 58 constexpr T make_from_tuple_impl( Tuple && t, std::index_sequence< I... > )
60 return T( std::get< I >( std::forward< Tuple >( t ))... );
73 template<
class T,
class Tuple >
76 return detail::make_from_tuple_impl< T >( std::forward< Tuple >( t ),
77 std::make_index_sequence< std::tuple_size< std::remove_reference_t< Tuple > >::value >{} );
81 #elif CONSTRUCTOR_PARAM_OPTION==2 82 #include "camp/camp.hpp" 127 template<
typename SUBREGION_TYPE,
128 typename CONSTITUTIVE_TYPE,
130 int NUM_DOF_PER_TEST_SP,
131 int NUM_DOF_PER_TRIAL_SP >
137 static constexpr
int numTestSupportPointsPerElem = FE_TYPE::numNodes;
141 static constexpr
int numTrialSupportPointsPerElem = FE_TYPE::numNodes;
145 static constexpr
int numDofPerTestSupportPoint = NUM_DOF_PER_TEST_SP;
149 static constexpr
int numDofPerTrialSupportPoint = NUM_DOF_PER_TRIAL_SP;
152 static constexpr
int numQuadraturePointsPerElem = FE_TYPE::numQuadraturePoints;
163 FE_TYPE
const & finiteElementSpace,
164 CONSTITUTIVE_TYPE *
const inputConstitutiveType ):
165 m_elemsToNodes( elementSubRegion.nodeList().toViewConst() ),
166 m_elemGhostRank( elementSubRegion.ghostRank() ),
167 m_constitutiveUpdate( inputConstitutiveType->createKernelUpdates() ),
168 m_finiteElementSpace( finiteElementSpace )
201 StackVariables & stack )
const 227 StackVariables & stack )
const 251 StackVariables & stack )
const 272 template<
typename POLICY,
273 typename KERNEL_TYPE >
277 KERNEL_TYPE
const & kernelComponent )
282 RAJA::ReduceMax< ReducePolicy< POLICY >,
real64 > maxResidual( 0 );
284 forAll< POLICY >( numElems,
287 typename KERNEL_TYPE::StackVariables stack;
289 kernelComponent.setup( k, stack );
290 for(
integer q=0; q<numQuadraturePointsPerElem; ++q )
292 kernelComponent.quadraturePointKernel( k, q, stack );
294 maxResidual.max( kernelComponent.complete( k, stack ) );
296 return maxResidual.get();
302 traits::ViewTypeConst< typename SUBREGION_TYPE::NodeMapType::base_type >
const m_elemsToNodes;
360 template<
typename POLICY,
361 typename CONSTITUTIVE_BASE,
362 typename REGION_TYPE,
363 template<
typename SUBREGION_TYPE,
364 typename CONSTITUTIVE_TYPE,
365 typename FE_TYPE >
class KERNEL_TEMPLATE,
366 typename ... KERNEL_CONSTRUCTOR_PARAMS >
370 string const & finiteElementName,
372 KERNEL_CONSTRUCTOR_PARAMS && ... kernelConstructorParams )
376 real64 maxResidualContribution = 0;
378 NodeManager & nodeManager = *(mesh.getNodeManager());
379 EdgeManager & edgeManager = *(mesh.getEdgeManager());
380 FaceManager & faceManager = *(mesh.getFaceManager());
386 #if CONSTRUCTOR_PARAM_OPTION==1 387 std::tuple< KERNEL_CONSTRUCTOR_PARAMS &... > kernelConstructorParamsTuple = std::forward_as_tuple( kernelConstructorParams ... );
388 #elif CONSTRUCTOR_PARAM_OPTION==2 389 camp::tuple< KERNEL_CONSTRUCTOR_PARAMS &... > kernelConstructorParamsTuple = camp::forward_as_tuple( kernelConstructorParams ... );
396 &maxResidualContribution,
400 &kernelConstructorParamsTuple,
402 (
localIndex const targetRegionIndex,
auto & elementSubRegion )
404 localIndex const numElems = elementSubRegion.size();
407 typedef TYPEOFREF( elementSubRegion ) SUBREGIONTYPE;
410 constitutive::ConstitutiveBase * constitutiveRelation =
nullptr;
411 constitutive::NullModel * nullConstitutiveModel =
nullptr;
412 if( targetRegionIndex <= constitutiveNames.size()-1 )
414 constitutiveRelation = elementSubRegion.template getConstitutiveModel( constitutiveNames[targetRegionIndex] );
418 nullConstitutiveModel = elementSubRegion.template RegisterGroup< constitutive::NullModel >(
"nullModelGroup" );
419 constitutiveRelation = nullConstitutiveModel;
423 constitutive::ConstitutivePassThru< CONSTITUTIVE_BASE >::Execute( constitutiveRelation,
424 [&maxResidualContribution,
428 &kernelConstructorParamsTuple,
432 (
auto *
const castedConstitutiveRelation )
435 using CONSTITUTIVE_TYPE =
TYPEOFPTR( castedConstitutiveRelation );
438 string const elementTypeString = elementSubRegion.GetElementTypeString();
441 subRegionFE = elementSubRegion.template getReference< FiniteElementBase >( finiteElementName );
443 finiteElement::dispatch3D( subRegionFE,
444 [&maxResidualContribution,
448 &kernelConstructorParamsTuple,
456 using KERNEL_TYPE = KERNEL_TEMPLATE< SUBREGIONTYPE,
466 #if CONSTRUCTOR_PARAM_OPTION==1 467 auto temp = std::forward_as_tuple( nodeManager,
472 castedConstitutiveRelation );
474 auto fullKernelComponentConstructorArgs = std::tuple_cat( temp,
475 kernelConstructorParamsTuple );
477 KERNEL_TYPE kernelComponent = std::make_from_tuple< KERNEL_TYPE >( fullKernelComponentConstructorArgs );
479 #elif CONSTRUCTOR_PARAM_OPTION==2 480 auto temp = camp::forward_as_tuple( nodeManager,
485 castedConstitutiveRelation );
486 auto fullKernelComponentConstructorArgs = camp::tuple_cat_pair( temp,
487 kernelConstructorParamsTuple );
488 KERNEL_TYPE kernelComponent = camp::make_from_tuple< KERNEL_TYPE >( fullKernelComponentConstructorArgs );
493 maxResidualContribution =
495 KERNEL_TYPE::template kernelLaunch< POLICY,
496 KERNEL_TYPE >( numElems,
502 if( nullConstitutiveModel )
504 elementSubRegion.deregisterGroup(
"nullModelGroup" );
509 return maxResidualContribution;
#define GEOSX_HOST_DEVICE
Marks a host-device function.
CONSTITUTIVE_TYPE::KernelWrapper const m_constitutiveUpdate
Kernel variables allocated on the stack.
constexpr T make_from_tuple(Tuple &&t)
Implementation of std::make_from_tuple()
#define TYPEOFREF(X)
Given an expression X that evaluates to a reference, expands to the type referred to...
Class facilitating the representation of a multi-level discretization of a MeshBody.
The NodeManager class provides an interface to ObjectManagerBase in order to manage node data...
arrayView1d< integer const > const m_elemGhostRank
The element ghost rank array.
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE void setup(localIndex const k, StackVariables &stack) const
Performs the setup phase for the kernel.
traits::ViewTypeConst< typename SUBREGION_TYPE::NodeMapType::base_type > const m_elemsToNodes
The element to nodes map.
This class serves to provide a "view" of a multidimensional array.
double real64
64-bit floating point type.
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE void quadraturePointKernel(localIndex const k, localIndex const q, StackVariables &stack) const
Performs a state update at a quadrature point.
Define the base interface for finite element kernels.
static real64 kernelLaunch(localIndex const numElems, KERNEL_TYPE const &kernelComponent)
Kernel Launcher.
FE_TYPE const & m_finiteElementSpace
std::int32_t integer
Signed integer type.
This class provides an interface to ObjectManagerBase in order to manage edge data.
#define TYPEOFPTR(X)
Given an expression X that evaluates to a pointer, expands to the type pointed to.
#define GEOSX_FORCE_INLINE
Marks a function or lambda for inlining.
#define GEOSX_UNUSED_VAR(...)
Mark an unused variable and silence compiler warnings.
std::ptrdiff_t localIndex
Local index type (for indexing objects within an MPI partition).
The ElementRegionManager class provides an interface to ObjectManagerBase in order to manage ElementR...
The FaceManager class provides an interface to ObjectManagerBase in order to manage face data...
static real64 regionBasedKernelApplication(MeshLevel &mesh, arrayView1d< string const > const &targetRegions, string const &finiteElementName, arrayView1d< string const > const &constitutiveNames, KERNEL_CONSTRUCTOR_PARAMS &&... kernelConstructorParams)
Performs a loop over specific regions (by type and name) and calls a kernel launch on the subregions ...
KernelBase(SUBREGION_TYPE const &elementSubRegion, FE_TYPE const &finiteElementSpace, CONSTITUTIVE_TYPE *const inputConstitutiveType)
Constructor.
std::size_t size_t
Unsigned size type.
void forElementSubRegions(LAMBDA &&lambda)
This function is used to launch kernel function over the element subregions of all the subregion type...
constexpr std::enable_if_t< std::is_arithmetic< T >::value, T > max(T const a, T const b)
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE real64 complete(localIndex const k, StackVariables &stack) const
Performs the complete phase for the kernel.