OGS
GenericNaturalBoundaryCondition-impl.h
Go to the documentation of this file.
1 
13 
14 namespace ProcessLib
15 {
16 template <typename BoundaryConditionData,
17  template <typename, typename, int> class LocalAssemblerImplementation>
18 template <typename Data>
19 GenericNaturalBoundaryCondition<BoundaryConditionData,
20  LocalAssemblerImplementation>::
21  GenericNaturalBoundaryCondition(
22  unsigned const integration_order, unsigned const shapefunction_order,
23  NumLib::LocalToGlobalIndexMap const& dof_table_bulk,
24  int const variable_id, int const component_id,
25  unsigned const global_dim, MeshLib::Mesh const& bc_mesh, Data&& data)
26  : _data(std::forward<Data>(data)), _bc_mesh(bc_mesh)
27 {
28  static_assert(std::is_same_v<typename std::decay_t<BoundaryConditionData>,
29  typename std::decay_t<Data>>,
30  "Type mismatch between declared and passed BC data.");
31 
32  // check basic data consistency
33  if (variable_id >=
34  static_cast<int>(dof_table_bulk.getNumberOfVariables()) ||
35  component_id >=
36  dof_table_bulk.getNumberOfVariableComponents(variable_id))
37  {
38  OGS_FATAL(
39  "Variable id or component id too high. Actual values: ({:d}, "
40  "{:d}), "
41  "maximum values: ({:d}, {:d}).",
42  variable_id, component_id, dof_table_bulk.getNumberOfVariables(),
43  dof_table_bulk.getNumberOfVariableComponents(variable_id));
44  }
45 
46  if (!_bc_mesh.getProperties().template existsPropertyVector<std::size_t>(
47  "bulk_node_ids"))
48  {
49  OGS_FATAL(
50  "The required bulk node ids map does not exist in the boundary "
51  "mesh '{:s}'.",
52  _bc_mesh.getName());
53  }
54 
55  std::vector<MeshLib::Node*> const& bc_nodes = _bc_mesh.getNodes();
56  DBUG(
57  "Found {:d} nodes for Natural BCs for the variable {:d} and component "
58  "{:d}",
59  bc_nodes.size(), variable_id, component_id);
60 
61  MeshLib::MeshSubset bc_mesh_subset(_bc_mesh, bc_nodes);
62 
63  // Create local DOF table from the BC mesh subset for the given variable and
64  // component id.
66  variable_id, {component_id}, std::move(bc_mesh_subset)));
67 
69  LocalAssemblerImplementation>(
71  shapefunction_order, _local_assemblers, _bc_mesh.isAxiallySymmetric(),
72  integration_order, _data);
73 }
74 
75 template <typename BoundaryConditionData,
76  template <typename, typename, int> class LocalAssemblerImplementation>
77 void GenericNaturalBoundaryCondition<BoundaryConditionData,
78  LocalAssemblerImplementation>::
79  applyNaturalBC(const double t,
80  std::vector<GlobalVector*> const& x,
81  int const process_id,
82  GlobalMatrix& K,
83  GlobalVector& b,
84  GlobalMatrix* Jac)
85 {
88  _local_assemblers, *_dof_table_boundary, t, x, process_id, K, b, Jac);
89 }
90 
91 } // namespace ProcessLib
#define OGS_FATAL(...)
Definition: Error.h:26
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
Global vector based on Eigen vector.
Definition: EigenVector.h:26
A subset of nodes on a single mesh.
Definition: MeshSubset.h:27
bool isAxiallySymmetric() const
Definition: Mesh.h:126
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition: Mesh.h:95
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition: Mesh.h:98
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:92
Properties & getProperties()
Definition: Mesh.h:123
int getNumberOfVariableComponents(int variable_id) const
LocalToGlobalIndexMap * deriveBoundaryConstrainedMap(int const variable_id, std::vector< int > const &component_ids, MeshLib::MeshSubset &&new_mesh_subset) const
virtual void assemble(std::size_t const id, NumLib::LocalToGlobalIndexMap const &dof_table_boundary, double const t, std::vector< GlobalVector * > const &x, int const process_id, GlobalMatrix &K, GlobalVector &b, GlobalMatrix *Jac)=0
MeshLib::Mesh const & _bc_mesh
A lower-dimensional mesh on which the boundary condition is defined.
BoundaryConditionData _data
Data used in the assembly of the specific boundary condition.
std::vector< std::unique_ptr< GenericNaturalBoundaryConditionLocalAssemblerInterface > > _local_assemblers
Local assemblers for each element of number of _elements.
std::unique_ptr< NumLib::LocalToGlobalIndexMap > _dof_table_boundary
void createLocalAssemblers(const unsigned dimension, std::vector< MeshLib::Element * > const &mesh_elements, NumLib::LocalToGlobalIndexMap const &dof_table, const unsigned shapefunction_order, std::vector< std::unique_ptr< LocalAssemblerInterface >> &local_assemblers, ExtraCtorArgs &&... extra_ctor_args)
static void executeMemberOnDereferenced(Method method, Container const &container, Args &&... args)