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 MooseVariable &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 65 of file BlockRestrictable.h.

Constructor & Destructor Documentation

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 47 of file BlockRestrictable.C.

48  : _blk_dual_restrictable(moose_object->getParam<bool>("_dual_restrictable")),
49  _blk_feproblem(moose_object->isParamValid("_fe_problem_base")
50  ? moose_object->getParam<FEProblemBase *>("_fe_problem_base")
51  : NULL),
52  _blk_mesh(moose_object->isParamValid("_mesh") ? moose_object->getParam<MooseMesh *>("_mesh")
53  : NULL),
55  _blk_tid(moose_object->isParamValid("_tid") ? moose_object->getParam<THREAD_ID>("_tid") : 0),
56  _blk_name(moose_object->getParam<std::string>("_object_name"))
57 {
58  initializeBlockRestrictable(moose_object);
59 }
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.
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:74
THREAD_ID _blk_tid
Thread id for this object.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseObject.h:67
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseObject.h:122
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.
const std::string & _blk_name
Name of the object.
MooseMesh * _blk_mesh
Pointer to Mesh.
unsigned int THREAD_ID
Definition: MooseTypes.h:79
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 62 of file BlockRestrictable.C.

64  : _blk_dual_restrictable(moose_object->getParam<bool>("_dual_restrictable")),
65  _blk_feproblem(moose_object->isParamValid("_fe_problem_base")
66  ? moose_object->getParam<FEProblemBase *>("_fe_problem_base")
67  : NULL),
68  _blk_mesh(moose_object->isParamValid("_mesh") ? moose_object->getParam<MooseMesh *>("_mesh")
69  : NULL),
70  _boundary_ids(boundary_ids),
71  _blk_tid(moose_object->isParamValid("_tid") ? moose_object->getParam<THREAD_ID>("_tid") : 0),
72  _blk_name(moose_object->getParam<std::string>("_object_name"))
73 {
74  initializeBlockRestrictable(moose_object);
75 }
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.
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:74
THREAD_ID _blk_tid
Thread id for this object.
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseObject.h:67
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseObject.h:122
const std::set< BoundaryID > & _boundary_ids
Reference to the boundary_ids, defaults to an empty set if not provided.
const std::string & _blk_name
Name of the object.
MooseMesh * _blk_mesh
Pointer to Mesh.
unsigned int THREAD_ID
Definition: MooseTypes.h:79
virtual BlockRestrictable::~BlockRestrictable ( )
inlinevirtual

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

Definition at line 88 of file BlockRestrictable.h.

88 {}

Member Function Documentation

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 168 of file BlockRestrictable.C.

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

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

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

See also
MooseObject

Definition at line 156 of file BlockRestrictable.C.

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

157 {
158  return _blk_ids.find(Moose::ANY_BLOCK_ID) == _blk_ids.end();
159 }
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.h:117
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error reporting)
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 162 of file BlockRestrictable.C.

Referenced by ~BlockRestrictable().

163 {
164  return _blocks;
165 }
std::vector< SubdomainName > _blocks
Vector the block names supplied by the user via the input file.
void BlockRestrictable::checkVariable ( const MooseVariable 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 308 of file BlockRestrictable.C.

Referenced by ~BlockRestrictable().

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

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

Referenced by ~BlockRestrictable().

255 {
256  mooseAssert(_blk_material_data != NULL, "MaterialData pointer is not defined");
257  return hasBlockMaterialPropertyHelper(prop_name) &&
258  _blk_material_data->haveProperty<T>(prop_name);
259 }
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.
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 250 of file BlockRestrictable.C.

Referenced by hasBlockMaterialProperty().

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

Referenced by LineMaterialSamplerBase< T >::execute(), hasBlocks(), and ~BlockRestrictable().

181 {
182  // Create a vector and utilize the getSubdomainIDs function, which
183  // handles the ANY_BLOCK_ID (getSubdomainID does not)
184  std::vector<SubdomainName> names(1);
185  names[0] = name;
186  return hasBlocks(_blk_mesh->getSubdomainIDs(names));
187 }
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
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:1051
MooseMesh * _blk_mesh
Pointer to Mesh.
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 190 of file BlockRestrictable.C.

191 {
192  return hasBlocks(_blk_mesh->getSubdomainIDs(names));
193 }
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
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:1051
MooseMesh * _blk_mesh
Pointer to Mesh.
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 196 of file BlockRestrictable.C.

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

206 {
207  std::set<SubdomainID> ids_set(ids.begin(), ids.end());
208  return hasBlocks(ids_set);
209 }
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
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 212 of file BlockRestrictable.C.

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

An initialization routine needed for dual constructors.

Definition at line 78 of file BlockRestrictable.C.

Referenced by BlockRestrictable().

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

Referenced by checkVariable(), isBlockSubset(), and ~BlockRestrictable().

222 {
223  // An empty input is assumed to be ANY_BLOCK_ID
224  if (ids.empty() || ids.find(Moose::ANY_BLOCK_ID) != ids.end())
225  return true;
226 
227  if (_blk_ids.find(Moose::ANY_BLOCK_ID) != _blk_ids.end())
228  return std::includes(ids.begin(),
229  ids.end(),
230  _blk_mesh->meshSubdomains().begin(),
231  _blk_mesh->meshSubdomains().end());
232  else
233  return std::includes(ids.begin(), ids.end(), _blk_ids.begin(), _blk_ids.end());
234 }
const std::set< SubdomainID > & meshSubdomains() const
Returns a read-only reference to the set of subdomains currently present in the Mesh.
Definition: MooseMesh.C:2157
const SubdomainID ANY_BLOCK_ID
Definition: MooseTypes.h:117
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.
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 237 of file BlockRestrictable.C.

238 {
239  std::set<SubdomainID> ids_set(ids.begin(), ids.end());
240  return isBlockSubset(ids_set);
241 }
bool isBlockSubset(const std::set< SubdomainID > &ids) const
Test if the class block ids are a subset of the supplied objects.
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 244 of file BlockRestrictable.C.

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

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

Return the number of blocks for this object.

Returns
The number of subdomains

Definition at line 174 of file BlockRestrictable.C.

Referenced by ~BlockRestrictable().

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

Member Data Documentation

const bool BlockRestrictable::_blk_dual_restrictable
private

Flag for allowing dual restriction.

Definition at line 231 of file BlockRestrictable.h.

Referenced by initializeBlockRestrictable().

FEProblemBase* BlockRestrictable::_blk_feproblem
private
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 225 of file BlockRestrictable.h.

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

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

Pointer to the MaterialData class for this object.

Definition at line 203 of file BlockRestrictable.h.

Referenced by hasBlockMaterialProperty(), and initializeBlockRestrictable().

MooseMesh* BlockRestrictable::_blk_mesh
private

Pointer to Mesh.

Definition at line 237 of file BlockRestrictable.h.

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

const std::string& BlockRestrictable::_blk_name
private

Name of the object.

Definition at line 249 of file BlockRestrictable.h.

Referenced by checkVariable(), and initializeBlockRestrictable().

THREAD_ID BlockRestrictable::_blk_tid
private

Thread id for this object.

Definition at line 246 of file BlockRestrictable.h.

Referenced by initializeBlockRestrictable().

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

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

Definition at line 228 of file BlockRestrictable.h.

Referenced by blocks(), and initializeBlockRestrictable().

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

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

Definition at line 243 of file BlockRestrictable.h.

Referenced by initializeBlockRestrictable().

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

An empty set for referencing when boundary_ids is not included.

Definition at line 240 of file BlockRestrictable.h.


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