39 template <
int spatial_dim,
typename AppliedDisplacementFunction>
40 void setVectorBCs(
const Domain& domain, std::vector<int> components, AppliedDisplacementFunction applied_displacement)
42 int field_dim = space_.GetVDim();
43 for (
auto component : components) {
44 SLIC_ERROR_IF(component >= field_dim || component < 0,
45 std::format(
"Trying to set boundary conditions on a field with dim {}, using component {}",
46 field_dim, component));
47 auto mfem_coefficient_function = [applied_displacement, component](
const mfem::Vector& X_mfem,
double t) {
48 auto X = make_tensor<spatial_dim>([&X_mfem](
int k) {
return X_mfem[k]; });
49 return applied_displacement(t, X)[component];
52 auto dof_list = domain.
dof_list(&space_);
54 space_.DofsToVDofs(
static_cast<int>(component), dof_list);
56 auto component_disp_bdr_coef_ = std::make_shared<mfem::FunctionCoefficient>(mfem_coefficient_function);
57 bcs_.
addEssential(dof_list, component_disp_bdr_coef_, space_,
static_cast<int>(component));
62 template <
int spatial_dim,
typename AppliedDisplacementFunction>
65 const int field_dim = space_.GetVDim();
66 std::vector<int> components(
static_cast<size_t>(field_dim));
67 for (
int component = 0; component < field_dim; ++component) {
68 components[
static_cast<size_t>(component)] = component;
70 setVectorBCs<spatial_dim>(domain, components, applied_displacement);
78 template <
int spatial_dim,
typename AppliedDisplacementFunction>
81 auto mfem_coefficient_function = [applied_displacement](
const mfem::Vector& X_mfem,
double t) {
82 auto X = make_tensor<spatial_dim>([&X_mfem](
int k) {
return X_mfem[k]; });
83 return applied_displacement(t, X);
86 auto dof_list = domain.
dof_list(&space_);
87 space_.DofsToVDofs(
static_cast<int>(0), dof_list);
89 auto component_disp_bdr_coef_ = std::make_shared<mfem::FunctionCoefficient>(mfem_coefficient_function);
90 bcs_.
addEssential(dof_list, component_disp_bdr_coef_, space_, 0);
94 template <
int spatial_dim>
97 setScalarBCs<spatial_dim>(domain, [](
auto,
auto) {
return 0.0; });
101 template <
int spatial_dim,
int field_dim>
108 template <
int spatial_dim,
int field_dim>
111 std::vector<int> components{component};
112 setVectorBCs<spatial_dim, field_dim>(domain, components);
116 template <
int spatial_dim,
int field_dim = spatial_dim>
119 SLIC_ERROR_IF(field_dim != space_.GetVDim(),
"Vector boundary condition field_dim does not match the fields vdim");
120 std::vector<int> components(
static_cast<size_t>(field_dim));
121 for (
int component = 0; component < field_dim; ++component) {
122 components[
static_cast<size_t>(component)] = component;
124 setFixedVectorBCs<spatial_dim, field_dim>(domain, components);
132 mfem::ParFiniteElementSpace& space_;
This file contains the declaration of the boundary condition manager class.
A container for the boundary condition information relating to a specific physics module.
void addEssential(const std::set< int > &ess_bdr, smith::GeneralCoefficient ess_bdr_coef, mfem::ParFiniteElementSpace &space, const std::optional< int > component={})
Set the essential boundary conditions from a list of boundary markers and a coefficient.
A generic class for setting Dirichlet boundary conditions on arbitrary physics.
void setFixedVectorBCs(const Domain &domain, std::vector< int > components)
Constrain the vector dofs over a domain corresponding to a subset of the vector components.
void setFixedScalarBCs(const Domain &domain)
Constrain the dofs of a scalar field over a domain.
DirichletBoundaryConditions(const mfem::ParMesh &mfem_mesh, mfem::ParFiniteElementSpace &space)
Construct from mfem::ParMesh.
void setFixedVectorBCs(const Domain &domain)
Constrain all the vector dofs over a domain.
void setScalarBCs(const Domain &domain, AppliedDisplacementFunction applied_displacement)
Specify time and space varying Dirichlet boundary conditions over a domain.
void setVectorBCs(const Domain &domain, std::vector< int > components, AppliedDisplacementFunction applied_displacement)
Specify time and space varying Dirichlet boundary conditions over a domain.
void setVectorBCs(const Domain &domain, AppliedDisplacementFunction applied_displacement)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setFixedVectorBCs(const Domain &domain, int component)
Constrain the dofs of a scalar field over a domain.
const smith::BoundaryConditionManager & getBoundaryConditionManager() const
Return the smith BoundaryConditionManager.
Helper class for constructing a mesh consistent with Smith.
Accelerator functionality.
mfem::ParFiniteElementSpace & space(FieldState field)
Get the space from the primal field of a field states.
a class for representing a geometric region that can be used for integration
mfem::Array< int > dof_list(const fes_t *fes) const
get mfem degree of freedom list for a given FiniteElementSpace
Arbitrary-rank tensor class.