https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
BoundaryRestrictableRequired Class Reference

A class for requiring an object to be boundary restricted. More...

#include <BoundaryRestrictableRequired.h>

Inheritance diagram for BoundaryRestrictableRequired:
[legend]

Public Types

enum  TEST_TYPE { ALL, ANY }
 A flag changing the behavior of hasBoundary. More...
 

Public Member Functions

 BoundaryRestrictableRequired (const MooseObject *moose_object, bool nodal)
 
 BoundaryRestrictableRequired (const BoundaryRestrictableRequired &object, const Moose::Kokkos::FunctorCopy &key)
 Special constructor used for Kokkos functor copy during parallel dispatch. More...
 
virtual const std::set< BoundaryID > & boundaryIDs () const
 Return the boundary IDs for this object. More...
 
const std::vector< BoundaryName > & boundaryNames () const
 Return the boundary names for this object. More...
 
unsigned int numBoundaryIDs () const
 Return the number of boundaries for this object. More...
 
bool hasBoundary (const BoundaryName &name) const
 Test if the supplied boundary name is valid for this object. More...
 
bool hasBoundary (const std::vector< BoundaryName > &names) const
 Test if the supplied vector of boundary names are valid for this object. More...
 
bool hasBoundary (const BoundaryID &id) const
 Test if the supplied boundary ids are valid for this object. More...
 
bool hasBoundary (const std::vector< BoundaryID > &ids, TEST_TYPE type=ALL) const
 Test if the supplied vector boundary ids are valid for this object. More...
 
bool hasBoundary (const std::set< BoundaryID > &ids, TEST_TYPE type=ALL) const
 Test if the supplied set of boundary ids are valid for this object. More...
 
bool isBoundarySubset (const std::set< BoundaryID > &ids) const
 Test if the class boundary ids are a subset of the supplied objects. More...
 
bool isBoundarySubset (const std::vector< BoundaryID > &ids) const
 
template<typename T , bool is_ad = false>
bool hasBoundaryMaterialProperty (const std::string &prop_name) const
 Check if a material property is valid for all boundaries of this object. More...
 
virtual bool boundaryRestricted () const
 Returns true if this object has been restricted to a boundary. More...
 
const std::set< BoundaryID > & meshBoundaryIDs () const
 Returns the set of all boundary ids for the entire mesh. More...
 
virtual bool checkVariableBoundaryIntegrity () const
 Whether integrity/coverage checking should be conducted for moose variables used in this object. More...
 

Static Public Member Functions

static InputParameters validParams ()
 
static bool restricted (const std::set< BoundaryID > &ids)
 Helper for determining if the object is boundary restricted. More...
 

Protected Member Functions

bool hasBoundaryMaterialPropertyHelper (const std::string &prop_name) const
 A helper method to avoid circular #include problems. More...
 
KOKKOS_FUNCTION dof_id_type numKokkosBoundaryNodes () const
 Get the number of nodes this Kokkos object is operating on. More...
 
KOKKOS_FUNCTION dof_id_type numKokkosBoundarySides () const
 Get the number of sides this Kokkos object is operating on. More...
 
KOKKOS_FUNCTION ContiguousNodeID kokkosBoundaryNodeID (ThreadID tid) const
 Get the contiguous node ID this Kokkos thread is operating on. More...
 
KOKKOS_FUNCTION auto kokkosBoundaryElementSideID (ThreadID tid) const
 Get the contiguous element ID - side index pair this Kokkos thread is operating on. More...
 

Detailed Description

A class for requiring an object to be boundary restricted.

This class acts as a wrapper for BoundaryRestrictable, it allows an additional validParams that adds the 'boundary' parameter as required.

Definition at line 21 of file BoundaryRestrictableRequired.h.

Member Enumeration Documentation

◆ TEST_TYPE

A flag changing the behavior of hasBoundary.

Enumerator
ALL 
ANY 

Definition at line 33 of file BoundaryRestrictable.h.

Constructor & Destructor Documentation

◆ BoundaryRestrictableRequired() [1/2]

BoundaryRestrictableRequired::BoundaryRestrictableRequired ( const MooseObject moose_object,
bool  nodal 
)

Definition at line 31 of file BoundaryRestrictableRequired.C.

33  : BoundaryRestrictable(moose_object, nodal)
34 {
35 }
BoundaryRestrictable(const MooseObject *moose_object, bool nodal)
Class constructor Populates the _bnd_ids for the given boundary names supplied with the &#39;boundary&#39; in...

◆ BoundaryRestrictableRequired() [2/2]

BoundaryRestrictableRequired::BoundaryRestrictableRequired ( const BoundaryRestrictableRequired object,
const Moose::Kokkos::FunctorCopy key 
)

Special constructor used for Kokkos functor copy during parallel dispatch.

Definition at line 38 of file BoundaryRestrictableRequired.C.

40  : BoundaryRestrictable(object, key)
41 {
42 }
BoundaryRestrictable(const MooseObject *moose_object, bool nodal)
Class constructor Populates the _bnd_ids for the given boundary names supplied with the &#39;boundary&#39; in...

Member Function Documentation

◆ boundaryIDs()

const std::set< BoundaryID > & BoundaryRestrictable::boundaryIDs ( ) const
virtualinherited

Return the boundary IDs for this object.

Returns
A set of all boundary ids for which the object is restricted

Definition at line 197 of file BoundaryRestrictable.C.

Referenced by MaterialBase::getGenericZeroMaterialPropertyByName(), BoundaryRestrictable::hasBoundaryMaterialPropertyHelper(), SidesetInfoVectorPostprocessor::initialize(), SideFVFluxBCIntegral::initialSetup(), InterfaceQpUserObjectBase::initialSetup(), and MaterialBase::registerPropName().

198 {
199  return _bnd_ids;
200 }
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.

◆ boundaryNames()

const std::vector< BoundaryName > & BoundaryRestrictable::boundaryNames ( ) const
inherited

Return the boundary names for this object.

Returns
A set of all boundary names for which the object is restricted

Definition at line 203 of file BoundaryRestrictable.C.

Referenced by MaterialOutputAction::getParams(), NearestNodeDistanceAux::NearestNodeDistanceAux(), and NearestNodeValueAux::NearestNodeValueAux().

204 {
205  return _boundary_names;
206 }
std::vector< BoundaryName > _boundary_names
Vector the the boundary names.

◆ boundaryRestricted()

bool BoundaryRestrictable::boundaryRestricted ( ) const
virtualinherited

Returns true if this object has been restricted to a boundary.

See also
MooseObject

Definition at line 215 of file BoundaryRestrictable.C.

Referenced by Moose::Kokkos::Material< KokkosGenericConstantMaterial >::checkMaterialProperty(), Material::checkMaterialProperty(), MaterialOutputAction::getParams(), DerivativeMaterialInterface< MortarScalarBase >::haveMaterialProperty(), and NodePositions::initialize().

216 {
218 }
static bool restricted(const std::set< BoundaryID > &ids)
Helper for determining if the object is boundary restricted.
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.

◆ checkVariableBoundaryIntegrity()

virtual bool BoundaryRestrictable::checkVariableBoundaryIntegrity ( ) const
inlinevirtualinherited

Whether integrity/coverage checking should be conducted for moose variables used in this object.

This should return true if variables are only evaluated locally, e.g. on the current node or element. This should return false if evaluation of this object entails non-local variable evaluations

Definition at line 190 of file BoundaryRestrictable.h.

190 { return true; }

◆ hasBoundary() [1/5]

bool BoundaryRestrictable::hasBoundary ( const BoundaryName &  name) const
inherited

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

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

Definition at line 227 of file BoundaryRestrictable.C.

Referenced by AuxKernelTempl< Real >::AuxKernelTempl(), BoundaryRestrictable::hasBoundary(), BoundaryRestrictable::hasBoundaryMaterialPropertyHelper(), and NodePositions::initialize().

228 {
229  // Create a vector and utilize the getBoundaryIDs function, which
230  // handles the ANY_BOUNDARY_ID (getBoundaryID does not)
231  return hasBoundary(_bnd_mesh->getBoundaryIDs({name}));
232 }
MooseMesh * _bnd_mesh
Point to mesh.
bool hasBoundary(const BoundaryName &name) const
Test if the supplied boundary name is valid for this object.
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Returns a vector of boundary IDs for the requested element on the requested side. ...

◆ hasBoundary() [2/5]

bool BoundaryRestrictable::hasBoundary ( const std::vector< BoundaryName > &  names) const
inherited

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

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

Definition at line 235 of file BoundaryRestrictable.C.

236 {
237  return hasBoundary(_bnd_mesh->getBoundaryIDs(names));
238 }
MooseMesh * _bnd_mesh
Point to mesh.
bool hasBoundary(const BoundaryName &name) const
Test if the supplied boundary name is valid for this object.
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Returns a vector of boundary IDs for the requested element on the requested side. ...

◆ hasBoundary() [3/5]

bool BoundaryRestrictable::hasBoundary ( const BoundaryID id) const
inherited

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

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

Definition at line 241 of file BoundaryRestrictable.C.

242 {
243  if (_bnd_ids.empty() || _bnd_ids.find(Moose::ANY_BOUNDARY_ID) != _bnd_ids.end())
244  return true;
245  else
246  return _bnd_ids.find(id) != _bnd_ids.end();
247 }
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.C:21

◆ hasBoundary() [4/5]

bool BoundaryRestrictable::hasBoundary ( const std::vector< BoundaryID > &  ids,
TEST_TYPE  type = ALL 
) const
inherited

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

Parameters
idsA vector of BoundaryIDs ids to check
typeA flag for the type of matching to perform: ALL requires that all supplied ids must match those of the object; ANY requires that any one of the supplied ids must match those of the object
Returns
True if the all of the given ids are found within the ids for this object

Definition at line 250 of file BoundaryRestrictable.C.

251 {
252  std::set<BoundaryID> ids_set(ids.begin(), ids.end());
253  return hasBoundary(ids_set, type);
254 }
bool hasBoundary(const BoundaryName &name) const
Test if the supplied boundary name is valid for this object.

◆ hasBoundary() [5/5]

bool BoundaryRestrictable::hasBoundary ( const std::set< BoundaryID > &  ids,
TEST_TYPE  type = ALL 
) const
inherited

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

Parameters
idsA std::set of BoundaryIDs to check
typeA flag for the type of matching to perform: ALL requires that all supplied ids must match those of the object; ANY requires that any one of the supplied ids must match those of the object
Returns
True if the all of the given ids are found within the ids for this object
See also
isSubset

Definition at line 257 of file BoundaryRestrictable.C.

258 {
259  // An empty input is assumed to be ANY_BOUNDARY_ID
260  if (ids.empty() || ids.find(Moose::ANY_BOUNDARY_ID) != ids.end())
261  return true;
262 
263  // All supplied IDs must match those of the object
264  else if (type == ALL)
265  {
266  if (_bnd_ids.find(Moose::ANY_BOUNDARY_ID) != _bnd_ids.end())
267  return true;
268  else
269  return std::includes(_bnd_ids.begin(), _bnd_ids.end(), ids.begin(), ids.end());
270  }
271  // Any of the supplied IDs must match those of the object
272  else
273  {
274  // Loop through the supplied ids
275  for (const auto & id : ids)
276  {
277  // Test the current supplied id
278  bool test = hasBoundary(id);
279 
280  // If the id exists in the stored ids, then return true, otherwise
281  if (test)
282  return true;
283  }
284  return false;
285  }
286 }
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.
bool hasBoundary(const BoundaryName &name) const
Test if the supplied boundary name is valid for this object.
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.C:21

◆ hasBoundaryMaterialProperty()

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

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

This method returns true if the supplied property name has been declared in a Material object on the boundary 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 boundary ids of the object, otherwise false

Definition at line 295 of file BoundaryRestrictable.h.

296 {
297  // If you get here the supplied property is defined on all boundaries, but is still subject
298  // existence in the MateialData class
299  return hasBoundaryMaterialPropertyHelper(prop_name) &&
300  _bnd_material_data.haveGenericProperty<T, is_ad>(prop_name);
301 }
bool haveGenericProperty(const std::string &prop_name) const
Definition: MaterialData.h:362
bool hasBoundaryMaterialPropertyHelper(const std::string &prop_name) const
A helper method to avoid circular #include problems.
const MaterialData & _bnd_material_data
Pointer to MaterialData for boundary (.

◆ hasBoundaryMaterialPropertyHelper()

bool BoundaryRestrictable::hasBoundaryMaterialPropertyHelper ( const std::string &  prop_name) const
protectedinherited

A helper method to avoid circular #include problems.

See also
hasBoundaryMaterialProperty

Definition at line 318 of file BoundaryRestrictable.C.

Referenced by BoundaryRestrictable::hasBoundaryMaterialProperty().

319 {
320  // Reference to MaterialWarehouse for testing and retrieving boundary ids
322 
323  // Complete set of BoundaryIDs that this object is defined
324  const std::set<BoundaryID> & ids =
326 
327  // Loop over each BoundaryID for this object
328  for (const auto & id : ids)
329  {
330  // Storage of material properties that have been DECLARED on this BoundaryID
331  std::set<std::string> declared_props;
332 
333  // If boundary materials exist, populated the set of properties that were declared
334  if (warehouse.hasActiveBoundaryObjects(id))
335  {
336  const std::vector<std::shared_ptr<MaterialBase>> & mats =
337  warehouse.getActiveBoundaryObjects(id);
338  for (const auto & mat : mats)
339  {
340  const std::set<std::string> & mat_props = mat->getSuppliedItems();
341  declared_props.insert(mat_props.begin(), mat_props.end());
342  }
343  }
344 
345  // If the supplied property is not in the list of properties on the current id, return false
346  if (declared_props.find(prop_name) == declared_props.end())
347  return false;
348  }
349 
350  // If you get here the supplied property is defined on all boundaries
351  return true;
352 }
MaterialBase objects are special in that they have additional objects created automatically (see FEPr...
const MaterialWarehouse & getMaterialWarehouse() const
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
const std::set< BoundaryID > & meshBoundaryIDs() const
Returns the set of all boundary ids for the entire mesh.
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
bool hasBoundary(const BoundaryName &name) const
Test if the supplied boundary name is valid for this object.
FEProblemBase * _bnd_feproblem
Pointer to FEProblemBase.
virtual const std::set< BoundaryID > & boundaryIDs() const
Return the boundary IDs for this object.
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.C:21

◆ isBoundarySubset() [1/2]

bool BoundaryRestrictable::isBoundarySubset ( const std::set< BoundaryID > &  ids) const
inherited

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

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

Definition at line 289 of file BoundaryRestrictable.C.

Referenced by BoundaryRestrictable::isBoundarySubset().

290 {
291  // An empty input is assumed to be ANY_BOUNDARY_ID
292  if (ids.empty() || ids.find(Moose::ANY_BOUNDARY_ID) != ids.end())
293  return true;
294 
295  if (_bnd_ids.find(Moose::ANY_BOUNDARY_ID) != _bnd_ids.end())
296  return std::includes(ids.begin(),
297  ids.end(),
298  _bnd_mesh->meshBoundaryIds().begin(),
299  _bnd_mesh->meshBoundaryIds().end());
300  else
301  return std::includes(ids.begin(), ids.end(), _bnd_ids.begin(), _bnd_ids.end());
302 }
MooseMesh * _bnd_mesh
Point to mesh.
const std::set< BoundaryID > & meshBoundaryIds() const
Returns a read-only reference to the set of boundary IDs currently present in the Mesh...
Definition: MooseMesh.C:3217
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.C:21

◆ isBoundarySubset() [2/2]

bool BoundaryRestrictable::isBoundarySubset ( const std::vector< BoundaryID > &  ids) const
inherited

Definition at line 305 of file BoundaryRestrictable.C.

306 {
307  std::set<BoundaryID> ids_set(ids.begin(), ids.end());
308  return isBoundarySubset(ids_set);
309 }
bool isBoundarySubset(const std::set< BoundaryID > &ids) const
Test if the class boundary ids are a subset of the supplied objects.

◆ kokkosBoundaryElementSideID()

KOKKOS_FUNCTION auto BoundaryRestrictable::kokkosBoundaryElementSideID ( 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 273 of file BoundaryRestrictable.h.

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

◆ kokkosBoundaryNodeID()

KOKKOS_FUNCTION ContiguousNodeID BoundaryRestrictable::kokkosBoundaryNodeID ( ThreadID  tid) const
inlineprotectedinherited

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

Parameters
tidThe thread ID
Returns
The contiguous node ID

Definition at line 264 of file BoundaryRestrictable.h.

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

◆ meshBoundaryIDs()

const std::set< BoundaryID > & BoundaryRestrictable::meshBoundaryIDs ( ) const
inherited

Returns the set of all boundary ids for the entire mesh.

Returns
A const reference the the boundary ids for the entire mesh

Definition at line 312 of file BoundaryRestrictable.C.

Referenced by BoundaryRestrictable::hasBoundaryMaterialPropertyHelper().

313 {
314  return _bnd_mesh->getBoundaryIDs();
315 }
MooseMesh * _bnd_mesh
Point to mesh.
std::vector< BoundaryID > getBoundaryIDs(const Elem *const elem, const unsigned short int side) const
Returns a vector of boundary IDs for the requested element on the requested side. ...

◆ numBoundaryIDs()

unsigned int BoundaryRestrictable::numBoundaryIDs ( ) const
inherited

Return the number of boundaries for this object.

Returns
The number of boundary ids

Definition at line 209 of file BoundaryRestrictable.C.

Referenced by SidesetInfoVectorPostprocessor::initialize().

210 {
211  return (unsigned int)_bnd_ids.size();
212 }
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.

◆ numKokkosBoundaryNodes()

KOKKOS_FUNCTION dof_id_type BoundaryRestrictable::numKokkosBoundaryNodes ( ) 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 250 of file BoundaryRestrictable.h.

250 { return _kokkos_node_ids.size(); }
Moose::Kokkos::Array< ContiguousNodeID > _kokkos_node_ids
List of contiguous node IDs this Kokkos object is operating on.

◆ numKokkosBoundarySides()

KOKKOS_FUNCTION dof_id_type BoundaryRestrictable::numKokkosBoundarySides ( ) 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 255 of file BoundaryRestrictable.h.

256  {
257  return _kokkos_element_side_ids.size();
258  }
Moose::Kokkos::Array< Moose::Kokkos::Pair< ContiguousElementID, unsigned int > > _kokkos_element_side_ids
List of contiguous element ID - side index pairs this Kokkos object is operating on.

◆ restricted()

bool BoundaryRestrictable::restricted ( const std::set< BoundaryID > &  ids)
staticinherited

Helper for determining if the object is boundary restricted.

This is needed for the MaterialPropertyInterface.

Definition at line 221 of file BoundaryRestrictable.C.

Referenced by moose::internal::boundaryRestricted(), and BoundaryRestrictable::boundaryRestricted().

222 {
223  return ids.find(Moose::ANY_BOUNDARY_ID) == ids.end();
224 }
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.C:21

◆ validParams()

InputParameters BoundaryRestrictableRequired::validParams ( )
static

Definition at line 14 of file BoundaryRestrictableRequired.C.

Referenced by InterfaceUserObjectBase::validParams(), SideUserObject::validParams(), BoundaryCondition::validParams(), LinearFVBoundaryCondition::validParams(), FVInterfaceKernel::validParams(), and FVBoundaryCondition::validParams().

15 {
16  // Create instance of InputParameters
18 
19  // Create user-facing 'boundary' input for restricting inheriting object to boundaries
20  params.addRequiredParam<std::vector<BoundaryName>>(
21  "boundary", "The list of boundary IDs from the mesh where this object applies");
22 
23  // A parameter for disabling error message for objects restrictable by boundary and block,
24  // if the parameter is valid it was already set so don't do anything
25  if (!params.isParamValid("_dual_restrictable"))
26  params.addPrivateParam<bool>("_dual_restrictable", false);
27 
28  return params;
29 }
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
InputParameters emptyInputParameters()
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.

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