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

/class BoundaryRestrictable /brief Provides functionality for limiting the object to certain boundary ids The is class the inheriting class with methods useful for limiting an object to certain boundaries. More...

#include <BoundaryRestrictable.h>

Inheritance diagram for BoundaryRestrictable:
[legend]

Public Types

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

Public Member Functions

 BoundaryRestrictable (const MooseObject *moose_object, bool nodal)
 Class constructor Populates the _bnd_ids for the given boundary names supplied with the 'boundary' input parameter. More...
 
 BoundaryRestrictable (const MooseObject *moose_object, const std::set< SubdomainID > &block_ids, bool nodal)
 Class constructor Populates the 'block' input parameters when an object is also block restricted, see the general class documentation for details. More...
 
 BoundaryRestrictable (const BoundaryRestrictable &object, const Moose::Kokkos::FunctorCopy &key)
 Special constructor used for Kokkos functor copy during parallel dispatch. More...
 
virtual ~BoundaryRestrictable ()
 Empty class destructor. 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...
 

Private Member Functions

void initializeBoundaryRestrictable ()
 An initialization routine needed for dual constructors. More...
 
void initializeKokkosBoundaryRestrictable (MooseMesh *mesh)
 

Private Attributes

FEProblemBase_bnd_feproblem
 Pointer to FEProblemBase. More...
 
MooseMesh_bnd_mesh
 Point to mesh. More...
 
std::set< BoundaryID_bnd_ids
 Set of the boundary ids. More...
 
std::vector< BoundaryID_vec_ids
 Vector of the boundary ids. More...
 
std::vector< BoundaryName > _boundary_names
 Vector the the boundary names. More...
 
const bool _bnd_dual_restrictable
 Flag for allowing dual restriction with BlockRestrictable. More...
 
const std::set< SubdomainID_empty_block_ids
 An empty set for referencing when block_ids is not included. More...
 
const std::set< SubdomainID > & _block_ids
 Reference to the block_ids, defaults to an empty set if not provided. More...
 
THREAD_ID _bnd_tid
 Thread id for this object. More...
 
const MaterialData_bnd_material_data
 Pointer to MaterialData for boundary (. More...
 
bool _bnd_nodal
 Whether or not this object is restricted to nodesets. More...
 
const MooseObject_moose_object
 The moose object that this is an interface for. More...
 
Moose::Kokkos::Array< ContiguousNodeID_kokkos_node_ids
 List of contiguous node IDs this Kokkos object is operating on. More...
 
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. More...
 

Detailed Description

/class BoundaryRestrictable /brief Provides functionality for limiting the object to certain boundary ids The is class the inheriting class with methods useful for limiting an object to certain boundaries.

The parameters "_boundary_id" and "boundary", which are created with BoundaryRestrictable::validParams() are used the framework.

Definition at line 29 of file BoundaryRestrictable.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

◆ BoundaryRestrictable() [1/3]

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

Class constructor Populates the _bnd_ids for the given boundary names supplied with the 'boundary' input parameter.

Parameters
parametersThe input parameters
nodalTrue indicates that the object is operating on nodesets, false for sidesets

Definition at line 36 of file BoundaryRestrictable.C.

37  : _bnd_feproblem(moose_object->isParamValid("_fe_problem_base")
38  ? moose_object->getParam<FEProblemBase *>("_fe_problem_base")
39  : NULL),
40  _bnd_mesh(moose_object->isParamValid("_mesh") ? moose_object->getParam<MooseMesh *>("_mesh")
41  : NULL),
42  _bnd_dual_restrictable(moose_object->getParam<bool>("_dual_restrictable")),
44  _bnd_tid(moose_object->isParamValid("_tid") ? moose_object->getParam<THREAD_ID>("_tid") : 0),
46 #ifdef MOOSE_KOKKOS_ENABLED
47  moose_object->isKokkosObject({})
49  :
50 #endif
52  _bnd_nodal(nodal),
53  _moose_object(*moose_object)
54 {
56 }
void initializeBoundaryRestrictable()
An initialization routine needed for dual constructors.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseBase.h:388
MooseMesh * _bnd_mesh
Point to mesh.
const bool _bnd_dual_restrictable
Flag for allowing dual restriction with BlockRestrictable.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
THREAD_ID _bnd_tid
Thread id for this object.
const std::set< SubdomainID > _empty_block_ids
An empty set for referencing when block_ids is not included.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:92
bool _bnd_nodal
Whether or not this object is restricted to nodesets.
bool isKokkosObject(IsKokkosObjectKey &&) const
Get whether this object is a Kokkos functor The parameter is set by the Kokkos base classes: ...
Definition: MooseObject.h:72
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 MooseObject & _moose_object
The moose object that this is an interface for.
const MaterialData & _bnd_material_data
Pointer to MaterialData for boundary (.
const std::set< SubdomainID > & _block_ids
Reference to the block_ids, defaults to an empty set if not provided.
FEProblemBase * _bnd_feproblem
Pointer to FEProblemBase.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:199
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ BoundaryRestrictable() [2/3]

BoundaryRestrictable::BoundaryRestrictable ( const MooseObject moose_object,
const std::set< SubdomainID > &  block_ids,
bool  nodal 
)

Class constructor Populates the 'block' input parameters when an object is also block restricted, see the general class documentation for details.

Parameters
parametersThe input parameters (see the detailed help for additional information)
block_idsThe block ids that the object is restricted to
nodalTrue indicates that the object is operating on nodesets, false for sidesets

Definition at line 59 of file BoundaryRestrictable.C.

62  : _bnd_feproblem(moose_object->isParamValid("_fe_problem_base")
63  ? moose_object->getParam<FEProblemBase *>("_fe_problem_base")
64  : NULL),
65  _bnd_mesh(moose_object->isParamValid("_mesh") ? moose_object->getParam<MooseMesh *>("_mesh")
66  : NULL),
67  _bnd_dual_restrictable(moose_object->getParam<bool>("_dual_restrictable")),
68  _block_ids(block_ids),
69  _bnd_tid(moose_object->isParamValid("_tid") ? moose_object->getParam<THREAD_ID>("_tid") : 0),
71 #ifdef MOOSE_KOKKOS_ENABLED
72  moose_object->isKokkosObject({})
74  :
75 #endif
77  _bnd_nodal(nodal),
78  _moose_object(*moose_object)
79 {
81 }
void initializeBoundaryRestrictable()
An initialization routine needed for dual constructors.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseBase.h:388
MooseMesh * _bnd_mesh
Point to mesh.
const bool _bnd_dual_restrictable
Flag for allowing dual restriction with BlockRestrictable.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
THREAD_ID _bnd_tid
Thread id for this object.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:92
bool _bnd_nodal
Whether or not this object is restricted to nodesets.
bool isKokkosObject(IsKokkosObjectKey &&) const
Get whether this object is a Kokkos functor The parameter is set by the Kokkos base classes: ...
Definition: MooseObject.h:72
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 MooseObject & _moose_object
The moose object that this is an interface for.
const MaterialData & _bnd_material_data
Pointer to MaterialData for boundary (.
const std::set< SubdomainID > & _block_ids
Reference to the block_ids, defaults to an empty set if not provided.
FEProblemBase * _bnd_feproblem
Pointer to FEProblemBase.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:199
unsigned int THREAD_ID
Definition: MooseTypes.h:209

◆ BoundaryRestrictable() [3/3]

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

Special constructor used for Kokkos functor copy during parallel dispatch.

◆ ~BoundaryRestrictable()

BoundaryRestrictable::~BoundaryRestrictable ( )
virtual

Empty class destructor.

Definition at line 194 of file BoundaryRestrictable.C.

194 {}

Member Function Documentation

◆ boundaryIDs()

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

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(), 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

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
virtual

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
inlinevirtual

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

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(), hasBoundary(), 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

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

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

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

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

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
protected

A helper method to avoid circular #include problems.

See also
hasBoundaryMaterialProperty

Definition at line 318 of file BoundaryRestrictable.C.

Referenced by 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

◆ initializeBoundaryRestrictable()

void BoundaryRestrictable::initializeBoundaryRestrictable ( )
private

An initialization routine needed for dual constructors.

Definition at line 84 of file BoundaryRestrictable.C.

85 {
86  // The name and id of the object
87  const std::string & name = _moose_object.name();
88 
89  // If the mesh pointer is not defined, but FEProblemBase is, get it from there
90  if (_bnd_feproblem != NULL && _bnd_mesh == NULL)
92 
93  // Check that the mesh pointer was defined, it is required for this class to operate
94  if (_bnd_mesh == NULL)
95  mooseError("The input parameters must contain a pointer to FEProblemBase via '_fe_problem' or "
96  "a pointer to the MooseMesh via '_mesh'");
97 
98  // If the user supplies boundary IDs
99  if (_moose_object.isParamValid("boundary"))
100  {
101  // Extract the blocks from the input
102  _boundary_names = _moose_object.getParam<std::vector<BoundaryName>>("boundary");
103 
104  // Get the IDs from the supplied names
106 
107  // Store the IDs, handling ANY_BOUNDARY_ID if supplied
108  if (std::find(_boundary_names.begin(), _boundary_names.end(), "ANY_BOUNDARY_ID") !=
109  _boundary_names.end())
111  else
112  _bnd_ids.insert(_vec_ids.begin(), _vec_ids.end());
113  }
114 
115  // Produce error if the object is not allowed to be both block and boundary restricted
116  if (!_bnd_dual_restrictable && !_bnd_ids.empty() && !_block_ids.empty())
117  if (!_block_ids.empty() && _block_ids.find(Moose::ANY_BLOCK_ID) == _block_ids.end())
118  _moose_object.paramError("boundary",
119  "Attempted to restrict the object '",
120  name,
121  "' to a boundary, but the object is already restricted by block(s)");
122 
123  // Store ANY_BOUNDARY_ID if empty
124  if (_bnd_ids.empty())
125  {
127  _boundary_names = {"ANY_BOUNDARY_ID"};
128  }
129 
130  // If this object is block restricted, check that defined blocks exist on the mesh
131  if (_bnd_ids.find(Moose::ANY_BOUNDARY_ID) == _bnd_ids.end())
132  {
133  const std::set<BoundaryID> * valid_ids;
134  const char * message_ptr = nullptr;
135 
136  if (_bnd_nodal)
137  {
138  valid_ids = &_bnd_mesh->meshNodesetIds();
139  message_ptr = "node sets";
140  }
141  else
142  {
143  valid_ids = &_bnd_mesh->meshSidesetIds();
144  message_ptr = "side sets";
145  }
146 
147  std::vector<BoundaryID> diff;
148 
149  std::set_difference(_bnd_ids.begin(),
150  _bnd_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 " << message_ptr << " (ids) do not exist on the mesh:";
160  for (const auto & id : diff)
161  {
162  if (_boundary_names.size() > 0)
163  {
164  auto & name = _boundary_names.at(std::find(_vec_ids.begin(), _vec_ids.end(), id) -
165  _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  if (!_bnd_nodal)
176  // Diagnostic message
177  msg << "\n\nMOOSE distinguishes between \"node sets\" and \"side sets\" depending on "
178  "whether\nyou are using \"Nodal\" or \"Integrated\" BCs respectively. Node sets "
179  "corresponding\nto your side sets are constructed for you by default.\n\n"
180  "Try setting \"Mesh/construct_side_list_from_node_list=true\" if you see this "
181  "error.\n"
182  "Note: If you are running with adaptivity you should prefer using side sets.";
183 
184  _moose_object.paramError("boundary", msg.str());
185  }
186  }
187 
188 #ifdef MOOSE_KOKKOS_ENABLED
191 #endif
192 }
std::string name(const ElemQuality q)
const std::set< BoundaryID > & meshNodesetIds() const
Returns a read-only reference to the set of nodesets currently present in the Mesh.
Definition: MooseMesh.C:3229
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:30
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:439
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseBase.h:388
const std::set< BoundaryID > & meshSidesetIds() const
Returns a read-only reference to the set of sidesets currently present in the Mesh.
Definition: MooseMesh.C:3223
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
MooseMesh * _bnd_mesh
Point to mesh.
const bool _bnd_dual_restrictable
Flag for allowing dual restriction with BlockRestrictable.
const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:103
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.
bool _bnd_nodal
Whether or not this object is restricted to nodesets.
bool isKokkosObject(IsKokkosObjectKey &&) const
Get whether this object is a Kokkos functor The parameter is set by the Kokkos base classes: ...
Definition: MooseObject.h:72
std::vector< BoundaryID > _vec_ids
Vector of the boundary ids.
const MooseObject & _moose_object
The moose object that this is an interface for.
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.C:19
std::vector< BoundaryName > _boundary_names
Vector the the boundary names.
virtual MooseMesh & mesh() override
const std::set< SubdomainID > & _block_ids
Reference to the block_ids, defaults to an empty set if not provided.
FEProblemBase * _bnd_feproblem
Pointer to FEProblemBase.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:199
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. ...
void initializeKokkosBoundaryRestrictable(MooseMesh *mesh)
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.C:21

◆ initializeKokkosBoundaryRestrictable()

void BoundaryRestrictable::initializeKokkosBoundaryRestrictable ( MooseMesh mesh)
private

◆ isBoundarySubset() [1/2]

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

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 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

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
inlineprotected

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
inlineprotected

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

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 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

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
inlineprotected

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
inlineprotected

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)
static

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 boundaryRestricted().

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

◆ validParams()

InputParameters BoundaryRestrictable::validParams ( )
static

Definition at line 17 of file BoundaryRestrictable.C.

Referenced by NodePositions::validParams(), InterfaceKernelBase::validParams(), NodalUserObject::validParams(), NodalKernelBase::validParams(), DGKernelBase::validParams(), InitialConditionBase::validParams(), AuxKernelTempl< Real >::validParams(), and MaterialBase::validParams().

18 {
19 
20  // Create instance of InputParameters
22 
23  // Create user-facing 'boundary' input for restricting inheriting object to boundaries
24  params.addParam<std::vector<BoundaryName>>(
25  "boundary", "The list of boundaries (ids or names) from the mesh where this object applies");
26 
27  // A parameter for disabling error message for objects restrictable by boundary and block,
28  // if the parameter is valid it was already set so don't do anything
29  if (!params.isParamValid("_dual_restrictable"))
30  params.addPrivateParam<bool>("_dual_restrictable", false);
31 
32  return params;
33 }
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...
InputParameters emptyInputParameters()
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
bool isParamValid(const std::string &name) const
This method returns parameters that have been initialized in one fashion or another, i.e.

Member Data Documentation

◆ _block_ids

const std::set<SubdomainID>& BoundaryRestrictable::_block_ids
private

Reference to the block_ids, defaults to an empty set if not provided.

Definition at line 215 of file BoundaryRestrictable.h.

Referenced by initializeBoundaryRestrictable().

◆ _bnd_dual_restrictable

const bool BoundaryRestrictable::_bnd_dual_restrictable
private

Flag for allowing dual restriction with BlockRestrictable.

Definition at line 209 of file BoundaryRestrictable.h.

Referenced by initializeBoundaryRestrictable().

◆ _bnd_feproblem

FEProblemBase* BoundaryRestrictable::_bnd_feproblem
private

◆ _bnd_ids

std::set<BoundaryID> BoundaryRestrictable::_bnd_ids
private

◆ _bnd_material_data

const MaterialData& BoundaryRestrictable::_bnd_material_data
private

Pointer to MaterialData for boundary (.

See also
hasBoundaryMaterialProperty)

Definition at line 221 of file BoundaryRestrictable.h.

Referenced by hasBoundaryMaterialProperty().

◆ _bnd_mesh

MooseMesh* BoundaryRestrictable::_bnd_mesh
private

Point to mesh.

Definition at line 197 of file BoundaryRestrictable.h.

Referenced by hasBoundary(), initializeBoundaryRestrictable(), isBoundarySubset(), and meshBoundaryIDs().

◆ _bnd_nodal

bool BoundaryRestrictable::_bnd_nodal
private

Whether or not this object is restricted to nodesets.

Definition at line 224 of file BoundaryRestrictable.h.

Referenced by initializeBoundaryRestrictable().

◆ _bnd_tid

THREAD_ID BoundaryRestrictable::_bnd_tid
private

Thread id for this object.

Definition at line 218 of file BoundaryRestrictable.h.

◆ _boundary_names

std::vector<BoundaryName> BoundaryRestrictable::_boundary_names
private

Vector the the boundary names.

Definition at line 206 of file BoundaryRestrictable.h.

Referenced by boundaryNames(), and initializeBoundaryRestrictable().

◆ _empty_block_ids

const std::set<SubdomainID> BoundaryRestrictable::_empty_block_ids
private

An empty set for referencing when block_ids is not included.

Definition at line 212 of file BoundaryRestrictable.h.

◆ _kokkos_element_side_ids

Moose::Kokkos::Array<Moose::Kokkos::Pair<ContiguousElementID, unsigned int> > BoundaryRestrictable::_kokkos_element_side_ids
private

List of contiguous element ID - side index pairs this Kokkos object is operating on.

Definition at line 289 of file BoundaryRestrictable.h.

Referenced by kokkosBoundaryElementSideID(), and numKokkosBoundarySides().

◆ _kokkos_node_ids

Moose::Kokkos::Array<ContiguousNodeID> BoundaryRestrictable::_kokkos_node_ids
private

List of contiguous node IDs this Kokkos object is operating on.

Definition at line 284 of file BoundaryRestrictable.h.

Referenced by kokkosBoundaryNodeID(), and numKokkosBoundaryNodes().

◆ _moose_object

const MooseObject& BoundaryRestrictable::_moose_object
private

The moose object that this is an interface for.

Definition at line 227 of file BoundaryRestrictable.h.

Referenced by initializeBoundaryRestrictable().

◆ _vec_ids

std::vector<BoundaryID> BoundaryRestrictable::_vec_ids
private

Vector of the boundary ids.

Definition at line 203 of file BoundaryRestrictable.h.

Referenced by initializeBoundaryRestrictable().


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