OGS
CreateReleaseNodalForce.cpp
Go to the documentation of this file.
1
13
14#include <limits>
15#include <numeric>
16#include <range/v3/range/conversion.hpp>
17#include <range/v3/view/iota.hpp>
18
19#include "BaseLib/ConfigTree.h"
20#include "BoundaryCondition.h"
22#include "MeshLib/Mesh.h"
26#include "ParameterLib/Utils.h"
27#include "ReleaseNodalForce.h"
28
29namespace ProcessLib
30{
31std::unique_ptr<BoundaryCondition> createReleaseNodalForce(
32 unsigned const global_dim, int const variable_id,
33 BoundaryConditionConfig const& bc_config, MeshLib::Mesh const& bc_mesh,
34 NumLib::LocalToGlobalIndexMap const& dof_table_bulk,
35 std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
36{
37 DBUG("Create ReleaseNodalForce boundary condition.");
38
40 {
42 "The compensate_non_equilibrium_initial_residuum must be set for "
43 "the ReleaseNodalForce boundary condition.");
44 }
45
46 auto const& config = bc_config.config;
48 config.checkConfigParameter("type", "ReleaseNodalForce");
49
50 auto const parameter_name =
52 config.getConfigParameter<std::string>("time_decay_parameter");
53 DBUG("Using parameter {:s}", parameter_name);
54
55 auto const& time_decay_parameter = ParameterLib::findParameter<double>(
56 parameter_name, parameters, 1, &bc_mesh);
57
58 // In case of partitioned mesh the boundary could be empty, i.e. there
59 // is no boundary condition.
60#ifdef USE_PETSC
61 // This can be extracted to createBoundaryCondition() but then the
62 // config parameters are not read and will cause an error.
63 // TODO (naumov): Add a function to ConfigTree for skipping the tags of
64 // the subtree and move the code up in createBoundaryCondition().
65 if (bc_mesh.getDimension() == 0 && bc_mesh.getNumberOfNodes() == 0 &&
66 bc_mesh.getNumberOfElements() == 0)
67 {
68 return nullptr;
69 }
70#endif // USE_PETSC
71
72 if (bc_mesh.getDimension() >= global_dim)
73 {
75 "The dimension ({:d}) of the given boundary mesh '{:s}' is not "
76 "lower than the bulk dimension ({:d}).",
77 bc_mesh.getDimension(), bc_mesh.getName(), global_dim);
78 }
79
80 // Create component ids vector for the current variable.
81 auto const& number_of_components =
82 dof_table_bulk.getNumberOfVariableComponents(variable_id);
83 std::vector<int> component_ids =
84 ranges::views::iota(0, number_of_components) | ranges::to_vector;
85
86 // BC mesh subset creation
87 std::vector<MeshLib::Node*> const bc_nodes = bc_mesh.getNodes();
88 DBUG("Found {:d} nodes for Natural BCs for the variable {:d}",
89 bc_nodes.size(), variable_id);
90
91 MeshLib::MeshSubset bc_mesh_subset(bc_mesh, bc_nodes);
92
93 // Create local DOF table from the BC mesh subset for the given variable
94 // and component ids.
95 auto dof_table_boundary = dof_table_bulk.deriveBoundaryConstrainedMap(
96 variable_id, std::move(component_ids), std::move(bc_mesh_subset));
97
99 pos.setNodeID(0);
101 if (time_decay_parameter(0, pos).front() - 1.0 >
102 std::numeric_limits<double>::epsilon())
103 {
104 OGS_FATAL(
105 "The time_decay_parameter '{:s}' must be equal to 1.0 at t=0.0. "
106 "and decrease over time to 0. ",
107 parameter_name);
108 }
109
110 return std::make_unique<ReleaseNodalForce>(
111 variable_id, bc_mesh, dof_table_boundary, time_decay_parameter);
112}
113
114} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
Definition of the Mesh class.
void checkConfigParameter(std::string const &param, std::string_view const value) const
A subset of nodes on a single mesh.
Definition MeshSubset.h:26
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:108
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition Mesh.h:90
const std::string getName() const
Get name of the mesh.
Definition Mesh.h:105
std::size_t getNumberOfNodes() const
Get the number of nodes.
Definition Mesh.h:102
std::size_t getNumberOfElements() const
Get the number of elements.
Definition Mesh.h:99
int getNumberOfVariableComponents(int variable_id) const
std::unique_ptr< LocalToGlobalIndexMap > deriveBoundaryConstrainedMap(int const variable_id, std::vector< int > const &component_ids, MeshLib::MeshSubset &&new_mesh_subset) const
void setNodeID(std::size_t node_id)
void setCoordinates(MathLib::Point3d const &coordinates)
OGS_NO_DANGLING Parameter< ParameterDataType > & findParameter(std::string const &parameter_name, std::vector< std::unique_ptr< ParameterBase > > const &parameters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
Definition Utils.h:102
std::unique_ptr< BoundaryCondition > createReleaseNodalForce(unsigned const global_dim, int const variable_id, BoundaryConditionConfig const &bc_config, MeshLib::Mesh const &bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters)