OGS
DirichletBoundaryConditionAuxiliaryFunctions.cpp
Go to the documentation of this file.
1 
14 
15 #include "MeshLib/Mesh.h"
16 #include "MeshLib/Node.h"
19 #include "ParameterLib/Parameter.h"
20 
21 namespace ProcessLib
22 {
24  MeshLib::Mesh const& bc_mesh,
25  NumLib::LocalToGlobalIndexMap const& dof_table_bulk,
26  int const variable_id,
27  int const component_id)
28 {
29  if (variable_id >=
30  static_cast<int>(dof_table_bulk.getNumberOfVariables()) ||
31  component_id >=
32  dof_table_bulk.getNumberOfVariableComponents(variable_id))
33  {
34  OGS_FATAL(
35  "Variable id or component id too high. Actual values: ({:d}, "
36  "{:d}), maximum values: ({:d}, {:d}).",
37  variable_id, component_id, dof_table_bulk.getNumberOfVariables(),
38  dof_table_bulk.getNumberOfVariableComponents(variable_id));
39  }
40 
41  if (!bc_mesh.getProperties().hasPropertyVector("bulk_node_ids"))
42  {
43  OGS_FATAL(
44  "The required bulk node ids map does not exist in the boundary "
45  "mesh '{:s}'.",
46  bc_mesh.getName());
47  }
48 
49  if (!bc_mesh.getProperties().existsPropertyVector<std::size_t>(
50  "bulk_node_ids"))
51  {
52  OGS_FATAL(
53  "The required bulk node ids map exist in the boundary mesh '{:s}' "
54  "but has wrong data type (should be equivalent to C++ data type "
55  "std::size_t which is an unsigned integer of size {:d} or UInt64 "
56  "in vtk terminology).",
57  bc_mesh.getName(), sizeof(std::size_t));
58  }
59 
60  DBUG(
61  "Found {:d} nodes for Dirichlet BCs for the variable {:d} and "
62  "component {:d}",
63  bc_mesh.getNodes().size(), variable_id, component_id);
64 }
65 
67  ParameterLib::Parameter<double> const& parameter,
68  MeshLib::Mesh const& bc_mesh,
69  std::vector<MeshLib::Node*> const& nodes_in_bc_mesh,
70  NumLib::LocalToGlobalIndexMap const& dof_table_boundary,
71  int const variable_id, int const component_id, const double t,
72  GlobalVector const& /*x*/,
74 {
76 
77  bc_values.ids.clear();
78  bc_values.values.clear();
79 
80  // convert mesh node ids to global index for the given component
81  bc_values.ids.reserve(nodes_in_bc_mesh.size());
82  bc_values.values.reserve(nodes_in_bc_mesh.size());
83  for (auto const* const node : nodes_in_bc_mesh)
84  {
85  auto const id = node->getID();
86  // TODO: that might be slow, but only done once
87  auto const global_index = dof_table_boundary.getGlobalIndex(
88  {bc_mesh.getID(), MeshLib::MeshItemType::Node, id}, variable_id,
89  component_id);
90  if (global_index == NumLib::MeshComponentMap::nop)
91  {
92  continue;
93  }
94  // For the DDC approach (e.g. with PETSc option), the negative
95  // index of global_index means that the entry by that index is a ghost
96  // one, which should be dropped. Especially for PETSc routines
97  // MatZeroRows and MatZeroRowsColumns, which are called to apply the
98  // Dirichlet BC, the negative index is not accepted like other matrix or
99  // vector PETSc routines. Therefore, the following if-condition is
100  // applied.
101  if (global_index >= 0)
102  {
103  pos.setNodeID(id);
104  pos.setCoordinates(*node);
105  bc_values.ids.emplace_back(global_index);
106  bc_values.values.emplace_back(parameter(t, pos).front());
107  }
108  }
109 }
110 } // namespace ProcessLib
Defines functions that are shared by DirichletBoundaryCondition and DirichletBoundaryConditionWithinT...
#define OGS_FATAL(...)
Definition: Error.h:26
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27
Definition of the Mesh class.
Definition of the Node class.
Global vector based on Eigen vector.
Definition: EigenVector.h:28
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
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:92
Properties & getProperties()
Definition: Mesh.h:123
bool hasPropertyVector(std::string const &name) const
Definition: Properties.cpp:30
bool existsPropertyVector(std::string const &name) const
GlobalIndexType getGlobalIndex(MeshLib::Location const &l, int const variable_id, int const component_id) const
int getNumberOfVariableComponents(int variable_id) const
static NUMLIB_EXPORT GlobalIndexType const nop
void setNodeID(std::size_t node_id)
void setCoordinates(MathLib::TemplatePoint< double, 3 > const &coordinates)
static const double t
void getEssentialBCValuesLocal(ParameterLib::Parameter< double > const &parameter, MeshLib::Mesh const &bc_mesh, std::vector< MeshLib::Node * > const &nodes_in_bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_boundary, int const variable_id, int const component_id, const double t, GlobalVector const &, NumLib::IndexValueVector< GlobalIndexType > &bc_values)
void checkParametersOfDirichletBoundaryCondition(MeshLib::Mesh const &bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, int const variable_id, int const component_id)
std::vector< IndexType > ids
std::vector< double > values