Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
MFEMBoundaryCondition.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 #ifdef MFEM_ENABLED
11 
12 #include "MFEMBoundaryCondition.h"
13 #include "MFEMProblem.h"
14 #include "libmesh/ignore_warnings.h"
15 #include "mfem/miniapps/common/mesh_extras.hpp"
16 #include "libmesh/restore_warnings.h"
17 
20 {
22  params.addClassDescription("Base class for applying boundary conditions to MFEM problems.");
23  params.registerBase("BoundaryCondition");
24  // Create user-facing 'boundary' input for restricting inheriting object to boundaries
25  // MFEM uses the boundary -1 to signify every sideset
26  params.addParam<std::vector<BoundaryName>>(
27  "boundary",
28  {"-1"},
29  "The list of boundaries (ids) from the mesh where this boundary condition applies. "
30  "Defaults to applying BC on all boundaries.");
31  params.addParam<VariableName>("variable", "Variable on which to apply the boundary condition");
32  return params;
33 }
34 
36  : MFEMGeneralUserObject(parameters),
37  _test_var_name(getParam<VariableName>("variable")),
38  _boundary_names(getParam<std::vector<BoundaryName>>("boundary")),
39  _bdr_attributes(_boundary_names.size())
40 {
41  for (unsigned int i = 0; i < _boundary_names.size(); ++i)
42  {
43  _bdr_attributes[i] = std::stoi(_boundary_names[i]);
44  }
45  mfem::ParMesh & mesh(*getMFEMProblem()
46  .getProblemData()
47  .gridfunctions.GetRef(_test_var_name)
48  .ParFESpace()
49  ->GetParMesh());
50  mfem::common::AttrToMarker(mesh.bdr_attributes.Max(), _bdr_attributes, _bdr_markers);
51 }
52 
53 #endif
static InputParameters validParams()
static InputParameters validParams()
MeshBase & mesh
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
MFEMBoundaryCondition(const InputParameters &parameters)
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
mfem::Array< int > _bdr_markers
const VariableName & _test_var_name
MFEMProblem & getMFEMProblem()
Returns a reference to the MFEMProblem instance.
const std::vector< BoundaryName > & _boundary_names
mfem::Array< int > _bdr_attributes
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
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...