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().existsPropertyVector<std::size_t>(
42  "bulk_node_ids"))
43  {
44  OGS_FATAL(
45  "The required bulk node ids map does not exist in the boundary "
46  "mesh '{:s}' or has the wrong data type (should be equivalent to "
47  "C++ data type std::size_t which is an unsigned integer of size "
48  "{:d} or UInt64 in vtk terminology).",
49  bc_mesh.getName(), sizeof(std::size_t));
50  }
51 
52  DBUG(
53  "Found {:d} nodes for Dirichlet BCs for the variable {:d} and "
54  "component {:d}",
55  bc_mesh.getNodes().size(), variable_id, component_id);
56 }
57 
59  ParameterLib::Parameter<double> const& parameter,
60  MeshLib::Mesh const& bc_mesh,
61  std::vector<MeshLib::Node*> const& nodes_in_bc_mesh,
62  NumLib::LocalToGlobalIndexMap const& dof_table_boundary,
63  int const variable_id, int const component_id, const double t,
64  GlobalVector const& /*x*/,
66 {
68 
69  bc_values.ids.clear();
70  bc_values.values.clear();
71 
72  // convert mesh node ids to global index for the given component
73  bc_values.ids.reserve(nodes_in_bc_mesh.size());
74  bc_values.values.reserve(nodes_in_bc_mesh.size());
75  for (auto const* const node : nodes_in_bc_mesh)
76  {
77  auto const id = node->getID();
78  // TODO: that might be slow, but only done once
79  auto const global_index = dof_table_boundary.getGlobalIndex(
80  {bc_mesh.getID(), MeshLib::MeshItemType::Node, id}, variable_id,
81  component_id);
82  if (global_index == NumLib::MeshComponentMap::nop)
83  {
84  continue;
85  }
86  // For the DDC approach (e.g. with PETSc option), the negative
87  // index of global_index means that the entry by that index is a ghost
88  // one, which should be dropped. Especially for PETSc routines
89  // MatZeroRows and MatZeroRowsColumns, which are called to apply the
90  // Dirichlet BC, the negative index is not accepted like other matrix or
91  // vector PETSc routines. Therefore, the following if-condition is
92  // applied.
93  if (global_index >= 0)
94  {
95  pos.setNodeID(id);
96  pos.setCoordinates(*node);
97  bc_values.ids.emplace_back(global_index);
98  bc_values.values.emplace_back(parameter(t, pos).front());
99  }
100  }
101 }
102 } // 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: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
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:92
Properties & getProperties()
Definition: Mesh.h:123
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)
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