www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
BlockRestrictable Class Reference

An interface that restricts an object to subdomains via the 'blocks' input parameter. More...

#include <BlockRestrictable.h>

Inheritance diagram for BlockRestrictable:
[legend]

Public Member Functions

 BlockRestrictable (const MooseObject *moose_object)
 Class constructor Populates the 'block' input parameters, see the general class documentation for details. More...
 
 BlockRestrictable (const MooseObject *moose_object, const std::set< BoundaryID > &boundary_ids)
 Class constructor Populates the 'block' input parameters when an object is also boundary restricted, see the general class documentation for details. More...
 
virtual ~BlockRestrictable ()
 Destructor: does nothing but needs to be marked as virtual since this class defines virtual functions. More...
 
const std::vector< SubdomainName > & blocks () const
 Return the block names for this object. More...
 
unsigned int numBlocks () const
 Return the number of blocks for this object. More...
 
virtual const std::set< SubdomainID > & blockIDs () const
 Return the block subdomain ids for this object. More...
 
bool hasBlocks (const SubdomainName &name) const
 Test if the supplied block name is valid for this object. More...
 
bool hasBlocks (const std::vector< SubdomainName > &names) const
 Test if the supplied vector of block names are valid for this object. More...
 
bool hasBlocks (const SubdomainID &id) const
 Test if the supplied block ids are valid for this object. More...
 
bool hasBlocks (const std::vector< SubdomainID > &ids) const
 Test if the supplied vector block ids are valid for this object. More...
 
bool hasBlocks (const std::set< SubdomainID > &ids) const
 Test if the supplied set of block ids are valid for this object. More...
 
bool isBlockSubset (const std::set< SubdomainID > &ids) const
 Test if the class block ids are a subset of the supplied objects. More...
 
bool isBlockSubset (const std::vector< SubdomainID > &ids) const
 Test if the class block ids are a subset of the supplied objects. More...
 
template<typename T >
bool hasBlockMaterialProperty (const std::string &prop_name)
 Check if a material property is valid for all blocks of this object. More...
 
const std::set< SubdomainID > & meshBlockIDs () const
 Return all of the SubdomainIDs for the mesh. More...
 
virtual bool blockRestricted () const
 Returns true if this object has been restricted to a boundary. More...
 
void checkVariable (const MooseVariableFEBase &variable) const
 Helper for checking that the ids for this object are in agreement with the variables on the supplied variable. More...
 

Protected Member Functions

virtual bool hasBlockMaterialPropertyHelper (const std::string &prop_name)
 A helper method to allow the Material object to specialize the behavior of hasBlockMaterialProperty. More...
 
void initializeBlockRestrictable (const MooseObject *moose_object)
 An initialization routine needed for dual constructors. More...
 
Moose::CoordinateSystemType getBlockCoordSystem ()
 Check if the blocks this object operates on all have the same coordinate system, and if so return it. More...
 

Protected Attributes

std::shared_ptr< MaterialData_blk_material_data
 Pointer to the MaterialData class for this object. More...
 

Private Attributes

std::set< SubdomainID_blk_ids
 Set of block ids supplied by the user via the input file (for error reporting) More...
 
std::vector< SubdomainName > _blocks
 Vector the block names supplied by the user via the input file. More...
 
const bool _blk_dual_restrictable
 Flag for allowing dual restriction. More...
 
FEProblemBase_blk_feproblem
 Pointer to FEProblemBase. More...
 
MooseMesh_blk_mesh
 Pointer to Mesh. More...
 
const std::set< BoundaryID_empty_boundary_ids
 An empty set for referencing when boundary_ids is not included. More...
 
const std::set< BoundaryID > & _boundary_ids
 Reference to the boundary_ids, defaults to an empty set if not provided. More...
 
THREAD_ID _blk_tid
 Thread id for this object. More...
 
const std::string & _blk_name
 Name of the object. More...
 

Detailed Description

An interface that restricts an object to subdomains via the 'blocks' input parameter.

This class adds the 'blocks' input parameter and checks that it is populated, if it is not populated it will be populated with all valid block ids via two methods:

  1. If a 'variable' parameter is present in the input parameters then by default the 'block' input is set to all blocks associated with the variable.
  2. If no 'variable' parameter is present then it utilizes all available blocks for the associated mesh.

When using with an object with a 'variable' parameter (e.g., Kernel), the following must also exist within the input parameters for the class to operate correctly

In the general case (i.e., no 'variable') either one of the following must also exist within the input parameters for proper operation of the class:

When creating a new object, generally, this class should be inherited following MooseObject. Also, the validParams<BlockRestricted>() must be added to any other parameters for the the class being created, since this is where the 'blocks' input parameter is created.

See also
Kernel
SideSetsAroundSubdomain

Definition at line 60 of file BlockRestrictable.h.

Constructor & Destructor Documentation

◆ BlockRestrictable() [1/2]

BlockRestrictable::BlockRestrictable ( const MooseObject moose_object)

Class constructor Populates the 'block' input parameters, see the general class documentation for details.

Parameters
parametersThe input parameters (see the detailed help for additional information)

Definition at line 41 of file BlockRestrictable.C.

42  : _blk_dual_restrictable(moose_object->getParam<bool>("_dual_restrictable")),
43  _blk_feproblem(moose_object->isParamValid("_fe_problem_base")
44  ? moose_object->getParam<FEProblemBase *>("_fe_problem_base")
45  : NULL),
46  _blk_mesh(moose_object->isParamValid("_mesh") ? moose_object->getParam<MooseMesh *>("_mesh")
47  : NULL),
49  _blk_tid(moose_object->isParamValid("_tid") ? moose_object->getParam<THREAD_ID>("_tid") : 0),
50  _blk_name(moose_object->getParam<std::string>("_object_name"))
51 {
52  initializeBlockRestrictable(moose_object);
53 }
const bool _blk_dual_restrictable
Flag for allowing dual restriction.
FEProblemBase * _blk_feproblem
Pointer to FEProblemBase.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseObject.h:185
void initializeBlockRestrictable(const MooseObject *moose_object)
An initialization routine needed for dual constructors.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:72
THREAD_ID _blk_tid
Thread id for this object.
const std::set< BoundaryID > _empty_boundary_ids
An empty set for referencing when boundary_ids is not included.
const std::set< BoundaryID > & _boundary_ids
Reference to the boundary_ids, defaults to an empty set if not provided.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseObject.h:81
const std::string & _blk_name
Name of the object.
MooseMesh * _blk_mesh
Pointer to Mesh.
unsigned int THREAD_ID
Definition: MooseTypes.h:97

◆ BlockRestrictable() [2/2]

BlockRestrictable::BlockRestrictable ( const MooseObject moose_object,
const std::set< BoundaryID > &  boundary_ids 
)

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

Parameters
parametersThe input parameters (see the detailed help for additional information)
boundary_idsThe boundary ids that the object is restricted to

Definition at line 56 of file BlockRestrictable.C.

58  : _blk_dual_restrictable(moose_object->getParam<bool>("_dual_restrictable")),
59  _blk_feproblem(moose_object->isParamValid("_fe_problem_base")
60  ? moose_object->getParam<FEProblemBase *>("_fe_problem_base")
61  : NULL),
62  _blk_mesh(moose_object->isParamValid("_mesh") ? moose_object->getParam<MooseMesh *>("_mesh")
63  : NULL),
64  _boundary_ids(boundary_ids),
65  _blk_tid(moose_object->isParamValid("_tid") ? moose_object->getParam<THREAD_ID>("_tid") : 0),
66  _blk_name(moose_object->getParam<std::string>("_object_name"))
67 {
68  initializeBlockRestrictable(moose_object);
69 }
const bool _blk_dual_restrictable
Flag for allowing dual restriction.
FEProblemBase * _blk_feproblem
Pointer to FEProblemBase.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseObject.h:185
void initializeBlockRestrictable(const MooseObject *moose_object)
An initialization routine needed for dual constructors.
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:72
THREAD_ID _blk_tid
Thread id for this object.
const std::set< BoundaryID > & _boundary_ids
Reference to the boundary_ids, defaults to an empty set if not provided.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseObject.h:81
const std::string & _blk_name
Name of the object.
MooseMesh * _blk_mesh
Pointer to Mesh.
unsigned int THREAD_ID
Definition: MooseTypes.h:97

◆ ~BlockRestrictable()

virtual BlockRestrictable::~BlockRestrictable ( )
inlinevirtual

Destructor: does nothing but needs to be marked as virtual since this class defines virtual functions.

Definition at line 83 of file BlockRestrictable.h.

83 {}

Member Function Documentation

◆ blockIDs()

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

Return the block subdomain ids for this object.

Returns
a set of SudomainIDs that are valid for this object

Definition at line 167 of file BlockRestrictable.C.

Referenced by getBlockCoordSystem(), Material::getZeroMaterialProperty(), hasBlockMaterialPropertyHelper(), and Material::registerPropName().

168 {
169  return _blk_ids;
170 }
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error reporting)

◆ blockRestricted()

bool BlockRestrictable::blockRestricted ( ) const
virtual

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

See also
MooseObject

Definition at line 155 of file BlockRestrictable.C.

Referenced by MooseObjectWarehouseBase< Indicator >::addObject(), checkVariable(), getBlockCoordSystem(), and hasBlockMaterialPropertyHelper().

156 {
157  return _blk_ids.find(Moose::ANY_BLOCK_ID) == _blk_ids.end();
158 }
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.h:319
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error reporting)

◆ blocks()

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

Return the block names for this object.

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

Returns
vector of SubdomainNames that are valid for this object

Definition at line 161 of file BlockRestrictable.C.

Referenced by MaterialOutputAction::getParams().

162 {
163  return _blocks;
164 }
std::vector< SubdomainName > _blocks
Vector the block names supplied by the user via the input file.

◆ checkVariable()

void BlockRestrictable::checkVariable ( const MooseVariableFEBase variable) const

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

Parameters
variableThe variable to check against.

Definition at line 307 of file BlockRestrictable.C.

308 {
309  if (!isBlockSubset(variable.activeSubdomains()))
310  {
311  std::string var_ids = Moose::stringify(variable.activeSubdomains(), ", ");
312  std::string obj_ids = Moose::stringify(blockRestricted() ? _blk_ids : meshBlockIDs(), ", ");
313  mooseError("The 'block' parameter of the object '",
314  _blk_name,
315  "' must be a subset of the 'block' parameter of the variable '",
316  variable.name(),
317  "':\n Object '",
318  _blk_name,
319  "': ",
320  obj_ids,
321  "\n Variable '",
322  variable.name(),
323  "': ",
324  var_ids);
325  }
326 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
virtual bool blockRestricted() const
Returns true if this object has been restricted to a boundary.
virtual const std::set< SubdomainID > & activeSubdomains() const =0
The subdomains the variable is active on.
bool isBlockSubset(const std::set< SubdomainID > &ids) const
Test if the class block ids are a subset of the supplied objects.
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:58
const std::string & name() const
Get the variable name.
const std::set< SubdomainID > & meshBlockIDs() const
Return all of the SubdomainIDs for the mesh.
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error reporting)
const std::string & _blk_name
Name of the object.

◆ getBlockCoordSystem()

Moose::CoordinateSystemType BlockRestrictable::getBlockCoordSystem ( )
protected

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

Definition at line 285 of file BlockRestrictable.C.

286 {
287  if (!_blk_mesh)
288  mooseError("No mesh available in BlockRestrictable::checkCoordSystem()");
289  if (!_blk_feproblem)
290  mooseError("No problem available in BlockRestrictable::checkCoordSystem()");
291 
292  const auto & subdomains = blockRestricted() ? blockIDs() : meshBlockIDs();
293 
294  if (subdomains.empty())
295  mooseError("No subdomains found in the problem.");
296 
297  // make sure all subdomains are using the same coordinate system
298  auto coord_system = _blk_feproblem->getCoordSystem(*subdomains.begin());
299  for (auto subdomain : subdomains)
300  if (_blk_feproblem->getCoordSystem(subdomain) != coord_system)
301  mooseError("This object requires all subdomains to have the same coordinate system.");
302 
303  return coord_system;
304 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
FEProblemBase * _blk_feproblem
Pointer to FEProblemBase.
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object.
virtual bool blockRestricted() const
Returns true if this object has been restricted to a boundary.
virtual Moose::CoordinateSystemType getCoordSystem(SubdomainID sid) override
const std::set< SubdomainID > & meshBlockIDs() const
Return all of the SubdomainIDs for the mesh.
MooseMesh * _blk_mesh
Pointer to Mesh.

◆ hasBlockMaterialProperty()

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

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

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

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

Definition at line 249 of file BlockRestrictable.h.

250 {
251  mooseAssert(_blk_material_data != NULL, "MaterialData pointer is not defined");
252  return hasBlockMaterialPropertyHelper(prop_name) &&
253  _blk_material_data->haveProperty<T>(prop_name);
254 }
std::shared_ptr< MaterialData > _blk_material_data
Pointer to the MaterialData class for this object.
virtual bool hasBlockMaterialPropertyHelper(const std::string &prop_name)
A helper method to allow the Material object to specialize the behavior of hasBlockMaterialProperty.

◆ hasBlockMaterialPropertyHelper()

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

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

It also avoid circular #include problems.

See also
hasBlockMaterialProperty

Definition at line 249 of file BlockRestrictable.C.

Referenced by hasBlockMaterialProperty().

250 {
251 
252  // Reference to MaterialWarehouse for testing and retrieving block ids
254 
255  // Complete set of ids that this object is active
256  const std::set<SubdomainID> & ids = blockRestricted() ? blockIDs() : meshBlockIDs();
257 
258  // Loop over each id for this object
259  for (const auto & id : ids)
260  {
261  // Storage of material properties that have been DECLARED on this id
262  std::set<std::string> declared_props;
263 
264  // If block materials exist, populated the set of properties that were declared
265  if (warehouse.hasActiveBlockObjects(id))
266  {
267  const std::vector<std::shared_ptr<Material>> & mats = warehouse.getActiveBlockObjects(id);
268  for (const auto & mat : mats)
269  {
270  const std::set<std::string> & mat_props = mat->getSuppliedItems();
271  declared_props.insert(mat_props.begin(), mat_props.end());
272  }
273  }
274 
275  // If the supplied property is not in the list of properties on the current id, return false
276  if (declared_props.find(prop_name) == declared_props.end())
277  return false;
278  }
279 
280  // If you get here the supplied property is defined on all blocks
281  return true;
282 }
bool hasActiveBlockObjects(THREAD_ID tid=0) const
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
FEProblemBase * _blk_feproblem
Pointer to FEProblemBase.
virtual const std::set< SubdomainID > & blockIDs() const
Return the block subdomain ids for this object.
virtual bool blockRestricted() const
Returns true if this object has been restricted to a boundary.
Material objects are special in that they have additional objects created automatically (see FEProble...
const MaterialWarehouse & getMaterialWarehouse() const
const std::set< SubdomainID > & meshBlockIDs() const
Return all of the SubdomainIDs for the mesh.

◆ hasBlocks() [1/5]

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

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

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

Definition at line 179 of file BlockRestrictable.C.

Referenced by CentroidMultiApp::fillPositions(), and hasBlocks().

180 {
181  // Create a vector and utilize the getSubdomainIDs function, which
182  // handles the ANY_BLOCK_ID (getSubdomainID does not)
183  std::vector<SubdomainName> names(1);
184  names[0] = name;
185  return hasBlocks(_blk_mesh->getSubdomainIDs(names));
186 }
std::vector< SubdomainID > getSubdomainIDs(const std::vector< SubdomainName > &subdomain_name) const
Get the associated subdomainIDs for the subdomain names that are passed in.
Definition: MooseMesh.C:1126
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
MooseMesh * _blk_mesh
Pointer to Mesh.

◆ hasBlocks() [2/5]

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

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

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

Definition at line 189 of file BlockRestrictable.C.

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

◆ hasBlocks() [3/5]

bool BlockRestrictable::hasBlocks ( const SubdomainID id) const

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

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

Definition at line 195 of file BlockRestrictable.C.

196 {
197  if (_blk_ids.empty() || _blk_ids.find(Moose::ANY_BLOCK_ID) != _blk_ids.end())
198  return true;
199  else
200  return _blk_ids.find(id) != _blk_ids.end();
201 }
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.h:319
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error reporting)

◆ hasBlocks() [4/5]

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

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

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

Definition at line 204 of file BlockRestrictable.C.

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

◆ hasBlocks() [5/5]

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

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

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

Definition at line 211 of file BlockRestrictable.C.

212 {
213  if (_blk_ids.empty() || _blk_ids.find(Moose::ANY_BLOCK_ID) != _blk_ids.end())
214  return true;
215  else
216  return std::includes(_blk_ids.begin(), _blk_ids.end(), ids.begin(), ids.end());
217 }
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.h:319
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error reporting)

◆ initializeBlockRestrictable()

void BlockRestrictable::initializeBlockRestrictable ( const MooseObject moose_object)
protected

An initialization routine needed for dual constructors.

Definition at line 72 of file BlockRestrictable.C.

Referenced by BlockRestrictable().

73 {
74  // If the mesh pointer is not defined, but FEProblemBase is, get it from there
75  if (_blk_feproblem != NULL && _blk_mesh == NULL)
77 
78  // Check that the mesh pointer was defined, it is required for this class to operate
79  if (_blk_mesh == NULL)
80  mooseError("The input parameters must contain a pointer to FEProblem via '_fe_problem' or a "
81  "pointer to the MooseMesh via '_mesh'");
82 
83  // Populate the MaterialData pointer
84  if (_blk_feproblem != NULL)
86 
87  // The 'block' input is defined
88  if (moose_object->isParamValid("block"))
89  {
90  // Extract the blocks from the input
91  _blocks = moose_object->getParam<std::vector<SubdomainName>>("block");
92 
93  // Get the IDs from the supplied names
94  std::vector<SubdomainID> vec_ids = _blk_mesh->getSubdomainIDs(_blocks);
95 
96  // Store the IDs, handling ANY_BLOCK_ID if supplied
97  if (std::find(_blocks.begin(), _blocks.end(), "ANY_BLOCK_ID") != _blocks.end())
99  else
100  _blk_ids.insert(vec_ids.begin(), vec_ids.end());
101  }
102 
103  // When 'blocks' is not set and there is a "variable", use the blocks from the variable
104  else if (moose_object->isParamValid("variable"))
105  {
106  std::string variable_name = moose_object->parameters().getMooseType("variable");
107  if (!variable_name.empty())
109  ->getVariable(_blk_tid,
110  variable_name,
113  .activeSubdomains();
114  }
115 
116  // Produce error if the object is not allowed to be both block and boundary restricted
117  if (!_blk_dual_restrictable && !_boundary_ids.empty() && !_boundary_ids.empty())
118  if (!_boundary_ids.empty() && _boundary_ids.find(Moose::ANY_BOUNDARY_ID) == _boundary_ids.end())
119  mooseError("Attempted to restrict the object '",
120  _blk_name,
121  "' to a block, but the object is already restricted by boundary");
122 
123  // If no blocks were defined above, specify that it is valid on all blocks
124  if (_blk_ids.empty() && !moose_object->isParamValid("boundary"))
125  {
127  _blocks = {"ANY_BLOCK_ID"};
128  }
129 
130  // If this object is block restricted, check that defined blocks exist on the mesh
131  if (_blk_ids.find(Moose::ANY_BLOCK_ID) == _blk_ids.end())
132  {
133  const std::set<SubdomainID> & valid_ids = _blk_mesh->meshSubdomains();
134  std::vector<SubdomainID> diff;
135 
136  std::set_difference(_blk_ids.begin(),
137  _blk_ids.end(),
138  valid_ids.begin(),
139  valid_ids.end(),
140  std::back_inserter(diff));
141 
142  if (!diff.empty())
143  {
144  std::ostringstream msg;
145  msg << "The object '" << _blk_name
146  << "' contains the following block ids that do not exist on the mesh:";
147  for (const auto & id : diff)
148  msg << " " << id;
149  mooseError(msg.str());
150  }
151  }
152 }
std::string getMooseType(const std::string &name) const
Utility functions for retrieving one of the MooseTypes variables into the common "string" base class...
const bool _blk_dual_restrictable
Flag for allowing dual restriction.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
FEProblemBase * _blk_feproblem
Pointer to FEProblemBase.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseObject.h:185
std::shared_ptr< MaterialData > _blk_material_data
Pointer to the MaterialData class for this object.
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseObject.h:57
THREAD_ID _blk_tid
Thread id for this object.
std::vector< SubdomainName > _blocks
Vector the block names supplied by the user via the input file.
std::shared_ptr< MaterialData > getMaterialData(Moose::MaterialDataType type, THREAD_ID tid=0)
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.h:319
virtual MooseMesh & mesh() override
const std::set< BoundaryID > & _boundary_ids
Reference to the boundary_ids, defaults to an empty set if not provided.
std::vector< SubdomainID > getSubdomainIDs(const std::vector< SubdomainName > &subdomain_name) const
Get the associated subdomainIDs for the subdomain names that are passed in.
Definition: MooseMesh.C:1126
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error reporting)
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseObject.h:81
const std::string & _blk_name
Name of the object.
MooseMesh * _blk_mesh
Pointer to Mesh.
const BoundaryID ANY_BOUNDARY_ID
Definition: MooseTypes.h:321
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:2261

◆ isBlockSubset() [1/2]

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

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

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

Definition at line 220 of file BlockRestrictable.C.

Referenced by checkVariable(), and isBlockSubset().

221 {
222  // An empty input is assumed to be ANY_BLOCK_ID
223  if (ids.empty() || ids.find(Moose::ANY_BLOCK_ID) != ids.end())
224  return true;
225 
226  if (_blk_ids.find(Moose::ANY_BLOCK_ID) != _blk_ids.end())
227  return std::includes(ids.begin(),
228  ids.end(),
229  _blk_mesh->meshSubdomains().begin(),
230  _blk_mesh->meshSubdomains().end());
231  else
232  return std::includes(ids.begin(), ids.end(), _blk_ids.begin(), _blk_ids.end());
233 }
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.h:319
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error reporting)
MooseMesh * _blk_mesh
Pointer to Mesh.
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:2261

◆ isBlockSubset() [2/2]

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

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

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

Definition at line 236 of file BlockRestrictable.C.

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

◆ meshBlockIDs()

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

Return all of the SubdomainIDs for the mesh.

Returns
A set of all subdomians for the entire mesh

Definition at line 243 of file BlockRestrictable.C.

Referenced by checkVariable(), getBlockCoordSystem(), and hasBlockMaterialPropertyHelper().

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

◆ numBlocks()

unsigned int BlockRestrictable::numBlocks ( ) const

Return the number of blocks for this object.

Returns
The number of subdomains

Definition at line 173 of file BlockRestrictable.C.

174 {
175  return (unsigned int)_blk_ids.size();
176 }
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error reporting)

Member Data Documentation

◆ _blk_dual_restrictable

const bool BlockRestrictable::_blk_dual_restrictable
private

Flag for allowing dual restriction.

Definition at line 226 of file BlockRestrictable.h.

Referenced by initializeBlockRestrictable().

◆ _blk_feproblem

FEProblemBase* BlockRestrictable::_blk_feproblem
private

◆ _blk_ids

std::set<SubdomainID> BlockRestrictable::_blk_ids
private

Set of block ids supplied by the user via the input file (for error reporting)

Definition at line 220 of file BlockRestrictable.h.

Referenced by blockIDs(), blockRestricted(), checkVariable(), hasBlocks(), initializeBlockRestrictable(), isBlockSubset(), and numBlocks().

◆ _blk_material_data

std::shared_ptr<MaterialData> BlockRestrictable::_blk_material_data
protected

Pointer to the MaterialData class for this object.

Definition at line 198 of file BlockRestrictable.h.

Referenced by hasBlockMaterialProperty(), and initializeBlockRestrictable().

◆ _blk_mesh

MooseMesh* BlockRestrictable::_blk_mesh
private

Pointer to Mesh.

Definition at line 232 of file BlockRestrictable.h.

Referenced by getBlockCoordSystem(), hasBlocks(), initializeBlockRestrictable(), isBlockSubset(), and meshBlockIDs().

◆ _blk_name

const std::string& BlockRestrictable::_blk_name
private

Name of the object.

Definition at line 244 of file BlockRestrictable.h.

Referenced by checkVariable(), and initializeBlockRestrictable().

◆ _blk_tid

THREAD_ID BlockRestrictable::_blk_tid
private

Thread id for this object.

Definition at line 241 of file BlockRestrictable.h.

Referenced by initializeBlockRestrictable().

◆ _blocks

std::vector<SubdomainName> BlockRestrictable::_blocks
private

Vector the block names supplied by the user via the input file.

Definition at line 223 of file BlockRestrictable.h.

Referenced by blocks(), and initializeBlockRestrictable().

◆ _boundary_ids

const std::set<BoundaryID>& BlockRestrictable::_boundary_ids
private

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

Definition at line 238 of file BlockRestrictable.h.

Referenced by initializeBlockRestrictable().

◆ _empty_boundary_ids

const std::set<BoundaryID> BlockRestrictable::_empty_boundary_ids
private

An empty set for referencing when boundary_ids is not included.

Definition at line 235 of file BlockRestrictable.h.


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