OGS 6.1.0-1699-ge946d4c5f
DirichletBoundaryConditionAuxiliaryFunctions.cpp
Go to the documentation of this file.
1 
14 
15 #include "MeshLib/Mesh.h"
16 #include "MeshLib/Node.h"
17 
21 
22 namespace ProcessLib
23 {
25  MeshLib::Mesh const& bc_mesh,
26  NumLib::LocalToGlobalIndexMap const& dof_table_bulk,
27  int const variable_id,
28  int const component_id)
29 {
30  if (variable_id >=
31  static_cast<int>(dof_table_bulk.getNumberOfVariables()) ||
32  component_id >=
33  dof_table_bulk.getNumberOfVariableComponents(variable_id))
34  {
35  OGS_FATAL(
36  "Variable id or component id too high. Actual values: (%d, "
37  "%d), maximum values: (%d, %d).",
38  variable_id, component_id, dof_table_bulk.getNumberOfVariables(),
39  dof_table_bulk.getNumberOfVariableComponents(variable_id));
40  }
41 
42  if (!bc_mesh.getProperties().existsPropertyVector<std::size_t>(
43  "bulk_node_ids"))
44  {
45  OGS_FATAL(
46  "The required bulk node ids map does not exist in the boundary "
47  "mesh '%s'.",
48  bc_mesh.getName().c_str());
49  }
50 
51  DBUG(
52  "Found %d nodes for Dirichlet BCs for the variable %d and "
53  "component "
54  "%d",
55  bc_mesh.getNodes().size(), variable_id, component_id);
56 }
57 
59  Parameter<double> const& parameter, MeshLib::Mesh const& bc_mesh,
60  std::vector<MeshLib::Node*> const& nodes_in_bc_mesh,
61  NumLib::LocalToGlobalIndexMap const& dof_table_boundary,
62  int const variable_id, int const component_id, const double t,
63  GlobalVector const& /*x*/,
65 {
66  SpatialPosition pos;
67 
68  bc_values.ids.clear();
69  bc_values.values.clear();
70 
71  // convert mesh node ids to global index for the given component
72  bc_values.ids.reserve(bc_values.ids.size() + nodes_in_bc_mesh.size());
73  bc_values.values.reserve(bc_values.values.size() + nodes_in_bc_mesh.size());
74  for (auto const* const node : nodes_in_bc_mesh)
75  {
76  auto const id = node->getID();
77  pos.setNodeID(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  continue;
84  // For the DDC approach (e.g. with PETSc option), the negative
85  // index of global_index means that the entry by that index is a ghost
86  // one, which should be dropped. Especially for PETSc routines
87  // MatZeroRows and MatZeroRowsColumns, which are called to apply the
88  // Dirichlet BC, the negative index is not accepted like other matrix or
89  // vector PETSc routines. Therefore, the following if-condition is
90  // applied.
91  if (global_index >= 0)
92  {
93  bc_values.ids.emplace_back(global_index);
94  bc_values.values.emplace_back(parameter(t, pos).front());
95  }
96  }
97 }
98 } // end of name space
void getEssentialBCValuesLocal(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)
Definition of the Node class.
std::size_t getID() const
Get id of the mesh.
Definition: Mesh.h:120
int getNumberOfVariableComponents(int variable_id) const
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition: Mesh.h:105
MeshLib::Properties & getProperties()
Definition: Mesh.h:131
Definition of the Mesh class.
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:102
std::vector< IndexType > ids
void checkParametersOfDirichletBoundaryCondition(MeshLib::Mesh const &bc_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, int const variable_id, int const component_id)
GlobalIndexType getGlobalIndex(MeshLib::Location const &l, int const variable_id, int const component_id) const
bool existsPropertyVector(std::string const &name) const
Definition: Properties.h:79
void setNodeID(std::size_t node_id)
#define OGS_FATAL(fmt,...)
Definition: Error.h:71
std::vector< double > values
static NUMLIB_EXPORT GlobalIndexType const nop