www.mooseframework.org
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)
 
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...
 

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 29 of file BoundaryRestrictable.h.

Constructor & Destructor Documentation

◆ BoundaryRestrictableRequired()

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

Definition at line 33 of file BoundaryRestrictableRequired.C.

35  : BoundaryRestrictable(moose_object, nodal)
36 {
37 }
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 180 of file BoundaryRestrictable.C.

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

181 {
182  return _bnd_ids;
183 }
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 186 of file BoundaryRestrictable.C.

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

187 {
188  return _boundary_names;
189 }
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 198 of file BoundaryRestrictable.C.

Referenced by Material::checkMaterialProperty(), MaterialOutputAction::getParams(), and DerivativeMaterialInterface< MortarScalarBase >::haveMaterialProperty().

199 {
201 }
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 179 of file BoundaryRestrictable.h.

179 { 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 210 of file BoundaryRestrictable.C.

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

211 {
212  // Create a vector and utilize the getBoundaryIDs function, which
213  // handles the ANY_BOUNDARY_ID (getBoundaryID does not)
214  return hasBoundary(_bnd_mesh->getBoundaryIDs({name}));
215 }
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. ...
Definition: MooseMesh.C:2719

◆ 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 218 of file BoundaryRestrictable.C.

219 {
220  return hasBoundary(_bnd_mesh->getBoundaryIDs(names));
221 }
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. ...
Definition: MooseMesh.C:2719

◆ 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 224 of file BoundaryRestrictable.C.

225 {
226  if (_bnd_ids.empty() || _bnd_ids.find(Moose::ANY_BOUNDARY_ID) != _bnd_ids.end())
227  return true;
228  else
229  return _bnd_ids.find(id) != _bnd_ids.end();
230 }
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.C:23

◆ 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 233 of file BoundaryRestrictable.C.

234 {
235  std::set<BoundaryID> ids_set(ids.begin(), ids.end());
236  return hasBoundary(ids_set, type);
237 }
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 240 of file BoundaryRestrictable.C.

241 {
242  // An empty input is assumed to be ANY_BOUNDARY_ID
243  if (ids.empty() || ids.find(Moose::ANY_BOUNDARY_ID) != ids.end())
244  return true;
245 
246  // All supplied IDs must match those of the object
247  else if (type == ALL)
248  {
249  if (_bnd_ids.find(Moose::ANY_BOUNDARY_ID) != _bnd_ids.end())
250  return true;
251  else
252  return std::includes(_bnd_ids.begin(), _bnd_ids.end(), ids.begin(), ids.end());
253  }
254  // Any of the supplied IDs must match those of the object
255  else
256  {
257  // Loop through the supplied ids
258  for (const auto & id : ids)
259  {
260  // Test the current supplied id
261  bool test = hasBoundary(id);
262 
263  // If the id exists in the stored ids, then return true, otherwise
264  if (test)
265  return true;
266  }
267  return false;
268  }
269 }
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:23

◆ 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 233 of file BoundaryRestrictable.h.

234 {
235  // If you get here the supplied property is defined on all boundaries, but is still subject
236  // existence in the MateialData class
237  return hasBoundaryMaterialPropertyHelper(prop_name) &&
238  _bnd_material_data.haveGenericProperty<T, is_ad>(prop_name);
239 }
bool haveGenericProperty(const std::string &prop_name) const
Definition: MaterialData.h:253
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 301 of file BoundaryRestrictable.C.

Referenced by BoundaryRestrictable::hasBoundaryMaterialProperty().

302 {
303  // Reference to MaterialWarehouse for testing and retrieving boundary ids
305 
306  // Complete set of BoundaryIDs that this object is defined
307  const std::set<BoundaryID> & ids =
309 
310  // Loop over each BoundaryID for this object
311  for (const auto & id : ids)
312  {
313  // Storage of material properties that have been DECLARED on this BoundaryID
314  std::set<std::string> declared_props;
315 
316  // If boundary materials exist, populated the set of properties that were declared
317  if (warehouse.hasActiveBoundaryObjects(id))
318  {
319  const std::vector<std::shared_ptr<MaterialBase>> & mats =
320  warehouse.getActiveBoundaryObjects(id);
321  for (const auto & mat : mats)
322  {
323  const std::set<std::string> & mat_props = mat->getSuppliedItems();
324  declared_props.insert(mat_props.begin(), mat_props.end());
325  }
326  }
327 
328  // If the supplied property is not in the list of properties on the current id, return false
329  if (declared_props.find(prop_name) == declared_props.end())
330  return false;
331  }
332 
333  // If you get here the supplied property is defined on all boundaries
334  return true;
335 }
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:23

◆ 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 272 of file BoundaryRestrictable.C.

Referenced by BoundaryRestrictable::isBoundarySubset().

273 {
274  // An empty input is assumed to be ANY_BOUNDARY_ID
275  if (ids.empty() || ids.find(Moose::ANY_BOUNDARY_ID) != ids.end())
276  return true;
277 
278  if (_bnd_ids.find(Moose::ANY_BOUNDARY_ID) != _bnd_ids.end())
279  return std::includes(ids.begin(),
280  ids.end(),
281  _bnd_mesh->meshBoundaryIds().begin(),
282  _bnd_mesh->meshBoundaryIds().end());
283  else
284  return std::includes(ids.begin(), ids.end(), _bnd_ids.begin(), _bnd_ids.end());
285 }
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:2927
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.C:23

◆ isBoundarySubset() [2/2]

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

Definition at line 288 of file BoundaryRestrictable.C.

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

◆ 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 295 of file BoundaryRestrictable.C.

Referenced by BoundaryRestrictable::hasBoundaryMaterialPropertyHelper().

296 {
297  return _bnd_mesh->getBoundaryIDs();
298 }
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. ...
Definition: MooseMesh.C:2719

◆ numBoundaryIDs()

unsigned int BoundaryRestrictable::numBoundaryIDs ( ) const
inherited

Return the number of boundaries for this object.

Returns
The number of boundary ids

Definition at line 192 of file BoundaryRestrictable.C.

Referenced by SidesetInfoVectorPostprocessor::initialize().

193 {
194  return (unsigned int)_bnd_ids.size();
195 }
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.

◆ 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 204 of file BoundaryRestrictable.C.

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

205 {
206  return ids.find(Moose::ANY_BOUNDARY_ID) == ids.end();
207 }
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.C:23

◆ validParams()

InputParameters BoundaryRestrictableRequired::validParams ( )
static

Definition at line 15 of file BoundaryRestrictableRequired.C.

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

16 {
17 
18  // Create instance of InputParameters
20 
21  // Create user-facing 'boundary' input for restricting inheriting object to boundaries
22  params.addRequiredParam<std::vector<BoundaryName>>(
23  "boundary", "The list of boundary IDs from the mesh where this object applies");
24 
25  // A parameter for disabling error message for objects restrictable by boundary and block,
26  // if the parameter is valid it was already set so don't do anything
27  if (!params.isParamValid("_dual_restrictable"))
28  params.addPrivateParam<bool>("_dual_restrictable", false);
29 
30  return params;
31 }
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: