Loading [MathJax]/extensions/MathMenu.js
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 for (auto const& l :
53 {
54 const auto g_idx =
56
57 if (g_idx < 0)
58 {
59 continue;
60 }
61
62 if ((*x[process_id])[g_idx] <= irreversibleDamage)
63 {
64 _bc_values.ids.emplace_back(g_idx);
65 _bc_values.values.emplace_back(0.0);
66 }
67 }
68}
69
70std::unique_ptr<PhaseFieldIrreversibleDamageOracleBoundaryCondition>
72 BaseLib::ConfigTree const& config,
73 NumLib::LocalToGlobalIndexMap const& dof_table, MeshLib::Mesh const& mesh,
74 int const variable_id, int const component_id)
75{
76 DBUG(
77 "Constructing PhaseFieldIrreversibleDamageOracleBoundaryCondition from "
78 "config.");
81 "type", "PhaseFieldIrreversibleDamageOracleBoundaryCondition");
82
83 return std::make_unique<
85 dof_table, mesh, variable_id, component_id);
86}
87
88} // 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
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
auto meshLocations(Mesh const &mesh, MeshItemType const item_type)
Definition Mesh.h:238
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