OGS
PhaseFieldIrreversibleDamageOracleBoundaryCondition.cpp
Go to the documentation of this file.
1
12
13#include <algorithm>
14#include <vector>
15
16#include "BaseLib/ConfigTree.h"
17#include "BaseLib/Logging.h"
18
19namespace ProcessLib
20{
22 const double /*t*/, GlobalVector const& /*x*/,
24{
25 bc_values.ids.clear();
26 bc_values.values.clear();
27
28 // convert mesh node ids to global index for the given component
29 bc_values.ids.reserve(bc_values.ids.size() + _bc_values.ids.size());
30 bc_values.values.reserve(bc_values.values.size() +
31 _bc_values.values.size());
32
33 std::copy(_bc_values.ids.begin(), _bc_values.ids.end(),
34 std::back_inserter(bc_values.ids));
35 std::copy(_bc_values.values.begin(), _bc_values.values.end(),
36 std::back_inserter(bc_values.values));
37}
38
39// update new values and corresponding indices.
41 const double /*t*/, std::vector<GlobalVector*> const& x,
42 int const process_id)
43{
44 // phase-field variable is considered irreversible if it loses more than 95%
45 // of the stiffness, which is a widely used threshold.
46 double irreversibleDamage = 0.05;
47
48 _bc_values.ids.clear();
49 _bc_values.values.clear();
50
51 auto const mesh_id = _mesh.getID();
52 auto const& nodes = _mesh.getNodes();
53 for (auto const* n : nodes)
54 {
55 std::size_t node_id = n->getID();
57 const auto g_idx =
59
60 if (g_idx < 0)
61 {
62 continue;
63 }
64
65 if ((*x[process_id])[g_idx] <= irreversibleDamage)
66 {
67 _bc_values.ids.emplace_back(g_idx);
68 _bc_values.values.emplace_back(0.0);
69 }
70 }
71}
72
73std::unique_ptr<PhaseFieldIrreversibleDamageOracleBoundaryCondition>
75 BaseLib::ConfigTree const& config,
76 NumLib::LocalToGlobalIndexMap const& dof_table, MeshLib::Mesh const& mesh,
77 int const variable_id, int const component_id)
78{
79 DBUG(
80 "Constructing PhaseFieldIrreversibleDamageOracleBoundaryCondition from "
81 "config.");
84 "type", "PhaseFieldIrreversibleDamageOracleBoundaryCondition");
85
86 return std::make_unique<
88 dof_table, mesh, variable_id, component_id);
89}
90
91} // namespace ProcessLib
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
void checkConfigParameter(std::string const &param, std::string_view const value) const
Global vector based on Eigen vector.
Definition EigenVector.h:25
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:106
std::size_t getID() const
Get id of the mesh.
Definition Mesh.h:121
GlobalIndexType getGlobalIndex(MeshLib::Location const &l, int const variable_id, int const component_id) const
void getEssentialBCValues(const double t, const GlobalVector &x, NumLib::IndexValueVector< GlobalIndexType > &bc_values) const override
Writes the values of essential BCs to bc_values.
void preTimestep(const double t, std::vector< GlobalVector * > const &x, int const process_id) override
std::unique_ptr< PhaseFieldIrreversibleDamageOracleBoundaryCondition > createPhaseFieldIrreversibleDamageOracleBoundaryCondition(BaseLib::ConfigTree const &config, NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, int const variable_id, int const component_id)
std::vector< IndexType > ids
std::vector< double > values