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

Static Public Member Functions

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<> specialization that adds the 'boundary' parameter as required.

Definition at line 33 of file BoundaryRestrictableRequired.h.

Member Enumeration Documentation

A flag changing the behavior of hasBoundary.

Enumerator
ALL 
ANY 

Definition at line 40 of file BoundaryRestrictable.h.

Constructor & Destructor Documentation

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

Definition at line 38 of file BoundaryRestrictableRequired.C.

40  : BoundaryRestrictable(moose_object, nodal)
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

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

Referenced by NonlinearSystemBase::addBoundaryCondition(), NonlinearSystemBase::addInterfaceKernel(), AutoPositionsMultiApp::fillPositions(), Material::getZeroMaterialProperty(), BoundaryRestrictable::hasBoundaryMaterialPropertyHelper(), and Material::registerPropName().

154 {
155  return _bnd_ids;
156 }
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.
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 159 of file BoundaryRestrictable.C.

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

160 {
161  return _boundary_names;
162 }
std::vector< BoundaryName > _boundary_names
Vector the the boundary names.
bool BoundaryRestrictable::boundaryRestricted ( ) const
virtualinherited

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

See also
MooseObject

Definition at line 171 of file BoundaryRestrictable.C.

Referenced by DerivativeMaterialInterface< T >::haveMaterialProperty().

172 {
174 }
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.
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 183 of file BoundaryRestrictable.C.

Referenced by BoundaryRestrictable::hasBoundary(), and BoundaryRestrictable::hasBoundaryMaterialPropertyHelper().

184 {
185  // Create a vector and utilize the getBoundaryIDs function, which
186  // handles the ANY_BOUNDARY_ID (getBoundaryID does not)
187  return hasBoundary(_bnd_mesh->getBoundaryIDs({name}));
188 }
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:1951
MooseMesh * _bnd_mesh
Point to mesh.
bool hasBoundary(const BoundaryName &name) const
Test if the supplied boundary name is valid for this object.
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 191 of file BoundaryRestrictable.C.

192 {
193  return hasBoundary(_bnd_mesh->getBoundaryIDs(names));
194 }
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:1951
MooseMesh * _bnd_mesh
Point to mesh.
bool hasBoundary(const BoundaryName &name) const
Test if the supplied boundary name is valid for this object.
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 197 of file BoundaryRestrictable.C.

198 {
199  if (_bnd_ids.empty() || _bnd_ids.find(Moose::ANY_BOUNDARY_ID) != _bnd_ids.end())
200  return true;
201  else
202  return _bnd_ids.find(id) != _bnd_ids.end();
203 }
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.h:119
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 206 of file BoundaryRestrictable.C.

207 {
208  std::set<BoundaryID> ids_set(ids.begin(), ids.end());
209  return hasBoundary(ids_set, type);
210 }
bool hasBoundary(const BoundaryName &name) const
Test if the supplied boundary name is valid for this object.
MatType type
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 213 of file BoundaryRestrictable.C.

214 {
215  // An empty input is assumed to be ANY_BOUNDARY_ID
216  if (ids.empty() || ids.find(Moose::ANY_BOUNDARY_ID) != ids.end())
217  return true;
218 
219  // All supplied IDs must match those of the object
220  else if (type == ALL)
221  {
222  if (_bnd_ids.find(Moose::ANY_BOUNDARY_ID) != _bnd_ids.end())
223  return true;
224  else
225  return std::includes(_bnd_ids.begin(), _bnd_ids.end(), ids.begin(), ids.end());
226  }
227  // Any of the supplied IDs must match those of the object
228  else
229  {
230  // Loop through the supplied ids
231  for (const auto & id : ids)
232  {
233  // Test the current supplied id
234  bool test = hasBoundary(id);
235 
236  // If the id exists in the stored ids, then return true, otherwise
237  if (test)
238  return true;
239  }
240  return false;
241  }
242 }
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.
MatType type
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.h:119
template<typename T >
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 228 of file BoundaryRestrictable.h.

229 {
230  // If you get here the supplied property is defined on all boundaries, but is still subject
231  // existence in the MateialData class
232  return hasBoundaryMaterialPropertyHelper(prop_name) &&
233  _bnd_material_data->haveProperty<T>(prop_name);
234 }
bool hasBoundaryMaterialPropertyHelper(const std::string &prop_name) const
A helper method to avoid circular #include problems.
std::shared_ptr< MaterialData > _bnd_material_data
Pointer to MaterialData for boundary (.
bool BoundaryRestrictable::hasBoundaryMaterialPropertyHelper ( const std::string &  prop_name) const
protectedinherited

A helper method to avoid circular #include problems.

See also
hasBoundaryMaterialProperty

Definition at line 274 of file BoundaryRestrictable.C.

Referenced by BoundaryRestrictable::hasBoundaryMaterialProperty().

275 {
276  // Reference to MaterialWarehouse for testing and retrieving boundary ids
278 
279  // Complete set of BoundaryIDs that this object is defined
280  const std::set<BoundaryID> & ids =
282 
283  // Loop over each BoundaryID for this object
284  for (const auto & id : ids)
285  {
286  // Storage of material properties that have been DECLARED on this BoundaryID
287  std::set<std::string> declared_props;
288 
289  // If boundary materials exist, populated the set of properties that were declared
290  if (warehouse.hasActiveBoundaryObjects(id))
291  {
292  const std::vector<std::shared_ptr<Material>> & mats = warehouse.getActiveBoundaryObjects(id);
293  for (const auto & mat : mats)
294  {
295  const std::set<std::string> & mat_props = mat->getSuppliedItems();
296  declared_props.insert(mat_props.begin(), mat_props.end());
297  }
298  }
299 
300  // If the supplied property is not in the list of properties on the current id, return false
301  if (declared_props.find(prop_name) == declared_props.end())
302  return false;
303  }
304 
305  // If you get here the supplied property is defined on all boundaries
306  return true;
307 }
virtual const std::set< BoundaryID > & boundaryIDs() const
Return the boundary IDs for this object.
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getActiveBoundaryObjects(THREAD_ID tid=0) const
Material objects are special in that they have additional objects created automatically (see FEProble...
const std::set< BoundaryID > & meshBoundaryIDs() const
Returns the set of all boundary ids for the entire mesh.
bool hasActiveBoundaryObjects(THREAD_ID tid=0) const
bool hasBoundary(const BoundaryName &name) const
Test if the supplied boundary name is valid for this object.
const MaterialWarehouse & getMaterialWarehouse()
FEProblemBase * _bnd_feproblem
Pointer to FEProblemBase.
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.h:119
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 245 of file BoundaryRestrictable.C.

Referenced by BoundaryRestrictable::isBoundarySubset().

246 {
247  // An empty input is assumed to be ANY_BOUNDARY_ID
248  if (ids.empty() || ids.find(Moose::ANY_BOUNDARY_ID) != ids.end())
249  return true;
250 
251  if (_bnd_ids.find(Moose::ANY_BOUNDARY_ID) != _bnd_ids.end())
252  return std::includes(ids.begin(),
253  ids.end(),
254  _bnd_mesh->meshBoundaryIds().begin(),
255  _bnd_mesh->meshBoundaryIds().end());
256  else
257  return std::includes(ids.begin(), ids.end(), _bnd_ids.begin(), _bnd_ids.end());
258 }
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:2110
MooseMesh * _bnd_mesh
Point to mesh.
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.h:119
bool BoundaryRestrictable::isBoundarySubset ( const std::vector< BoundaryID > &  ids) const
inherited

Definition at line 261 of file BoundaryRestrictable.C.

262 {
263  std::set<BoundaryID> ids_set(ids.begin(), ids.end());
264  return isBoundarySubset(ids_set);
265 }
bool isBoundarySubset(const std::set< BoundaryID > &ids) const
Test if the class boundary ids are a subset of the supplied objects.
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 268 of file BoundaryRestrictable.C.

Referenced by BoundaryRestrictable::hasBoundaryMaterialPropertyHelper().

269 {
270  return _bnd_mesh->getBoundaryIDs();
271 }
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:1951
MooseMesh * _bnd_mesh
Point to mesh.
unsigned int BoundaryRestrictable::numBoundaryIDs ( ) const
inherited

Return the number of boundaries for this object.

Returns
The number of boundary ids

Definition at line 165 of file BoundaryRestrictable.C.

166 {
167  return (unsigned int)_bnd_ids.size();
168 }
std::set< BoundaryID > _bnd_ids
Set of the boundary ids.
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 177 of file BoundaryRestrictable.C.

Referenced by BoundaryRestrictable::boundaryRestricted().

178 {
179  return ids.find(Moose::ANY_BOUNDARY_ID) == ids.end();
180 }
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.h:119

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