https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
MFEMBoundaryRestrictable Class Reference

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

#include <MFEMBoundaryRestrictable.h>

Inheritance diagram for MFEMBoundaryRestrictable:
[legend]

Public Member Functions

 MFEMBoundaryRestrictable (const InputParameters &parameters, const mfem::ParMesh &mfem_mesh)
 
mfem::Array< int > boundariesToAttributes (const InputParameters &parameters)
 Converts the boundary names and IDs to mesh attributes, checking that the mesh has them.
 
std::vector< std::string > boundariesToStrings ()
 
bool isBoundaryRestricted () const
 Returns a bool indicating if the object is restricted to a subset of boundaries.
 
const mfem::Array< int > & getBoundaryAttributes ()
 
mfem::Array< int > & getBoundaryMarkers ()
 
const mfem::ParMesh & getMesh ()
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Attributes

const mfem::ParMesh & _mfem_mesh
 Stores the names of the boundaries.
 
std::vector< BoundaryName > _boundary_names
 Stores the names of the boundaries.
 
mfem::Array< int > _boundary_attributes
 Array storing boundary attribute IDs for this object.
 
mfem::Array< int > _boundary_markers
 Boolean array indicating which boundaries are active in this object.
 

Detailed Description

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

Definition at line 23 of file MFEMBoundaryRestrictable.h.

Constructor & Destructor Documentation

◆ MFEMBoundaryRestrictable()

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

Definition at line 27 of file MFEMBoundaryRestrictable.C.

29 : _mfem_mesh(mfem_mesh),
30 _boundary_names(parameters.get<std::vector<BoundaryName>>("boundary")),
32 _boundary_markers(_mfem_mesh.bdr_attributes.IsEmpty()
33 ? mfem::Array<int>()
34 : mfem::AttributeSets::AttrToMarker(_mfem_mesh.bdr_attributes.Max(),
35 _boundary_attributes.IsEmpty()
36 ? _mfem_mesh.bdr_attributes
38{
39}
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.
mfem::Array< int > _boundary_attributes
Array storing boundary attribute IDs for this object.
std::vector< BoundaryName > _boundary_names
Stores the names of the boundaries.
mfem::Array< int > _boundary_markers
Boolean array indicating which boundaries are active in this object.
mfem::Array< int > boundariesToAttributes(const InputParameters &parameters)
Converts the boundary names and IDs to mesh attributes, checking that the mesh has them.
const mfem::ParMesh & _mfem_mesh
Stores the names of the boundaries.

Member Function Documentation

◆ boundariesToAttributes()

mfem::Array< int > MFEMBoundaryRestrictable::boundariesToAttributes ( const InputParameters &  parameters)

Converts the boundary names and IDs to mesh attributes, checking that the mesh has them.

Definition at line 42 of file MFEMBoundaryRestrictable.C.

43{
44 mfem::Array<int> attributes;
45 auto & mesh = getMesh();
46
47 for (const BoundaryName & boundary_name : _boundary_names)
48 {
49 try
50 {
51 // Is this a boundary ID?
52 const int attribute_id = std::stoi(boundary_name);
53 attributes.Append(attribute_id);
54 }
55 catch (...)
56 {
57 // It was not
58 if (!mesh.bdr_attribute_sets.AttributeSetExists(boundary_name))
59 parameters.paramError("boundary", "the mesh has no boundary named '", boundary_name, "'.");
60 auto & subdomain_ids = mesh.bdr_attribute_sets.GetAttributeSet(boundary_name);
61 for (const auto & subdomain_id : subdomain_ids)
62 attributes.Append(subdomain_id);
63 }
64 }
65
66 for (const auto attribute : attributes)
67 if (mesh.bdr_attributes.Find(attribute) == -1)
68 parameters.paramError("boundary", "the mesh has no boundary with ID ", attribute, ".");
69 return attributes;
70}
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
void paramError(const std::string &param, Args... args) const
Emits a parameter error prefixed with the parameter location and object information if available.
const mfem::ParMesh & getMesh()
MeshBase & mesh

◆ boundariesToStrings()

std::vector< std::string > MFEMBoundaryRestrictable::boundariesToStrings ( )

Definition at line 73 of file MFEMBoundaryRestrictable.C.

74{
75 const auto & attrs = _boundary_attributes;
76 std::vector<std::string> strs(attrs.Size());
77 std::transform(attrs.begin(), attrs.end(), strs.begin(), [](int n) { return std::to_string(n); });
78 return strs;
79}

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

◆ getBoundaryAttributes()

const mfem::Array< int > & MFEMBoundaryRestrictable::getBoundaryAttributes ( )
inline

Definition at line 37 of file MFEMBoundaryRestrictable.h.

37{ return _boundary_attributes; }

Referenced by MFEMBoundarySubMesh::buildSubMesh().

◆ getBoundaryMarkers()

mfem::Array< int > & MFEMBoundaryRestrictable::getBoundaryMarkers ( )
inline

◆ getMesh()

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

Definition at line 39 of file MFEMBoundaryRestrictable.h.

39{ return _mfem_mesh; }

Referenced by boundariesToAttributes(), and MFEMBoundarySubMesh::buildSubMesh().

◆ isBoundaryRestricted()

bool MFEMBoundaryRestrictable::isBoundaryRestricted ( ) const
inline

◆ validParams()

InputParameters MFEMBoundaryRestrictable::validParams ( )
static

Definition at line 15 of file MFEMBoundaryRestrictable.C.

16{
17 // Create InputParameters object that will be appended to the parameters for the inheriting object
19 params.addParam<std::vector<BoundaryName>>(
20 "boundary",
21 {},
22 "The list of boundaries (names or ids) that this object will be restricted to. "
23 "Leave empty to apply to all boundaries.");
24 return params;
25}
InputParameters emptyInputParameters()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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.

Referenced by MFEMBoundaryCondition::validParams(), MFEMFunctorMaterial::validParams(), MFEMComplexScalarBoundaryIC::validParams(), MFEMScalarBoundaryIC::validParams(), MFEMVectorBoundaryFluxIntegralPostprocessor::validParams(), and MFEMBoundarySubMesh::validParams().

Member Data Documentation

◆ _boundary_attributes

mfem::Array<int> MFEMBoundaryRestrictable::_boundary_attributes
protected

Array storing boundary attribute IDs for this object.

Definition at line 47 of file MFEMBoundaryRestrictable.h.

Referenced by boundariesToStrings(), and getBoundaryAttributes().

◆ _boundary_markers

mfem::Array<int> MFEMBoundaryRestrictable::_boundary_markers
protected

Boolean array indicating which boundaries are active in this object.

Definition at line 49 of file MFEMBoundaryRestrictable.h.

Referenced by getBoundaryMarkers().

◆ _boundary_names

std::vector<BoundaryName> MFEMBoundaryRestrictable::_boundary_names
protected

Stores the names of the boundaries.

Definition at line 45 of file MFEMBoundaryRestrictable.h.

Referenced by boundariesToAttributes(), and isBoundaryRestricted().

◆ _mfem_mesh

const mfem::ParMesh& MFEMBoundaryRestrictable::_mfem_mesh
protected

Stores the names of the boundaries.

Definition at line 43 of file MFEMBoundaryRestrictable.h.

Referenced by getMesh().


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