19 std::unique_ptr<NumLib::LocalToGlobalIndexMap> dof_table,
20 int const variable_id,
int const component_id,
21 unsigned const integration_order,
unsigned const shapefunction_order,
22 unsigned const global_dim,
23 std::vector<std::reference_wrapper<ProcessVariable>>
const&
24 all_process_variables_for_this_process)
26 DBUG(
"Constructing PythonSourceTerm from config.");
30 auto const source_term_object =
37 pybind11::object scope =
38 pybind11::module::import(
"__main__").attr(
"__dict__");
40 if (!scope.contains(source_term_object))
43 "Function `{:s}' is not defined in the python script file, or "
44 "there was no python script file specified.",
48 auto* source_term = scope[source_term_object.c_str()]
49 .cast<ProcessLib::SourceTerms::Python::
50 PythonSourceTermPythonSideInterface*>();
67 auto const global_component_id =
68 dof_table->getGlobalComponent(variable_id, component_id);
69 return std::make_unique<ProcessLib::SourceTerms::Python::PythonSourceTerm>(
72 {source_term, global_component_id, source_term_mesh,
73 all_process_variables_for_this_process, shapefunction_order}},
74 integration_order, global_dim, flush_stdout);
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, std::vector< std::reference_wrapper< ProcessVariable > > const &all_process_variables_for_this_process)