OGS 6.2.0-97-g4a610c866
DirichletBoundaryConditionAuxiliaryFunctions.cpp
Go to the documentation of this file.
1 
14 
15 #include "MeshLib/Mesh.h"
16 #include "MeshLib/Node.h"
17 
20 #include "ParameterLib/Parameter.h"
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  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(bc_values.ids.size() + nodes_in_bc_mesh.size());
74  bc_values.values.reserve(bc_values.values.size() + nodes_in_bc_mesh.size());
75  for (auto const* const node : nodes_in_bc_mesh)
76  {
77  auto const id = node->getID();
78  pos.setNodeID(node->getID());
79  // TODO: that might be slow, but only done once
80  auto const global_index = dof_table_boundary.getGlobalIndex(
81  {bc_mesh.getID(), MeshLib::MeshItemType::Node, id}, variable_id,
82  component_id);
83  if (global_index == NumLib::MeshComponentMap::nop)
84  {
85  continue;
86  }
87  // For the DDC approach (e.g. with PETSc option), the negative
88  // index of global_index means that the entry by that index is a ghost
89  // one, which should be dropped. Especially for PETSc routines
90  // MatZeroRows and MatZeroRowsColumns, which are called to apply the
91  // Dirichlet BC, the negative index is not accepted like other matrix or
92  // vector PETSc routines. Therefore, the following if-condition is
93  // applied.
94  if (global_index >= 0)
95  {
96  bc_values.ids.emplace_back(global_index);
97  bc_values.values.emplace_back(parameter(t, pos).front());
98  }
99  }
100 }
101 } // namespace ProcessLib
void setNodeID(std::size_t node_id)
Definition of the Node class.
std::size_t getID() const
Get id of the mesh.
Definition: Mesh.h:123
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:134
Definition of the Mesh class.
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:102
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)
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
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
std::vector< double > values
static NUMLIB_EXPORT GlobalIndexType const nop