OGS
ReleaseNodalForce.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "ReleaseNodalForce.h"
5
7#include "MeshLib/Mesh.h"
10
11namespace ProcessLib
12{
14 int const variable_id,
15 MeshLib::Mesh const& boundary_mesh,
16 std::unique_ptr<NumLib::LocalToGlobalIndexMap>& dof_table,
17 ParameterLib::Parameter<double> const& time_decay_parameter)
18 : variable_id_(variable_id),
19 boundary_mesh_(boundary_mesh),
20 dof_table_(std::move(dof_table)),
21 time_decay_parameter_(time_decay_parameter)
22{
23}
24
26{
27 auto const& number_of_components =
28 dof_table_->getNumberOfVariableComponents(variable_id_);
29
31 {
32 return;
33 }
34
35 initial_release_nodal_force_.reserve(boundary_mesh_.getNumberOfNodes() *
36 number_of_components);
37
38 // Iterate over all nodes in the boundary mesh and set the initial
39 // released nodal.
40 for (auto const* node : boundary_mesh_.getNodes())
41 {
42 auto const node_id = node->getID();
43 MeshLib::Location const l{boundary_mesh_.getID(),
45 for (int component_id = 0; component_id < number_of_components;
46 ++component_id)
47 {
48 auto const global_index =
49 dof_table_->getGlobalIndex(l, variable_id_, component_id);
50 if (global_index == NumLib::MeshComponentMap::nop)
51 {
52 continue;
53 }
54 // For the DDC approach (e.g. with PETSc option), the negative
55 // index of global_index means that the entry by that index is
56 // a ghost one, which should be dropped. Especially for PETSc
57 // routines MatZeroRows and MatZeroRowsColumns, which are
58 // called to apply the Dirichlet BC, the negative index is not
59 // accepted like other matrix or vector PETSc routines.
60 // Therefore, the following if-condition is applied.
61 if (global_index >= 0) [[likely]]
62 {
63 global_indices_.push_back(global_index);
65 r_neq->get(global_index));
66 boundary_nodes_.push_back(node);
67 }
68 }
69 }
70}
71
73 std::vector<GlobalVector*> const& /*x*/,
74 int const /*process_id*/,
75 GlobalMatrix* /*K*/, GlobalVector& b,
76 GlobalMatrix* /*Jac*/)
77{
78 DBUG("Apply ReleaseNodalForce.");
79
81 {
82 return;
83 }
84
85 std::vector<double> release_values;
86 release_values.reserve(global_indices_.size());
87
88 for (std::size_t i = 0; i < global_indices_.size(); ++i)
89 {
91 auto const* node = boundary_nodes_[i];
92 pos.setNodeID(node->getID());
93 pos.setCoordinates(*node);
94
95 release_values.push_back(
96 -(1.0 - time_decay_parameter_(t, pos).front()) *
98 }
99
100 b.add(global_indices_, release_values);
101}
102
103} // namespace ProcessLib
MathLib::EigenMatrix GlobalMatrix
MathLib::EigenVector GlobalVector
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
void add(IndexType rowId, double v)
add entry
Definition EigenVector.h:70
double get(IndexType rowId) const
get entry
Definition EigenVector.h:52
static constexpr NUMLIB_EXPORT GlobalIndexType const nop
void setNodeID(std::size_t node_id)
void setCoordinates(MathLib::Point3d const &coordinates)
void applyNaturalBC(const double t, std::vector< GlobalVector * > const &x, int const process_id, GlobalMatrix *K, GlobalVector &b, GlobalMatrix *Jac) override
Applies the released nodal force boundary condition. This method scales the nodal forces by the relea...
std::vector< double > initial_release_nodal_force_
ParameterLib::Parameter< double > const & time_decay_parameter_
ReleaseNodalForce(int const variable_id, MeshLib::Mesh const &boundary_mesh, std::unique_ptr< NumLib::LocalToGlobalIndexMap > &dof_table, ParameterLib::Parameter< double > const &time_decay_parameter)
Constructs a released nodal force boundary condition.
std::vector< GlobalIndexType > global_indices_
MeshLib::Mesh const & boundary_mesh_
std::vector< MeshLib::Node const * > boundary_nodes_
void set(GlobalVector const *r_neq)
std::unique_ptr< NumLib::LocalToGlobalIndexMap > const dof_table_