https://mooseframework.inl.gov
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Moose::Kokkos::ElementReducer Class Reference

#include <KokkosElementReducer.h>

Inheritance diagram for Moose::Kokkos::ElementReducer:
[legend]

Public Member Functions

 ElementReducer (const MooseObject *object)
 
 ElementReducer (const ElementReducer &object)
 Copy constructor for parallel dispatch. More...
 
virtual ThreadID numReducerThreads () const override
 Get the number of threads. More...
 
template<typename Derived >
KOKKOS_FUNCTION void operator() (ReducerLoop, const ThreadID tid, const Derived &reducer, Real *result) const
 The parallel computation entry function called by Kokkos. More...
 
KOKKOS_FUNCTION const MeshkokkosMesh () const
 Get the const reference of the Kokkos mesh. More...
 
KOKKOS_FUNCTION const AssemblykokkosAssembly () const
 Get the const reference of the Kokkos assembly. More...
 
KOKKOS_FUNCTION const Array< System > & kokkosSystems () const
 Get the const reference of the Kokkos systems. More...
 
Array< System > & kokkosSystems ()
 Get the writeable host reference of the Kokkos systems. More...
 
KOKKOS_FUNCTION const SystemkokkosSystem (unsigned int sys) const
 Get the const reference of a Kokkos system. More...
 
SystemkokkosSystem (unsigned int sys)
 Get the writeable reference of a Kokkos system. More...
 
const std::vector< SubdomainName > & blocks () const
 Return the block names for this object. More...
 
unsigned int numBlocks () const
 Return the number of blocks for this object. More...
 
virtual const std::set< SubdomainID > & blockIDs () const
 Return the block subdomain ids for this object Note, if this is not block restricted, this function returns all mesh subdomain ids. More...
 
unsigned int blocksMaxDimension () const
 Return the largest mesh dimension of the elements in the blocks for this object. More...
 
bool hasBlocks (const SubdomainName &name) const
 Test if the supplied block name is valid for this object. More...
 
bool hasBlocks (const std::vector< SubdomainName > &names) const
 Test if the supplied vector of block names are valid for this object. More...
 
bool hasBlocks (const std::set< SubdomainName > &names) const
 Test if the supplied set of block names are valid for this object. More...
 
bool hasBlocks (SubdomainID id) const
 Test if the supplied block ids are valid for this object. More...
 
bool hasBlocks (const std::vector< SubdomainID > &ids) const
 Test if the supplied vector block ids are valid for this object. More...
 
bool hasBlocks (const std::set< SubdomainID > &ids) const
 Test if the supplied set of block ids are valid for this object. More...
 
bool isBlockSubset (const std::set< SubdomainID > &ids) const
 Test if the class block ids are a subset of the supplied objects. More...
 
bool isBlockSubset (const std::vector< SubdomainID > &ids) const
 Test if the class block ids are a subset of the supplied objects. More...
 
template<typename T , bool is_ad = false>
bool hasBlockMaterialProperty (const std::string &prop_name)
 Check if a material property is valid for all blocks of this object. More...
 
const std::set< SubdomainID > & meshBlockIDs () const
 Return all of the SubdomainIDs for the mesh. More...
 
virtual bool blockRestricted () const
 Returns true if this object has been restricted to a block. More...
 
virtual void checkVariable (const MooseVariableFieldBase &variable) const
 Helper for checking that the ids for this object are in agreement with the variables on the supplied variable. More...
 
template<typename Derived >
KOKKOS_FUNCTION void reduce (Datum &, Real *) const
 Default methods to prevent compile errors even when these methods were not defined in the derived class. More...
 
template<typename Derived >
KOKKOS_FUNCTION void join (Real *, const Real *) const
 
template<typename Derived >
KOKKOS_FUNCTION void init (Real *) const
 

Static Public Member Functions

static InputParameters validParams ()
 
template<typename Derived >
static auto defaultReduce ()
 Function used to check if users have overriden the hook method. More...
 

Protected Member Functions

virtual void computeReducer ()
 Dispatch reduction operation. More...
 
void allocateReductionBuffer (const unsigned int size)
 Allocate reduction buffer. More...
 
virtual bool hasBlockMaterialPropertyHelper (const std::string &prop_name)
 A helper method to allow the Material object to specialize the behavior of hasBlockMaterialProperty. More...
 
void initializeBlockRestrictable (const MooseObject *moose_object)
 An initialization routine needed for dual constructors. More...
 
void initializeKokkosBlockRestrictable ()
 
Moose::CoordinateSystemType getBlockCoordSystem ()
 Check if the blocks this object operates on all have the same coordinate system, and if so return it. More...
 
KOKKOS_FUNCTION dof_id_type numKokkosBlockElements () const
 Get the number of elements this Kokkos object is operating on. More...
 
KOKKOS_FUNCTION dof_id_type numKokkosBlockNodes () const
 Get the number of nodes this Kokkos object is operating on. More...
 
KOKKOS_FUNCTION dof_id_type numKokkosBlockSides () const
 Get the number of sides this Kokkos object is operating on. More...
 
KOKKOS_FUNCTION ContiguousElementID kokkosBlockElementID (Moose::Kokkos::ThreadID tid) const
 Get the contiguous element ID this Kokkos thread is operating on. More...
 
KOKKOS_FUNCTION ContiguousElementID kokkosBlockNodeID (Moose::Kokkos::ThreadID tid) const
 Get the contiguous node index this Kokkos thread is operating on. More...
 
KOKKOS_FUNCTION auto kokkosBlockElementSideID (Moose::Kokkos::ThreadID tid) const
 Get the contiguous element ID - side index pair this Kokkos thread is operating on. More...
 

Protected Attributes

const MooseObject_reducer_object
 MOOSE object. More...
 
std::unique_ptr< DispatcherBase_reducer_dispatcher
 Kokkos functor dispatcher. More...
 
::Kokkos::View< Real *, ::Kokkos::HostSpace > _reduction_buffer
 Reduction buffer. More...
 
const MaterialData_blk_material_data
 Pointer to the MaterialData class for this object. More...
 

Detailed Description

Definition at line 19 of file KokkosElementReducer.h.

Constructor & Destructor Documentation

◆ ElementReducer() [1/2]

Moose::Kokkos::ElementReducer::ElementReducer ( const MooseObject object)

◆ ElementReducer() [2/2]

Moose::Kokkos::ElementReducer::ElementReducer ( const ElementReducer object)

Copy constructor for parallel dispatch.

Member Function Documentation

◆ allocateReductionBuffer()

void Moose::Kokkos::ReducerBase::allocateReductionBuffer ( const unsigned int  size)
inlineprotectedinherited

Allocate reduction buffer.

Definition at line 88 of file KokkosReducerBase.h.

89  {
90  ::Kokkos::realloc(_reduction_buffer, size);
91  }
::Kokkos::View< Real *, ::Kokkos::HostSpace > _reduction_buffer
Reduction buffer.

◆ blockIDs()

const std::set< SubdomainID > & BlockRestrictable::blockIDs ( ) const
virtualinherited

Return the block subdomain ids for this object Note, if this is not block restricted, this function returns all mesh subdomain ids.

Returns
a set of SubdomainIDs that are valid for this object

Definition at line 209 of file BlockRestrictable.C.

Referenced by FunctorMaterial::addFunctorProperty(), DiracKernelBase::addPoint(), DiracKernelBase::addPointWithValidId(), NodalPatchRecoveryAuxBase::blockRestrictElements(), MooseMesh::cacheFaceInfoVariableOwnership(), MooseMesh::cacheFVElementalDoFs(), ComboMarker::ComboMarker(), ElementGroupCentroidPositions::ElementGroupCentroidPositions(), ExtraIDIntegralVectorPostprocessor::ExtraIDIntegralVectorPostprocessor(), BlockRestrictable::getBlockCoordSystem(), MaterialBase::getGenericZeroMaterialPropertyByName(), NEML2FEInterpolation::getMOOSEVariable(), FunctorIC::gradient(), BlockRestrictable::hasBlockMaterialPropertyHelper(), IndicatorMarker::IndicatorMarker(), SubdomainsDivision::initialize(), ElementCentroidPositions::initialize(), QuadraturePointsPositions::initialize(), FunctorExtremaPositions::initialize(), NodalPatchRecoveryAux::NodalPatchRecoveryAux(), PointwiseRenormalizeVector::PointwiseRenormalizeVector(), ProjectedMaterialPropertyNodalPatchRecoveryAux::ProjectedMaterialPropertyNodalPatchRecoveryAux(), MaterialBase::registerPropName(), FVPointValueConstraint::setMyElem(), and FunctorIC::value().

210 {
211  if (_blk_ids.find(Moose::ANY_BLOCK_ID) != _blk_ids.end())
212  return _blk_mesh->meshSubdomains();
213  else
214  return _blk_ids;
215 }
const MooseMesh * _blk_mesh
Pointer to Mesh.
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.C:19
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error checking)
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:3298

◆ blockRestricted()

bool BlockRestrictable::blockRestricted ( ) const
virtualinherited

◆ blocks()

const std::vector< SubdomainName > & BlockRestrictable::blocks ( ) const
inherited

Return the block names for this object.

Note, if the 'blocks' input parameter was not utilized this will return an empty vector.

Returns
vector of SubdomainNames that are valid for this object

Definition at line 203 of file BlockRestrictable.C.

Referenced by MaterialOutputAction::getParams(), SubdomainsDivision::initialize(), and SolutionIC::initialSetup().

204 {
205  return _blocks;
206 }
std::vector< SubdomainName > _blocks
Vector the block names supplied by the user via the input file.

◆ blocksMaxDimension()

unsigned int BlockRestrictable::blocksMaxDimension ( ) const
inherited

Return the largest mesh dimension of the elements in the blocks for this object.

Definition at line 386 of file BlockRestrictable.C.

387 {
388  mooseAssert(_blk_dim != libMesh::invalid_uint, "Block restriction not initialized");
389  return _blk_dim;
390 }
unsigned int _blk_dim
Largest mesh dimension of the elements in the blocks for this object.
const unsigned int invalid_uint

◆ checkVariable()

void BlockRestrictable::checkVariable ( const MooseVariableFieldBase variable) const
virtualinherited

Helper for checking that the ids for this object are in agreement with the variables on the supplied variable.

Parameters
variableThe variable to check against.

Reimplemented in DomainUserObject.

Definition at line 358 of file BlockRestrictable.C.

Referenced by DomainUserObject::checkVariable().

359 {
360  // a variable defined on all internal sides does not need this check because
361  // it can be coupled with other variables in DG kernels
362  if (!_blk_mesh->interiorLowerDBlocks().empty() &&
364  return;
365 
366  if (!isBlockSubset(variable.activeSubdomains()))
367  {
368  std::string var_ids = Moose::stringify(variable.activeSubdomains(), ", ");
369  std::string obj_ids = Moose::stringify(blockRestricted() ? _blk_ids : meshBlockIDs(), ", ");
370  mooseError("The 'block' parameter of the object '",
371  _blk_name,
372  "' must be a subset of the 'block' parameter of the variable '",
373  variable.name(),
374  "':\n Object '",
375  _blk_name,
376  "': ",
377  obj_ids,
378  "\n Variable '",
379  variable.name(),
380  "': ",
381  var_ids);
382  }
383 }
const std::set< SubdomainID > & interiorLowerDBlocks() const
Definition: MooseMesh.h:1549
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
virtual bool blockRestricted() const
Returns true if this object has been restricted to a block.
bool isBlockSubset(const std::set< SubdomainID > &ids) const
Test if the class block ids are a subset of the supplied objects.
const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:103
bool activeOnSubdomains(const std::set< SubdomainID > &subdomains) const
Is the variable active on the subdomains?
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:64
const MooseMesh * _blk_mesh
Pointer to Mesh.
const std::set< SubdomainID > & activeSubdomains() const
The subdomains the variable is active on.
const std::set< SubdomainID > & meshBlockIDs() const
Return all of the SubdomainIDs for the mesh.
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error checking)
const std::string & _blk_name
Name of the object.

◆ computeReducer()

virtual void Moose::Kokkos::ReducerBase::computeReducer ( )
protectedvirtualinherited

Dispatch reduction operation.

◆ defaultReduce()

template<typename Derived >
static auto Moose::Kokkos::ReducerBase::defaultReduce ( )
inlinestaticinherited

Function used to check if users have overriden the hook method.

Returns
The function pointer of the default hook method

Definition at line 70 of file KokkosReducerBase.h.

71  {
72  return &ReducerBase::reduce<Derived>;
73  }

◆ getBlockCoordSystem()

Moose::CoordinateSystemType BlockRestrictable::getBlockCoordSystem ( )
protectedinherited

Check if the blocks this object operates on all have the same coordinate system, and if so return it.

Definition at line 336 of file BlockRestrictable.C.

337 {
338  if (!_blk_mesh)
339  mooseError("No mesh available in BlockRestrictable::checkCoordSystem()");
340  if (!_blk_feproblem)
341  mooseError("No problem available in BlockRestrictable::checkCoordSystem()");
342 
343  const auto & subdomains = blockRestricted() ? blockIDs() : meshBlockIDs();
344 
345  if (subdomains.empty())
346  mooseError("No subdomains found in the problem.");
347 
348  // make sure all subdomains are using the same coordinate system
349  auto coord_system = _blk_feproblem->getCoordSystem(*subdomains.begin());
350  for (auto subdomain : subdomains)
351  if (_blk_feproblem->getCoordSystem(subdomain) != coord_system)
352  mooseError("This object requires all subdomains to have the same coordinate system.");
353 
354  return coord_system;
355 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
FEProblemBase * _blk_feproblem
Pointer to FEProblemBase.
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted, this function returns all mesh subdomain ids.
virtual bool blockRestricted() const
Returns true if this object has been restricted to a block.
const MooseMesh * _blk_mesh
Pointer to Mesh.
const std::set< SubdomainID > & meshBlockIDs() const
Return all of the SubdomainIDs for the mesh.
Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) const
Definition: SubProblem.C:1283

◆ hasBlockMaterialProperty()

template<typename T , bool is_ad>
bool BlockRestrictable::hasBlockMaterialProperty ( const std::string &  prop_name)
inherited

Check if a material property is valid for all blocks of this object.

This method returns true if the supplied property name has been declared in a Material object on the block ids for this object.

Template Parameters
TThe type of material property
Parameters
prop_namethe name of the property to query
Returns
true if the property exists for all block ids of the object, otherwise false
See also
Material::hasBlockMaterialProperty

Definition at line 360 of file BlockRestrictable.h.

361 {
362  mooseAssert(_blk_material_data != NULL, "MaterialData pointer is not defined");
363  return hasBlockMaterialPropertyHelper(prop_name) &&
364  _blk_material_data->haveGenericProperty<T, is_ad>(prop_name);
365 }
bool haveGenericProperty(const std::string &prop_name) const
Definition: MaterialData.h:370
const MaterialData * _blk_material_data
Pointer to the MaterialData class for this object.
virtual bool hasBlockMaterialPropertyHelper(const std::string &prop_name)
A helper method to allow the Material object to specialize the behavior of hasBlockMaterialProperty.

◆ hasBlockMaterialPropertyHelper()

bool BlockRestrictable::hasBlockMaterialPropertyHelper ( const std::string &  prop_name)
protectedvirtualinherited

A helper method to allow the Material object to specialize the behavior of hasBlockMaterialProperty.

It also avoid circular #include problems.

See also
hasBlockMaterialProperty

Definition at line 300 of file BlockRestrictable.C.

Referenced by BlockRestrictable::hasBlockMaterialProperty().

301 {
302 
303  // Reference to MaterialWarehouse for testing and retrieving block ids
305 
306  // Complete set of ids that this object is active
307  const std::set<SubdomainID> & ids = blockRestricted() ? blockIDs() : meshBlockIDs();
308 
309  // Loop over each id for this object
310  for (const auto & id : ids)
311  {
312  // Storage of material properties that have been DECLARED on this id
313  std::set<std::string> declared_props;
314 
315  // If block materials exist, populated the set of properties that were declared
316  if (warehouse.hasActiveBlockObjects(id))
317  {
318  const std::vector<std::shared_ptr<MaterialBase>> & mats = warehouse.getActiveBlockObjects(id);
319  for (const auto & mat : mats)
320  {
321  const std::set<std::string> & mat_props = mat->getSuppliedItems();
322  declared_props.insert(mat_props.begin(), mat_props.end());
323  }
324  }
325 
326  // If the supplied property is not in the list of properties on the current id, return false
327  if (declared_props.find(prop_name) == declared_props.end())
328  return false;
329  }
330 
331  // If you get here the supplied property is defined on all blocks
332  return true;
333 }
bool hasActiveBlockObjects(THREAD_ID tid=0) const
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
FEProblemBase * _blk_feproblem
Pointer to FEProblemBase.
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object Note, if this is not block restricted, this function returns all mesh subdomain ids.
virtual bool blockRestricted() const
Returns true if this object has been restricted to a block.
MaterialBase objects are special in that they have additional objects created automatically (see FEPr...
const MaterialWarehouse & getMaterialWarehouse() const
const std::set< SubdomainID > & meshBlockIDs() const
Return all of the SubdomainIDs for the mesh.

◆ hasBlocks() [1/6]

bool BlockRestrictable::hasBlocks ( const SubdomainName &  name) const
inherited

Test if the supplied block name is valid for this object.

Parameters
nameA SubdomainName to check
Returns
True if the given id is valid for this object

Definition at line 224 of file BlockRestrictable.C.

Referenced by LinearFVFluxKernel::addMatrixContribution(), DiracKernelBase::addPoint(), LinearFVFluxKernel::addRightHandSideContribution(), NodalPatchRecoveryBase::addToQuery(), MultiAppVariableValueSamplePostprocessorTransfer::cacheElemToPostprocessorData(), DomainUserObject::checkVariable(), ComputeJacobianThread::compute(), ComboMarker::computeElementMarker(), GradientJumpIndicator::computeQpIntegral(), ProjectionAux::computeValue(), DomainUserObject::DomainUserObject(), ProjectionAux::elemOnNodeVariableIsDefinedOn(), MultiAppVariableValueSamplePostprocessorTransfer::execute(), QuadraturePointMultiApp::fillPositions(), CentroidMultiApp::fillPositions(), NodalPatchRecoveryBase::gatherRequestList(), NodalPatchRecoveryBase::getCoefficients(), MeshDivisionFunctorReductionVectorPostprocessor::hasBlocks(), BlockRestrictable::hasBlocks(), MooseVariableField< Real >::hasBlocks(), FVFluxKernel::hasFaceSide(), IndicatorMarker::IndicatorMarker(), NodePositions::initialize(), ParsedDownSelectionPositions::initialize(), UpdateErrorVectorsThread::onElement(), PointwiseRenormalizeVector::PointwiseRenormalizeVector(), and BlockRestrictionDebugOutput::printBlockRestrictionMap().

225 {
226  // Create a vector and utilize the getSubdomainIDs function, which
227  // handles the ANY_BLOCK_ID (getSubdomainID does not)
228  std::vector<SubdomainName> names(1);
229  names[0] = name;
230  return hasBlocks(_blk_mesh->getSubdomainIDs(names));
231 }
std::string name(const ElemQuality q)
std::vector< SubdomainID > getSubdomainIDs(const std::vector< SubdomainName > &subdomain_names) const
Get the associated subdomainIDs for the subdomain names that are passed in.
Definition: MooseMesh.C:1759
const MooseMesh * _blk_mesh
Pointer to Mesh.
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.

◆ hasBlocks() [2/6]

bool BlockRestrictable::hasBlocks ( const std::vector< SubdomainName > &  names) const
inherited

Test if the supplied vector of block names are valid for this object.

Parameters
namesA vector of SubdomainNames to check
Returns
True if the given ids are valid for this object

Definition at line 234 of file BlockRestrictable.C.

235 {
236  return hasBlocks(_blk_mesh->getSubdomainIDs(names));
237 }
std::vector< SubdomainID > getSubdomainIDs(const std::vector< SubdomainName > &subdomain_names) const
Get the associated subdomainIDs for the subdomain names that are passed in.
Definition: MooseMesh.C:1759
const MooseMesh * _blk_mesh
Pointer to Mesh.
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.

◆ hasBlocks() [3/6]

bool BlockRestrictable::hasBlocks ( const std::set< SubdomainName > &  names) const
inherited

Test if the supplied set of block names are valid for this object.

Parameters
namesA set of SubdomainNames to check
Returns
True if the given ids are valid for this object

Definition at line 240 of file BlockRestrictable.C.

241 {
242  return hasBlocks(_blk_mesh->getSubdomainIDs(names));
243 }
std::vector< SubdomainID > getSubdomainIDs(const std::vector< SubdomainName > &subdomain_names) const
Get the associated subdomainIDs for the subdomain names that are passed in.
Definition: MooseMesh.C:1759
const MooseMesh * _blk_mesh
Pointer to Mesh.
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.

◆ hasBlocks() [4/6]

bool BlockRestrictable::hasBlocks ( SubdomainID  id) const
inherited

Test if the supplied block ids are valid for this object.

Parameters
idA SubdomainID to check
Returns
True if the given id is valid for this object

Definition at line 246 of file BlockRestrictable.C.

247 {
248  if (_blk_ids.empty() || _blk_ids.find(Moose::ANY_BLOCK_ID) != _blk_ids.end())
249  return true;
250  else
251  return _blk_ids.find(id) != _blk_ids.end();
252 }
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.C:19
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error checking)

◆ hasBlocks() [5/6]

bool BlockRestrictable::hasBlocks ( const std::vector< SubdomainID > &  ids) const
inherited

Test if the supplied vector block ids are valid for this object.

Parameters
idsA vector of SubdomainIDs ids to check
Returns
True if all of the given ids are found within the ids for this object

Definition at line 255 of file BlockRestrictable.C.

256 {
257  std::set<SubdomainID> ids_set(ids.begin(), ids.end());
258  return hasBlocks(ids_set);
259 }
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.

◆ hasBlocks() [6/6]

bool BlockRestrictable::hasBlocks ( const std::set< SubdomainID > &  ids) const
inherited

Test if the supplied set of block ids are valid for this object.

Parameters
idsA std::set of SubdomainIDs to check
Returns
True if all of the given ids are found within the ids for this object
See also
isSubset

Definition at line 262 of file BlockRestrictable.C.

263 {
264  if (_blk_ids.empty() || _blk_ids.find(Moose::ANY_BLOCK_ID) != _blk_ids.end())
265  return true;
266  else
267  return std::includes(_blk_ids.begin(), _blk_ids.end(), ids.begin(), ids.end());
268 }
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.C:19
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error checking)

◆ init()

template<typename Derived >
KOKKOS_FUNCTION void Moose::Kokkos::ReducerBase::init ( Real ) const
inlineinherited

Definition at line 58 of file KokkosReducerBase.h.

59  {
60  ::Kokkos::abort("Default init() should never be called. Make sure you properly redefined this "
61  "method in your class without typos.");
62  }

◆ initializeBlockRestrictable()

void BlockRestrictable::initializeBlockRestrictable ( const MooseObject moose_object)
protectedinherited

An initialization routine needed for dual constructors.

Definition at line 76 of file BlockRestrictable.C.

Referenced by BlockRestrictable::BlockRestrictable().

77 {
78  // If the mesh pointer is not defined, but FEProblemBase is, get it from there
79  if (_blk_feproblem != NULL && _blk_mesh == NULL)
81 
82  // Check that the mesh pointer was defined, it is required for this class to operate
83  if (_blk_mesh == NULL)
84  mooseError("The input parameters must contain a pointer to FEProblem via '_fe_problem' or a "
85  "pointer to the MooseMesh via '_mesh'");
86 
87  // Populate the MaterialData pointer
88  if (_blk_feproblem != NULL)
89  {
90 #ifdef MOOSE_KOKKOS_ENABLED
93  else
94 #endif
96  }
97 
98  // The 'block' input is defined
99  if (moose_object->isParamValid("block"))
100  {
101  // Extract the blocks from the input
102  _blocks = moose_object->getParam<std::vector<SubdomainName>>("block");
103 
104  // Store the IDs in a set, handling ANY_BLOCK_ID if supplied
105  if (std::find(_blocks.begin(), _blocks.end(), "ANY_BLOCK_ID") != _blocks.end())
107  else
108  {
109  // Get the IDs from the supplied names
111  _blk_ids.insert(_vec_ids.begin(), _vec_ids.end());
112  }
113  }
114 
115  // When 'blocks' is not set and there is a "variable", use the blocks from the variable
116  else if (moose_object->isParamValid("variable"))
117  {
118  std::string variable_name = moose_object->parameters().getMooseType("variable");
119  if (!variable_name.empty())
121  ->getVariable(_blk_tid,
122  variable_name,
125  .activeSubdomains();
126  }
127 
128  // Produce error if the object is not allowed to be both block and boundary restricted
129  if (!_blk_dual_restrictable && !_boundary_ids.empty() && !_boundary_ids.empty())
130  if (!_boundary_ids.empty() && _boundary_ids.find(Moose::ANY_BOUNDARY_ID) == _boundary_ids.end())
131  moose_object->paramError("block",
132  "Attempted to restrict the object '",
133  _blk_name,
134  "' to a block, but the object is already restricted by boundary");
135 
136  // If no blocks were defined above, specify that it is valid on all blocks
137  if (_blk_ids.empty() && !moose_object->isParamValid("boundary"))
138  {
140  _blocks = {"ANY_BLOCK_ID"};
141  }
142 
143  // If this object is block restricted, check that defined blocks exist on the mesh
144  if (_blk_ids.find(Moose::ANY_BLOCK_ID) == _blk_ids.end())
145  {
146  const std::set<SubdomainID> & valid_ids = _blk_mesh->meshSubdomains();
147  std::vector<SubdomainID> diff;
148 
149  std::set_difference(_blk_ids.begin(),
150  _blk_ids.end(),
151  valid_ids.begin(),
152  valid_ids.end(),
153  std::back_inserter(diff));
154 
155  if (!diff.empty())
156  {
157  std::ostringstream msg;
158  auto sep = " ";
159  msg << "the following blocks (ids) do not exist on the mesh:";
160  for (const auto & id : diff)
161  {
162  if (_blk_name.size() > 0)
163  {
164  auto & name =
165  _blocks.at(std::find(_vec_ids.begin(), _vec_ids.end(), id) - _vec_ids.begin());
166  if (std::to_string(id) != name)
167  msg << sep << name << " (" << id << ")";
168  else
169  msg << sep << id;
170  }
171  else
172  msg << sep << id;
173  sep = ", ";
174  }
175  std::vector<SubdomainID> valid_ids_vec(valid_ids.begin(), valid_ids.end());
176  auto valid_names = _blk_mesh->getSubdomainNames(valid_ids_vec);
177  msg << "\nBlocks names (resp. ids) that do exist: " << Moose::stringify(valid_names) << " ("
178  << Moose::stringify(valid_ids) << ")";
179  moose_object->paramError("block", msg.str());
180  }
181  }
182 
183  // Get the mesh dimension for the blocks
184  if (blockRestricted())
186  else
188 
189 #ifdef MOOSE_KOKKOS_ENABLED
190  if (moose_object->isKokkosObject())
193 #endif
194 }
std::string name(const ElemQuality q)
std::string getMooseType(const std::string &name) const
Utility functions for retrieving one of the MooseTypes variables into the common "string" base class...
unsigned int _blk_dim
Largest mesh dimension of the elements in the blocks for this object.
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
Find a value in an array.
Definition: KokkosUtils.h:40
const bool _blk_dual_restrictable
Flag for allowing dual restriction.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition: MooseBase.h:467
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseBase.h:416
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool isKokkosObject() const
Get whether this object is a Kokkos functor The parameter MooseBase::kokkos_object_param is set by th...
Definition: MooseObject.h:63
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131
FEProblemBase * _blk_feproblem
Pointer to FEProblemBase.
const MooseObject * _moose_object
Pointer to the MOOSE object.
virtual bool blockRestricted() const
Returns true if this object has been restricted to a block.
std::vector< SubdomainID > getSubdomainIDs(const std::vector< SubdomainName > &subdomain_names) const
Get the associated subdomainIDs for the subdomain names that are passed in.
Definition: MooseMesh.C:1759
std::vector< SubdomainID > _vec_ids
Vector of block ids supplied by the user via the input file (for error reporting) ...
void addKokkosMeshInitializationHook(std::function< void()> function)
Add a function hook that needs to be called after Kokkos mesh initialization.
virtual unsigned int dimension() const
Returns MeshBase::mesh_dimension(), (not MeshBase::spatial_dimension()!) of the underlying libMesh me...
Definition: MooseMesh.C:3012
THREAD_ID _blk_tid
Thread id for this object.
std::vector< SubdomainName > _blocks
Vector the block names supplied by the user via the input file.
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:64
std::vector< SubdomainName > getSubdomainNames(const std::vector< SubdomainID > &subdomain_ids) const
Get the associated subdomainNames for the subdomain ids that are passed in.
Definition: MooseMesh.C:1791
MaterialData & getMaterialData(Moose::MaterialDataType type, const THREAD_ID tid=0, const MooseObject *object=nullptr) const
MaterialData & getKokkosMaterialData(Moose::MaterialDataType type, const MooseObject *object=nullptr) const
const MooseMesh * _blk_mesh
Pointer to Mesh.
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.C:19
unsigned int getBlocksMaxDimension(const std::vector< SubdomainName > &blocks) const
Returns the maximum element dimension on the given blocks.
Definition: MooseMesh.C:3033
const MaterialData * _blk_material_data
Pointer to the MaterialData class for this object.
virtual MooseMesh & mesh() override
const std::set< BoundaryID > & _boundary_ids
Reference to the boundary_ids, defaults to an empty set if not provided.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:209
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error checking)
void initializeKokkosBlockRestrictable()
const std::string & _blk_name
Name of the object.
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.C:21
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:3298

◆ initializeKokkosBlockRestrictable()

void BlockRestrictable::initializeKokkosBlockRestrictable ( )
protectedinherited

◆ isBlockSubset() [1/2]

bool BlockRestrictable::isBlockSubset ( const std::set< SubdomainID > &  ids) const
inherited

Test if the class block ids are a subset of the supplied objects.

Parameters
idsA std::set of Subdomains to check
Returns
True if all of the block ids for this class are found within the given ids (opposite of hasBlocks)
See also
hasBlocks

Definition at line 271 of file BlockRestrictable.C.

Referenced by BlockRestrictable::checkVariable(), BlockRestrictable::isBlockSubset(), NodalPatchRecoveryAux::NodalPatchRecoveryAux(), and ProjectedMaterialPropertyNodalPatchRecoveryAux::ProjectedMaterialPropertyNodalPatchRecoveryAux().

272 {
273  // An empty input is assumed to be ANY_BLOCK_ID
274  if (ids.empty() || ids.find(Moose::ANY_BLOCK_ID) != ids.end())
275  return true;
276 
277  if (_blk_ids.find(Moose::ANY_BLOCK_ID) != _blk_ids.end())
278  return std::includes(ids.begin(),
279  ids.end(),
280  _blk_mesh->meshSubdomains().begin(),
281  _blk_mesh->meshSubdomains().end());
282  else
283  return std::includes(ids.begin(), ids.end(), _blk_ids.begin(), _blk_ids.end());
284 }
const MooseMesh * _blk_mesh
Pointer to Mesh.
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.C:19
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error checking)
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:3298

◆ isBlockSubset() [2/2]

bool BlockRestrictable::isBlockSubset ( const std::vector< SubdomainID > &  ids) const
inherited

Test if the class block ids are a subset of the supplied objects.

Parameters
idsA std::vector of Subdomains to check
Returns
True if all of the block ids for this class are found within the given ids (opposite of hasBlocks)
See also
hasBlocks

Definition at line 287 of file BlockRestrictable.C.

288 {
289  std::set<SubdomainID> ids_set(ids.begin(), ids.end());
290  return isBlockSubset(ids_set);
291 }
bool isBlockSubset(const std::set< SubdomainID > &ids) const
Test if the class block ids are a subset of the supplied objects.

◆ join()

template<typename Derived >
KOKKOS_FUNCTION void Moose::Kokkos::ReducerBase::join ( Real ,
const Real  
) const
inlineinherited

Definition at line 52 of file KokkosReducerBase.h.

53  {
54  ::Kokkos::abort("Default join() should never be called. Make sure you properly redefined this "
55  "method in your class without typos.");
56  }

◆ kokkosAssembly()

KOKKOS_FUNCTION const Assembly& Moose::Kokkos::AssemblyHolder::kokkosAssembly ( ) const
inlineinherited

Get the const reference of the Kokkos assembly.

Returns
The const reference of the Kokkos assembly depending on the architecture this function is being called on

Definition at line 569 of file KokkosAssembly.h.

Referenced by Moose::Kokkos::System::getVectorQpADGrad(), Moose::Kokkos::System::getVectorQpADGradFace(), Moose::Kokkos::System::getVectorQpADValue(), Moose::Kokkos::System::getVectorQpADValueFace(), Moose::Kokkos::System::getVectorQpGradFace(), Moose::Kokkos::System::getVectorQpValueFace(), operator()(), Moose::Kokkos::SideReducer::operator()(), Moose::Kokkos::NodalReducer::operator()(), Moose::Kokkos::NodalUserObject::operator()(), Moose::Kokkos::SideUserObject::operator()(), Moose::Kokkos::ElementUserObject::operator()(), Moose::Kokkos::ADNodalBC::operator()(), Moose::Kokkos::ADKernel::operator()(), Moose::Kokkos::ADIntegratedBC::operator()(), Moose::Kokkos::AuxKernel::operator()(), Moose::Kokkos::Material::operator()(), Moose::Kokkos::NodalBC::operator()(), Moose::Kokkos::NodalKernel::operator()(), Moose::Kokkos::IntegratedBC::operator()(), and Moose::Kokkos::Kernel::operator()().

570  {
571  KOKKOS_IF_ON_HOST(return _assembly_host;)
572 
573  return _assembly_device;
574  }
const Assembly _assembly_device
Device copy of the Kokkos assembly.
const Assembly & _assembly_host
Host reference of the Kokkos assembly.

◆ kokkosBlockElementID()

KOKKOS_FUNCTION ContiguousElementID BlockRestrictable::kokkosBlockElementID ( Moose::Kokkos::ThreadID  tid) const
inlineprotectedinherited

Get the contiguous element ID this Kokkos thread is operating on.

Parameters
tidThe thread ID
Returns
The contiguous element ID

Definition at line 280 of file BlockRestrictable.h.

Referenced by operator()(), Moose::Kokkos::ElementUserObject::operator()(), Moose::Kokkos::ADKernel::operator()(), Moose::Kokkos::AuxKernel::operator()(), and Moose::Kokkos::Kernel::operator()().

281  {
282  return _kokkos_element_ids[tid];
283  }
Moose::Kokkos::Array< ContiguousElementID > _kokkos_element_ids
List of contiguous element IDs this Kokkos object is operating on.

◆ kokkosBlockElementSideID()

KOKKOS_FUNCTION auto BlockRestrictable::kokkosBlockElementSideID ( Moose::Kokkos::ThreadID  tid) const
inlineprotectedinherited

Get the contiguous element ID - side index pair this Kokkos thread is operating on.

Parameters
tidThe thread ID
Returns
The contiguous element ID - side index pair

Definition at line 298 of file BlockRestrictable.h.

299  {
300  return _kokkos_element_side_ids[tid];
301  }
Moose::Kokkos::Array< Moose::Kokkos::Pair< ContiguousElementID, unsigned int > > _kokkos_element_side_ids
List of contiguous local element ID - side index pairs this Kokkos object is operating on...

◆ kokkosBlockNodeID()

KOKKOS_FUNCTION ContiguousElementID BlockRestrictable::kokkosBlockNodeID ( Moose::Kokkos::ThreadID  tid) const
inlineprotectedinherited

Get the contiguous node index this Kokkos thread is operating on.

Parameters
tidThe thread ID
Returns
the contiguous node ID

Definition at line 289 of file BlockRestrictable.h.

Referenced by Moose::Kokkos::NodalReducer::operator()(), Moose::Kokkos::NodalUserObject::operator()(), Moose::Kokkos::AuxKernel::operator()(), and Moose::Kokkos::NodalKernel::operator()().

290  {
291  return _kokkos_node_ids[tid];
292  }
Moose::Kokkos::Array< ContiguousNodeID > _kokkos_node_ids
List of contiguous node IDs this Kokkos object is operating on.

◆ kokkosMesh()

KOKKOS_FUNCTION const Mesh& Moose::Kokkos::MeshHolder::kokkosMesh ( ) const
inlineinherited

Get the const reference of the Kokkos mesh.

Returns
The const reference of the Kokkos mesh depending on the architecture this function is being called on

Definition at line 452 of file KokkosMesh.h.

Referenced by Moose::Kokkos::Assembly::computePhysicalMap(), Moose::Kokkos::Kernel::operator()(), Moose::Kokkos::IntegratedBC::operator()(), Moose::Kokkos::Datum::q_point(), and KokkosBoundNodalKernel::skipOnBoundary().

453  {
454  KOKKOS_IF_ON_HOST(
456  "kokkosMesh() was called too early. Kokkos mesh is available after problem "
457  "initialization. Override initialSetup() if you need to setup your object data "
458  "using the Kokkos mesh.");
459 
460  return _mesh_host;)
461 
462  return _mesh_device;
463  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool initialized() const
Get whether the mesh was initialized.
Definition: KokkosMesh.h:68
const Mesh _mesh_device
Device copy of the Kokkos mesh.
Definition: KokkosMesh.h:474
const Mesh & _mesh_host
Host reference of the Kokkos mesh.
Definition: KokkosMesh.h:470

◆ kokkosSystem() [1/2]

KOKKOS_FUNCTION const System& Moose::Kokkos::SystemHolder::kokkosSystem ( unsigned int  sys) const
inlineinherited

◆ kokkosSystem() [2/2]

System& Moose::Kokkos::SystemHolder::kokkosSystem ( unsigned int  sys)
inlineinherited

Get the writeable reference of a Kokkos system.

Parameters
sysThe system number
Returns
The writeable host reference of the Kokkos system

Definition at line 803 of file KokkosSystem.h.

803 { return _systems_host[sys]; }
Array< System > & _systems_host
Host reference of the Kokkos systems.
Definition: KokkosSystem.h:810

◆ kokkosSystems() [1/2]

KOKKOS_FUNCTION const Array<System>& Moose::Kokkos::SystemHolder::kokkosSystems ( ) const
inlineinherited

◆ kokkosSystems() [2/2]

Array<System>& Moose::Kokkos::SystemHolder::kokkosSystems ( )
inlineinherited

Get the writeable host reference of the Kokkos systems.

Returns
The writeable host reference of the Kokkos systems

Definition at line 785 of file KokkosSystem.h.

785 { return _systems_host; }
Array< System > & _systems_host
Host reference of the Kokkos systems.
Definition: KokkosSystem.h:810

◆ meshBlockIDs()

const std::set< SubdomainID > & BlockRestrictable::meshBlockIDs ( ) const
inherited

Return all of the SubdomainIDs for the mesh.

Returns
A set of all subdomians for the entire mesh

Definition at line 294 of file BlockRestrictable.C.

Referenced by BlockRestrictable::checkVariable(), ElementGroupCentroidPositions::ElementGroupCentroidPositions(), BlockRestrictable::getBlockCoordSystem(), BlockRestrictable::hasBlockMaterialPropertyHelper(), and SolutionIC::initialSetup().

295 {
296  return _blk_mesh->meshSubdomains();
297 }
const MooseMesh * _blk_mesh
Pointer to Mesh.
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:3298

◆ numBlocks()

unsigned int BlockRestrictable::numBlocks ( ) const
inherited

Return the number of blocks for this object.

Returns
The number of subdomains

Definition at line 218 of file BlockRestrictable.C.

Referenced by ElementCentroidPositions::initialize(), and QuadraturePointsPositions::initialize().

219 {
220  return (unsigned int)_blk_ids.size();
221 }
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error checking)

◆ numKokkosBlockElements()

KOKKOS_FUNCTION dof_id_type BlockRestrictable::numKokkosBlockElements ( ) const
inlineprotectedinherited

Get the number of elements this Kokkos object is operating on.

Returns
The number of elements local to this process

Definition at line 261 of file BlockRestrictable.h.

Referenced by numReducerThreads(), and Moose::Kokkos::ElementUserObject::numUserObjectThreads().

261 { return _kokkos_element_ids.size(); }
KOKKOS_FUNCTION index_type size() const
Get the total array size.
Definition: KokkosArray.h:205
Moose::Kokkos::Array< ContiguousElementID > _kokkos_element_ids
List of contiguous element IDs this Kokkos object is operating on.

◆ numKokkosBlockNodes()

KOKKOS_FUNCTION dof_id_type BlockRestrictable::numKokkosBlockNodes ( ) const
inlineprotectedinherited

Get the number of nodes this Kokkos object is operating on.

Returns
The number of nodes local to this process

Definition at line 266 of file BlockRestrictable.h.

Referenced by Moose::Kokkos::NodalReducer::numReducerThreads(), and Moose::Kokkos::NodalUserObject::numUserObjectThreads().

266 { return _kokkos_node_ids.size(); }
KOKKOS_FUNCTION index_type size() const
Get the total array size.
Definition: KokkosArray.h:205
Moose::Kokkos::Array< ContiguousNodeID > _kokkos_node_ids
List of contiguous node IDs this Kokkos object is operating on.

◆ numKokkosBlockSides()

KOKKOS_FUNCTION dof_id_type BlockRestrictable::numKokkosBlockSides ( ) const
inlineprotectedinherited

Get the number of sides this Kokkos object is operating on.

Returns
The number of sides local to this process

Definition at line 271 of file BlockRestrictable.h.

272  {
274  }
KOKKOS_FUNCTION index_type size() const
Get the total array size.
Definition: KokkosArray.h:205
Moose::Kokkos::Array< Moose::Kokkos::Pair< ContiguousElementID, unsigned int > > _kokkos_element_side_ids
List of contiguous local element ID - side index pairs this Kokkos object is operating on...

◆ numReducerThreads()

virtual ThreadID Moose::Kokkos::ElementReducer::numReducerThreads ( ) const
inlineoverridevirtual

Get the number of threads.

Implements Moose::Kokkos::ReducerBase.

Definition at line 31 of file KokkosElementReducer.h.

31 { return numKokkosBlockElements(); }
KOKKOS_FUNCTION dof_id_type numKokkosBlockElements() const
Get the number of elements this Kokkos object is operating on.

◆ operator()()

template<typename Derived >
KOKKOS_FUNCTION void Moose::Kokkos::ElementReducer::operator() ( ReducerLoop  ,
const ThreadID  tid,
const Derived &  reducer,
Real result 
) const

The parallel computation entry function called by Kokkos.

Definition at line 43 of file KokkosElementReducer.h.

47 {
48  auto elem = kokkosBlockElementID(tid);
49 
51 
52  reducer.template reduce<Derived>(datum, result);
53 }
The Kokkos object that holds thread-private data in the parallel operations of any Kokkos object...
Definition: KokkosDatum.h:23
const unsigned int invalid_uint
KOKKOS_FUNCTION const Assembly & kokkosAssembly() const
Get the const reference of the Kokkos assembly.
KOKKOS_FUNCTION ContiguousElementID kokkosBlockElementID(Moose::Kokkos::ThreadID tid) const
Get the contiguous element ID this Kokkos thread is operating on.
KOKKOS_FUNCTION const Array< System > & kokkosSystems() const
Get the const reference of the Kokkos systems.
Definition: KokkosSystem.h:775

◆ reduce()

template<typename Derived >
KOKKOS_FUNCTION void Moose::Kokkos::ReducerBase::reduce ( Datum ,
Real  
) const
inlineinherited

Default methods to prevent compile errors even when these methods were not defined in the derived class.

Definition at line 46 of file KokkosReducerBase.h.

47  {
48  ::Kokkos::abort("Default reduce() should never be called. Make sure you properly redefined "
49  "this method in your class without typos.");
50  }

◆ validParams()

static InputParameters Moose::Kokkos::ElementReducer::validParams ( )
static

Member Data Documentation

◆ _blk_material_data

const MaterialData* BlockRestrictable::_blk_material_data
protectedinherited

Pointer to the MaterialData class for this object.

Definition at line 232 of file BlockRestrictable.h.

Referenced by BlockRestrictable::hasBlockMaterialProperty(), and BlockRestrictable::initializeBlockRestrictable().

◆ _reducer_dispatcher

std::unique_ptr<DispatcherBase> Moose::Kokkos::ReducerBase::_reducer_dispatcher
protectedinherited

Kokkos functor dispatcher.

Definition at line 100 of file KokkosReducerBase.h.

◆ _reducer_object

const MooseObject* Moose::Kokkos::ReducerBase::_reducer_object
protectedinherited

MOOSE object.

Definition at line 96 of file KokkosReducerBase.h.

◆ _reduction_buffer

::Kokkos::View<Real *, ::Kokkos::HostSpace> Moose::Kokkos::ReducerBase::_reduction_buffer
protectedinherited

Reduction buffer.

Definition at line 104 of file KokkosReducerBase.h.

Referenced by Moose::Kokkos::ReducerBase::allocateReductionBuffer().


The documentation for this class was generated from the following file: