www.mooseframework.org
BlockRestrictable.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 // MOOSE includes
13 #include "InputParameters.h"
14 #include "ParallelUniqueId.h"
15 #include "MaterialData.h"
16 #include "MooseObject.h"
17 
18 #define usingBlockRestrictableMembers using BlockRestrictable::getBlockCoordSystem
19 
20 // Forward declarations
21 class BlockRestrictable;
22 class FEProblemBase;
23 class MooseMesh;
25 
26 template <>
28 
62 {
63 public:
69  BlockRestrictable(const MooseObject * moose_object);
70 
78  BlockRestrictable(const MooseObject * moose_object, const std::set<BoundaryID> & boundary_ids);
79 
84  virtual ~BlockRestrictable() {}
85 
94  const std::vector<SubdomainName> & blocks() const;
95 
100  unsigned int numBlocks() const;
101 
106  const virtual std::set<SubdomainID> & blockIDs() const;
107 
113  bool hasBlocks(const SubdomainName & name) const;
114 
120  bool hasBlocks(const std::vector<SubdomainName> & names) const;
121 
127  bool hasBlocks(const SubdomainID & id) const;
128 
134  bool hasBlocks(const std::vector<SubdomainID> & ids) const;
135 
142  bool hasBlocks(const std::set<SubdomainID> & ids) const;
143 
151  bool isBlockSubset(const std::set<SubdomainID> & ids) const;
152 
160  bool isBlockSubset(const std::vector<SubdomainID> & ids) const;
161 
174  template <typename T>
175  bool hasBlockMaterialProperty(const std::string & prop_name);
176 
181  const std::set<SubdomainID> & meshBlockIDs() const;
182 
187  virtual bool blockRestricted() const;
188 
195  void checkVariable(const MooseVariableFEBase & variable) const;
196 
197 protected:
199  std::shared_ptr<MaterialData> _blk_material_data;
200 
206  virtual bool hasBlockMaterialPropertyHelper(const std::string & prop_name);
207 
211  void initializeBlockRestrictable(const MooseObject * moose_object);
212 
218 
219 private:
221  std::set<SubdomainID> _blk_ids;
222 
224  std::vector<SubdomainName> _blocks;
225 
228 
231 
234 
236  const std::set<BoundaryID> _empty_boundary_ids;
237 
239  const std::set<BoundaryID> & _boundary_ids;
240 
243 
245  const std::string & _blk_name;
246 };
247 
248 template <typename T>
249 bool
250 BlockRestrictable::hasBlockMaterialProperty(const std::string & prop_name)
251 {
252  mooseAssert(_blk_material_data != NULL, "MaterialData pointer is not defined");
253  return hasBlockMaterialPropertyHelper(prop_name) &&
254  _blk_material_data->haveProperty<T>(prop_name);
255 }
256 
unsigned int numBlocks() const
Return the number of blocks for this object.
const bool _blk_dual_restrictable
Flag for allowing dual restriction.
InputParameters validParams< BlockRestrictable >()
Moose::CoordinateSystemType getBlockCoordSystem()
Check if the blocks this object operates on all have the same coordinate system, and if so return it...
FEProblemBase * _blk_feproblem
Pointer to FEProblemBase.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
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.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
std::shared_ptr< MaterialData > _blk_material_data
Pointer to the MaterialData class for this object.
bool isBlockSubset(const std::set< SubdomainID > &ids) const
Test if the class block ids are a subset of the supplied objects.
void initializeBlockRestrictable(const MooseObject *moose_object)
An initialization routine needed for dual constructors.
virtual ~BlockRestrictable()
Destructor: does nothing but needs to be marked as virtual since this class defines virtual functions...
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:42
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
BlockRestrictable(const MooseObject *moose_object)
Class constructor Populates the &#39;block&#39; input parameters, see the general class documentation for det...
THREAD_ID _blk_tid
Thread id for this object.
bool hasBlockMaterialProperty(const std::string &prop_name)
Check if a material property is valid for all blocks of this object.
std::vector< SubdomainName > _blocks
Vector the block names supplied by the user via the input file.
subdomain_id_type SubdomainID
CoordinateSystemType
Definition: MooseTypes.h:556
const std::vector< SubdomainName > & blocks() const
Return the block names for this object.
const std::set< BoundaryID > _empty_boundary_ids
An empty set for referencing when boundary_ids is not included.
An interface that restricts an object to subdomains via the &#39;blocks&#39; input parameter.
const std::set< SubdomainID > & meshBlockIDs() const
Return all of the SubdomainIDs for the mesh.
virtual bool hasBlockMaterialPropertyHelper(const std::string &prop_name)
A helper method to allow the Material object to specialize the behavior of hasBlockMaterialProperty.
const std::set< BoundaryID > & _boundary_ids
Reference to the boundary_ids, defaults to an empty set if not provided.
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
std::set< SubdomainID > _blk_ids
Set of block ids supplied by the user via the input file (for error reporting)
void checkVariable(const MooseVariableFEBase &variable) const
Helper for checking that the ids for this object are in agreement with the variables on the supplied ...
const std::string & _blk_name
Name of the object.
MooseMesh * _blk_mesh
Pointer to Mesh.
unsigned int THREAD_ID
Definition: MooseTypes.h:161