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