https://mooseframework.inl.gov
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
MFEMBlockRestrictable Class Reference

Base class for construction of an object that is restricted to a subset of subdomains of the problem mesh. More...

#include <MFEMBlockRestrictable.h>

Inheritance diagram for MFEMBlockRestrictable:
[legend]

Public Member Functions

 MFEMBlockRestrictable (const InputParameters &parameters, const mfem::ParMesh &mfem_mesh)
 
mfem::Array< intsubdomainsToAttributes (const std::vector< SubdomainName > &subdomain_names)
 
std::vector< std::string > subdomainsToStrings (const std::vector< SubdomainName > &subdomain_names)
 
bool isSubdomainRestricted ()
 Returns a bool indicating if the object is restricted to a subset of subdomains. More...
 
const mfem::Array< int > & getSubdomainAttributes ()
 
mfem::Array< int > & getSubdomainMarkers ()
 
const mfem::ParMesh & getMesh () const
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Attributes

const mfem::ParMesh & _mfem_mesh
 Stores the names of the subdomains. More...
 
std::vector< SubdomainName > _subdomain_names
 Stores the names of the subdomains. More...
 
mfem::Array< int_subdomain_attributes
 Array storing subdomain attribute IDs for this object. More...
 
mfem::Array< int_subdomain_markers
 Boolean array indicating which subdomains are active in this object. More...
 

Detailed Description

Base class for construction of an object that is restricted to a subset of subdomains of the problem mesh.

Definition at line 23 of file MFEMBlockRestrictable.h.

Constructor & Destructor Documentation

◆ MFEMBlockRestrictable()

MFEMBlockRestrictable::MFEMBlockRestrictable ( const InputParameters parameters,
const mfem::ParMesh &  mfem_mesh 
)

Definition at line 29 of file MFEMBlockRestrictable.C.

31  : _mfem_mesh(mfem_mesh),
32  _subdomain_names(parameters.get<std::vector<SubdomainName>>("block")),
34 {
36  if (!_subdomain_attributes.IsEmpty())
37  mfem::common::AttrToMarker(
39 }
mfem::Array< int > subdomainsToAttributes(const std::vector< SubdomainName > &subdomain_names)
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
const mfem::ParMesh & _mfem_mesh
Stores the names of the subdomains.
std::vector< SubdomainName > _subdomain_names
Stores the names of the subdomains.
mfem::Array< int > _subdomain_markers
Boolean array indicating which subdomains are active in this object.
mfem::Array< int > _subdomain_attributes
Array storing subdomain attribute IDs for this object.

Member Function Documentation

◆ getMesh()

const mfem::ParMesh& MFEMBlockRestrictable::getMesh ( ) const
inline

Definition at line 38 of file MFEMBlockRestrictable.h.

Referenced by MFEMDomainSubMesh::buildSubMesh(), and subdomainsToAttributes().

38 { return _mfem_mesh; }
const mfem::ParMesh & _mfem_mesh
Stores the names of the subdomains.

◆ getSubdomainAttributes()

const mfem::Array<int>& MFEMBlockRestrictable::getSubdomainAttributes ( )
inline

Definition at line 36 of file MFEMBlockRestrictable.h.

Referenced by MFEMDomainSubMesh::buildSubMesh().

36 { return _subdomain_attributes; }
mfem::Array< int > _subdomain_attributes
Array storing subdomain attribute IDs for this object.

◆ getSubdomainMarkers()

mfem::Array<int>& MFEMBlockRestrictable::getSubdomainMarkers ( )
inline

Definition at line 37 of file MFEMBlockRestrictable.h.

37 { return _subdomain_markers; }
mfem::Array< int > _subdomain_markers
Boolean array indicating which subdomains are active in this object.

◆ isSubdomainRestricted()

bool MFEMBlockRestrictable::isSubdomainRestricted ( )
inline

Returns a bool indicating if the object is restricted to a subset of subdomains.

Definition at line 34 of file MFEMBlockRestrictable.h.

34 { return _subdomain_names.size(); }
std::vector< SubdomainName > _subdomain_names
Stores the names of the subdomains.

◆ subdomainsToAttributes()

mfem::Array< int > MFEMBlockRestrictable::subdomainsToAttributes ( const std::vector< SubdomainName > &  subdomain_names)

Definition at line 42 of file MFEMBlockRestrictable.C.

Referenced by MFEMBlockRestrictable(), and subdomainsToStrings().

43 {
44  mfem::Array<int> attributes(subdomain_names.size());
45  auto & mesh = getMesh();
46  std::transform(
47  subdomain_names.begin(),
48  subdomain_names.end(),
49  attributes.begin(),
50  [&mesh](const SubdomainName & subdomain) -> int
51  {
52  try
53  {
54  // Is this a block ID?
55  return std::stoi(subdomain);
56  }
57  catch (...)
58  {
59  // It was not
60  auto & subdomain_ids = mesh.attribute_sets.GetAttributeSet(subdomain);
61  if (subdomain_ids.Size() != 1)
62  mooseError(
63  "There should be a 1-to-1 correspondence between subdomain name and subdomain ID");
64  return subdomain_ids[0];
65  }
66  });
67  return attributes;
68 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:302
MeshBase & mesh
const mfem::ParMesh & getMesh() const

◆ subdomainsToStrings()

std::vector< std::string > MFEMBlockRestrictable::subdomainsToStrings ( const std::vector< SubdomainName > &  subdomain_names)

Definition at line 71 of file MFEMBlockRestrictable.C.

Referenced by MFEMGenericFunctorMaterial::MFEMGenericFunctorMaterial(), and MFEMGenericFunctorVectorMaterial::MFEMGenericFunctorVectorMaterial().

72 {
73  auto attributes = subdomainsToAttributes(subdomain_names);
74  std::vector<std::string> subdomain_attr_strings(subdomain_names.size());
75  for (const auto i : index_range(subdomain_names))
76  subdomain_attr_strings[i] = std::to_string(attributes[i]);
77  return subdomain_attr_strings;
78 }
mfem::Array< int > subdomainsToAttributes(const std::vector< SubdomainName > &subdomain_names)
auto index_range(const T &sizable)

◆ validParams()

InputParameters MFEMBlockRestrictable::validParams ( )
static

Definition at line 15 of file MFEMBlockRestrictable.C.

Referenced by MFEMFunctorMaterial::validParams(), MFEMDomainSubMesh::validParams(), and MFEMKernel::validParams().

16 {
17  // Create InputParameters object that will be appended to the parameters for the inheriting object
19  // Create user-facing 'boundary' input for restricting inheriting object to boundaries
20  // MFEM uses the boundary -1 to signify every sideset
21  params.addParam<std::vector<SubdomainName>>("block",
22  {},
23  "The list of subdomains (names or ids) that this "
24  "object will be restricted to. Leave empty to apply "
25  "to all subdomains.");
26  return params;
27 }
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters emptyInputParameters()
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...

Member Data Documentation

◆ _mfem_mesh

const mfem::ParMesh& MFEMBlockRestrictable::_mfem_mesh
protected

Stores the names of the subdomains.

Definition at line 42 of file MFEMBlockRestrictable.h.

Referenced by getMesh(), and MFEMBlockRestrictable().

◆ _subdomain_attributes

mfem::Array<int> MFEMBlockRestrictable::_subdomain_attributes
protected

Array storing subdomain attribute IDs for this object.

Definition at line 46 of file MFEMBlockRestrictable.h.

Referenced by getSubdomainAttributes(), and MFEMBlockRestrictable().

◆ _subdomain_markers

mfem::Array<int> MFEMBlockRestrictable::_subdomain_markers
protected

Boolean array indicating which subdomains are active in this object.

Definition at line 48 of file MFEMBlockRestrictable.h.

Referenced by getSubdomainMarkers(), and MFEMBlockRestrictable().

◆ _subdomain_names

std::vector<SubdomainName> MFEMBlockRestrictable::_subdomain_names
protected

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