13 #include <pybind11/pybind11.h>
25 std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table,
26 int const variable_id,
int const component_id,
27 unsigned const integration_order,
unsigned const shapefunction_order,
28 unsigned const global_dim)
30 DBUG(
"Constructing PythonSourceTerm from config.");
34 auto const source_term_object =
41 pybind11::object scope =
42 pybind11::module::import(
"__main__").attr(
"__dict__");
44 if (!scope.contains(source_term_object))
47 "Function `{:s}' is not defined in the python script file, or "
48 "there was no python script file specified.",
52 auto* source_term = scope[source_term_object.c_str()]
53 .cast<ProcessLib::SourceTerms::Python::
54 PythonSourceTermPythonSideInterface*>();
71 auto const global_component_id =
72 dof_table->getGlobalComponent(variable_id, component_id);
73 return std::make_unique<ProcessLib::SourceTerms::Python::PythonSourceTerm>(
76 source_term, global_component_id, source_term_mesh,
77 source_term_mesh.
getID()},
78 integration_order, shapefunction_order, global_dim, flush_stdout);
void DBUG(char const *fmt, Args const &... args)
Definition of the Mesh class.
void checkConfigParameter(std::string const ¶m, T const &value) const
T getConfigParameter(std::string const ¶m) const
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
std::size_t getID() const
Get id of the mesh.
std::size_t getNumberOfNodes() const
Get the number of nodes.
std::size_t getNumberOfElements() const
Get the number of elements.
std::unique_ptr< SourceTerm > createPythonSourceTerm(BaseLib::ConfigTree const &config, MeshLib::Mesh const &source_term_mesh, std::unique_ptr< NumLib::LocalToGlobalIndexMap > dof_table, int const variable_id, int const component_id, unsigned const integration_order, unsigned const shapefunction_order, unsigned const global_dim)
Groups data used by source terms, in particular by the local assemblers.