OGS
PhaseFieldIrreversibleDamageOracleBoundaryCondition.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
5
6#include <algorithm>
7#include <vector>
8
10#include "BaseLib/Logging.h"
11
12namespace ProcessLib
13{
15 const double /*t*/, GlobalVector const& /*x*/,
17{
18 bc_values.ids.clear();
19 bc_values.values.clear();
20
21 // convert mesh node ids to global index for the given component
22 bc_values.ids.reserve(bc_values.ids.size() + _bc_values.ids.size());
23 bc_values.values.reserve(bc_values.values.size() +
24 _bc_values.values.size());
25
26 std::copy(_bc_values.ids.begin(), _bc_values.ids.end(),
27 std::back_inserter(bc_values.ids));
28 std::copy(_bc_values.values.begin(), _bc_values.values.end(),
29 std::back_inserter(bc_values.values));
30}
31
32// update new values and corresponding indices.
34 const double /*t*/, std::vector<GlobalVector*> const& x,
35 int const process_id)
36{
37 // phase-field variable is considered irreversible if it loses more than 95%
38 // of the stiffness, which is a widely used threshold.
39 double irreversibleDamage = 0.05;
40
41 _bc_values.ids.clear();
42 _bc_values.values.clear();
43
44 for (auto const& l :
46 {
47 const auto g_idx =
48 _dof_table.getGlobalIndex(l, _variable_id, _component_id);
49
50 if (g_idx < 0)
51 {
52 continue;
53 }
54
55 if ((*x[process_id])[g_idx] <= irreversibleDamage)
56 {
57 _bc_values.ids.emplace_back(g_idx);
58 _bc_values.values.emplace_back(0.0);
59 }
60 }
61}
62
64 BaseLib::ConfigTree const& config)
65{
66 DBUG("Parsing PhaseFieldIrreversibleDamageOracleBoundaryCondition.");
67
70 "type", "PhaseFieldIrreversibleDamageOracleBoundaryCondition");
71}
72
73std::unique_ptr<PhaseFieldIrreversibleDamageOracleBoundaryCondition>
75 NumLib::LocalToGlobalIndexMap const& dof_table, MeshLib::Mesh const& mesh,
76 int const variable_id, int const component_id)
77{
78 DBUG("Constructing PhaseFieldIrreversibleDamageOracleBoundaryCondition.");
79
80 return std::make_unique<
82 dof_table, mesh, variable_id, component_id);
83}
84
85} // namespace ProcessLib
MathLib::EigenVector GlobalVector
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
void checkConfigParameter(std::string const &param, std::string_view const value) 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:227
void parsePhaseFieldIrreversibleDamageOracleBoundaryCondition(BaseLib::ConfigTree const &config)
std::unique_ptr< PhaseFieldIrreversibleDamageOracleBoundaryCondition > createPhaseFieldIrreversibleDamageOracleBoundaryCondition(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