OGS
GenericNaturalBoundaryCondition-impl.h
Go to the documentation of this file.
1 
13 
14 namespace ProcessLib
15 {
16 template <typename BoundaryConditionData,
17  template <typename /* shp fct */, int /* global dim */>
18  class LocalAssemblerImplementation>
19 template <typename Data>
20 GenericNaturalBoundaryCondition<BoundaryConditionData,
21  LocalAssemblerImplementation>::
23  unsigned const integration_order, unsigned const shapefunction_order,
24  NumLib::LocalToGlobalIndexMap const& dof_table_bulk,
25  int const variable_id, int const component_id,
26  unsigned const global_dim, MeshLib::Mesh const& bc_mesh, Data&& data)
27  : _data(std::forward<Data>(data)), _bc_mesh(bc_mesh)
28 {
29  static_assert(std::is_same_v<typename std::decay_t<BoundaryConditionData>,
30  typename std::decay_t<Data>>,
31  "Type mismatch between declared and passed BC data.");
32 
33  // check basic data consistency
34  if (variable_id >=
35  static_cast<int>(dof_table_bulk.getNumberOfVariables()) ||
36  component_id >=
37  dof_table_bulk.getNumberOfVariableComponents(variable_id))
38  {
39  OGS_FATAL(
40  "Variable id or component id too high. Actual values: ({:d}, "
41  "{:d}), "
42  "maximum values: ({:d}, {:d}).",
43  variable_id, component_id, dof_table_bulk.getNumberOfVariables(),
44  dof_table_bulk.getNumberOfVariableComponents(variable_id));
45  }
46 
47  if (!_bc_mesh.getProperties().template existsPropertyVector<std::size_t>(
48  "bulk_node_ids"))
49  {
50  OGS_FATAL(
51  "The required bulk node ids map does not exist in the boundary "
52  "mesh '{:s}'.",
53  _bc_mesh.getName());
54  }
55 
56  std::vector<MeshLib::Node*> const& bc_nodes = _bc_mesh.getNodes();
57  DBUG(
58  "Found {:d} nodes for Natural BCs for the variable {:d} and component "
59  "{:d}",
60  bc_nodes.size(), variable_id, component_id);
61 
62  MeshLib::MeshSubset bc_mesh_subset(_bc_mesh, bc_nodes);
63 
64  // Create local DOF table from the BC mesh subset for the given variable and
65  // component id.
66  _dof_table_boundary = dof_table_bulk.deriveBoundaryConstrainedMap(
67  variable_id, {component_id}, std::move(bc_mesh_subset));
68 
70  LocalAssemblerImplementation>(
71  global_dim, _bc_mesh.getElements(), *_dof_table_boundary,
72  shapefunction_order, _local_assemblers,
73  NumLib::IntegrationOrder{integration_order},
74  _bc_mesh.isAxiallySymmetric(), _data);
75 }
76 
77 template <typename BoundaryConditionData,
78  template <typename /* shp fct */, int /* global dim */>
79  class LocalAssemblerImplementation>
80 void GenericNaturalBoundaryCondition<BoundaryConditionData,
81  LocalAssemblerImplementation>::
82  applyNaturalBC(const double t,
83  std::vector<GlobalVector*> const& x,
84  int const process_id,
85  GlobalMatrix& K,
86  GlobalVector& b,
87  GlobalMatrix* Jac)
88 {
91  _local_assemblers, *_dof_table_boundary, t, x, process_id, K, b, Jac);
92 }
93 
94 } // namespace ProcessLib
#define OGS_FATAL(...)
Definition: Error.h:26
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:29
A subset of nodes on a single mesh.
Definition: MeshSubset.h:26
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
static const double t
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, NumLib::IntegrationOrder const integration_order, ExtraCtorArgs &&... extra_ctor_args)
static void executeMemberOnDereferenced(Method method, Container const &container, Args &&... args)