OGS 6.2.0-97-g4a610c866
CreateSourceTerm.cpp
Go to the documentation of this file.
1 
10 #include "CreateSourceTerm.h"
11 
12 #include "CreateNodalSourceTerm.h"
14 #ifdef OGS_USE_PYTHON
16 #endif
17 #include "SourceTerm.h"
18 #include "SourceTermConfig.h"
19 
20 namespace ProcessLib
21 {
22 std::unique_ptr<SourceTerm> createSourceTerm(
23  const SourceTermConfig& config,
24  const NumLib::LocalToGlobalIndexMap& dof_table_bulk,
25  const MeshLib::Mesh& source_term_mesh, const int variable_id,
26  const unsigned integration_order, const unsigned shapefunction_order,
27  std::vector<std::unique_ptr<ParameterLib::ParameterBase>> const& parameters)
28 {
30  auto const type = config.config.peekConfigParameter<std::string>("type");
31 
32  // check basic data consistency
33  if (variable_id >=
34  static_cast<int>(dof_table_bulk.getNumberOfVariables()) ||
35  *config.component_id >=
36  dof_table_bulk.getNumberOfVariableComponents(variable_id))
37  {
38  OGS_FATAL(
39  "Variable id or component id too high. Actual values: (%d, "
40  "%d), maximum values: (%d, %d).",
41  variable_id, *config.component_id,
42  dof_table_bulk.getNumberOfVariables(),
43  dof_table_bulk.getNumberOfVariableComponents(variable_id));
44  }
45 
46  if (!source_term_mesh.getProperties()
47  .template existsPropertyVector<std::size_t>("bulk_node_ids"))
48  {
49  OGS_FATAL(
50  "The required bulk node ids map does not exist in the "
51  "source term mesh '%s'.",
52  source_term_mesh.getName().c_str());
53  }
54  std::vector<MeshLib::Node*> const& source_term_nodes =
55  source_term_mesh.getNodes();
56  DBUG(
57  "Found %d nodes for source term at mesh '%s' for the variable %d and "
58  "component %d",
59  source_term_nodes.size(), source_term_mesh.getName().c_str(),
60  variable_id, *config.component_id);
61 
62  MeshLib::MeshSubset source_term_mesh_subset(source_term_mesh,
63  source_term_nodes);
64 
65 
66  if (type == "Nodal")
67  {
68  std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table_source_term(
69  dof_table_bulk.deriveBoundaryConstrainedMap(
70  variable_id, {*config.component_id},
71  std::move(source_term_mesh_subset)));
73  config.config, config.mesh, std::move(dof_table_source_term),
74  source_term_mesh.getID(), variable_id, *config.component_id,
75  parameters);
76  }
77 
78  if (type == "Volumetric")
79  {
80  std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table_source_term(
81  dof_table_bulk.deriveBoundaryConstrainedMap(
82  variable_id, {*config.component_id},
83  std::move(source_term_mesh_subset)));
85  config.config, config.mesh, std::move(dof_table_source_term),
86  parameters, integration_order, shapefunction_order);
87  }
88 
89  if (type == "Python")
90  {
91 #ifdef OGS_USE_PYTHON
92  std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table_source_term(
93  dof_table_bulk.deriveBoundaryConstrainedMap(
94  std::move(source_term_mesh_subset)));
95 
97  config.config, config.mesh, std::move(dof_table_source_term),
98  source_term_mesh.getID(), variable_id, *config.component_id,
99  integration_order, shapefunction_order,
100  source_term_mesh.getDimension());
101 #else
102  OGS_FATAL("OpenGeoSys has not been built with Python support.");
103 #endif
104  }
105 
106 
107  OGS_FATAL("Unknown source term type: `%s'.", type.c_str());
108 }
109 } // namespace ProcessLib
std::unique_ptr< SourceTerm > createVolumetricSourceTerm(BaseLib::ConfigTree const &config, MeshLib::Mesh const &source_term_mesh, std::unique_ptr< NumLib::LocalToGlobalIndexMap > source_term_dof_table, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, unsigned const shapefunction_order)
boost::optional< int > const component_id
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
std::unique_ptr< SourceTerm > createSourceTerm(const SourceTermConfig &config, const NumLib::LocalToGlobalIndexMap &dof_table_bulk, const MeshLib::Mesh &source_term_mesh, const int variable_id, const unsigned integration_order, const unsigned shapefunction_order, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
MeshLib::Properties & getProperties()
Definition: Mesh.h:134
std::unique_ptr< SourceTerm > createPythonSourceTerm(BaseLib::ConfigTree const &config, MeshLib::Mesh const &source_term_mesh, std::unique_ptr< NumLib::LocalToGlobalIndexMap > dof_table, std::size_t const bulk_mesh_id, int const variable_id, int const component_id, unsigned const integration_order, unsigned const shapefunction_order, unsigned const global_dim)
const std::string getName() const
Get name of the mesh.
Definition: Mesh.h:102
MeshLib::Mesh const & mesh
T peekConfigParameter(std::string const &param) const
BaseLib::ConfigTree config
LocalToGlobalIndexMap * deriveBoundaryConstrainedMap(int const variable_id, std::vector< int > const &component_ids, MeshLib::MeshSubset &&new_mesh_subset) const
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
Definition: Mesh.h:81
std::unique_ptr< SourceTerm > createNodalSourceTerm(BaseLib::ConfigTree const &config, MeshLib::Mesh const &st_mesh, std::unique_ptr< NumLib::LocalToGlobalIndexMap > dof_table, std::size_t const source_term_mesh_id, const int variable_id, const int component_id, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters)
#define OGS_FATAL(fmt,...)
Definition: Error.h:63
A subset of nodes on a single mesh.
Definition: MeshSubset.h:26