OGS
PythonSourceTerm.cpp
Go to the documentation of this file.
1
11#include "PythonSourceTerm.h"
12
13#include <algorithm>
14#include <pybind11/pybind11.h>
15
16#include <iostream>
17
18#include "FlushStdoutGuard.h"
23
24namespace ProcessLib
25{
26namespace SourceTerms
27{
28namespace Python
29{
31 std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
32 PythonStData&& source_term_data, unsigned const integration_order,
33 unsigned const global_dim, bool const flush_stdout)
34 : SourceTerm(std::move(source_term_dof_table)),
35 _source_term_data(std::move(source_term_data)),
36 _flush_stdout(flush_stdout)
37{
42 NumLib::IntegrationOrder{integration_order},
45}
46
47void PythonSourceTerm::integrate(const double t, const GlobalVector& x,
48 GlobalVector& b, GlobalMatrix* Jac) const
49{
50 FlushStdoutGuard guard(_flush_stdout);
51
52 try
53 {
57 }
58 catch (pybind11::error_already_set const& e)
59 {
60 OGS_FATAL("Error evaluating source term in Python: {}", e.what());
61 }
62}
63
64} // namespace Python
65} // namespace SourceTerms
66} // namespace ProcessLib
#define OGS_FATAL(...)
Definition Error.h:26
Global vector based on Eigen vector.
Definition EigenVector.h:25
bool isAxiallySymmetric() const
Definition Mesh.h:137
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
std::unique_ptr< NumLib::LocalToGlobalIndexMap > const _source_term_dof_table
Definition SourceTerm.h:35
virtual void assemble(std::size_t const source_term_element_id, NumLib::LocalToGlobalIndexMap const &source_term_dof_table, double const t, const GlobalVector &x, GlobalVector &b, GlobalMatrix *Jac)=0
PythonSourceTerm(std::unique_ptr< NumLib::LocalToGlobalIndexMap > source_term_dof_table, PythonStData &&source_term_data, unsigned const integration_order, unsigned const global_dim, bool const flush_stdout)
std::vector< std::unique_ptr< PythonSourceTermLocalAssemblerInterface > > _local_assemblers
Local assemblers for all elements of the source term mesh.
void integrate(const double t, GlobalVector const &x, GlobalVector &b, GlobalMatrix *jac) const override
PythonStData _source_term_data
Auxiliary data used by the local assemblers.
void createLocalAssemblersPython(const unsigned dimension, std::vector< MeshLib::Element * > const &mesh_elements, NumLib::LocalToGlobalIndexMap const &dof_table, std::vector< std::unique_ptr< LocalAssemblerInterface > > &local_assemblers, NumLib::IntegrationOrder const integration_order, ExtraCtorArgs &&... extra_ctor_args)
static void executeMemberOnDereferenced(Method method, Container const &container, Args &&... args)
MeshLib::Mesh const & bc_or_st_mesh
The domain, where this BC or ST will be applied.
Definition BcOrStData.h:46