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 
19 namespace 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));
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 ((*x[process_id])[node_id] <= irreversibleDamage)
61  {
62  _bc_values.ids.emplace_back(g_idx);
63  _bc_values.values.emplace_back(0.0);
64  }
65  }
66 }
67 
68 std::unique_ptr<PhaseFieldIrreversibleDamageOracleBoundaryCondition>
70  BaseLib::ConfigTree const& config,
71  NumLib::LocalToGlobalIndexMap const& dof_table, MeshLib::Mesh const& mesh,
72  int const variable_id, int const component_id)
73 {
74  DBUG(
75  "Constructing PhaseFieldIrreversibleDamageOracleBoundaryCondition from "
76  "config.");
78  config.checkConfigParameter(
79  "type", "PhaseFieldIrreversibleDamageOracleBoundaryCondition");
80 
81  return std::make_unique<
83  dof_table, mesh, variable_id, component_id);
84 }
85 
86 } // namespace ProcessLib
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
void checkConfigParameter(std::string const &param, T const &value) const
Global vector based on Eigen vector.
Definition: EigenVector.h:26
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition: Mesh.h:95
std::size_t getID() const
Get id of the mesh.
Definition: Mesh.h:110
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
void copy(PETScVector const &x, PETScVector &y)
Definition: LinAlg.cpp:37
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