Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
boundary_condition_manager.hpp
Go to the documentation of this file.
1 // Copyright (c) Lawrence Livermore National Security, LLC and
2 // other Smith Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
13 #pragma once
14 
15 #include <memory>
16 #include <set>
17 #include <optional>
18 #include <vector>
19 
22 
23 namespace smith {
24 
29  public:
35  explicit BoundaryConditionManager(const mfem::ParMesh& mesh) : num_attrs_(mesh.bdr_attributes.Max()) {}
36 
45  void addEssential(const std::set<int>& ess_bdr, smith::GeneralCoefficient ess_bdr_coef,
46  mfem::ParFiniteElementSpace& space, const std::optional<int> component = {});
47 
56  void addEssential(const mfem::Array<int>& local_dofs, std::shared_ptr<mfem::Coefficient> ess_bdr_coef,
57  mfem::ParFiniteElementSpace& space, std::optional<int> component = {});
58 
66  void addEssentialByTrueDofs(const mfem::Array<int>& true_dofs, std::shared_ptr<mfem::VectorCoefficient> ess_bdr_coef,
67  mfem::ParFiniteElementSpace& space);
68 
73  const mfem::Array<int>& allEssentialTrueDofs() const
74  {
75  if (!all_dofs_valid_) {
76  updateAllDofs();
77  }
78  return all_true_dofs_;
79  }
80 
85  const mfem::Array<int>& allEssentialLocalDofs() const
86  {
87  if (!all_dofs_valid_) {
88  updateAllDofs();
89  }
90  return all_local_dofs_;
91  }
92 
100  std::unique_ptr<mfem::HypreParMatrix> eliminateAllEssentialDofsFromMatrix(mfem::HypreParMatrix& matrix) const
101  {
102  return std::unique_ptr<mfem::HypreParMatrix>(matrix.EliminateRowsCols(allEssentialTrueDofs()));
103  }
104 
108  std::vector<BoundaryCondition>& essentials() { return ess_bdr_; }
109 
113  const std::vector<BoundaryCondition>& essentials() const { return ess_bdr_; }
114 
115  private:
119  void updateAllDofs() const;
120 
124  const int num_attrs_;
125 
129  std::vector<BoundaryCondition> ess_bdr_;
130 
136  std::set<int> attrs_in_use_;
137 
142  mutable mfem::Array<int> all_true_dofs_;
143 
148  mutable mfem::Array<int> all_local_dofs_;
149 
153  mutable bool all_dofs_valid_ = false;
154 };
155 
156 } // namespace smith
This file contains the declaration of the boundary condition class.
A container for the boundary condition information relating to a specific physics module.
const mfem::Array< int > & allEssentialTrueDofs() const
Returns all the true degrees of freedom associated with all the essential BCs.
void addEssentialByTrueDofs(const mfem::Array< int > &true_dofs, std::shared_ptr< mfem::VectorCoefficient > ess_bdr_coef, mfem::ParFiniteElementSpace &space)
BoundaryConditionManager(const mfem::ParMesh &mesh)
Construct a new Boundary Condition Manager object.
std::unique_ptr< mfem::HypreParMatrix > eliminateAllEssentialDofsFromMatrix(mfem::HypreParMatrix &matrix) const
Eliminates all essential BCs from a matrix.
std::vector< BoundaryCondition > & essentials()
Accessor for the essential BC objects.
const std::vector< BoundaryCondition > & essentials() const
Accessor for the essential BC objects.
const mfem::Array< int > & allEssentialLocalDofs() const
Returns all the local degrees of freedom associated with all the essential BCs.
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.
This file contains the declaration of structure that manages the MFEM objects that make up the state ...
Accelerator functionality.
Definition: smith.cpp:36