OGS
PythonSourceTerm.cpp
Go to the documentation of this file.
1
11#include "PythonSourceTerm.h"
12
13#include <pybind11/pybind11.h>
14
15#include <iostream>
16
17#include "FlushStdoutGuard.h"
22
23namespace ProcessLib
24{
25namespace SourceTerms
26{
27namespace Python
28{
30 std::unique_ptr<NumLib::LocalToGlobalIndexMap> source_term_dof_table,
31 PythonStData&& source_term_data, unsigned const integration_order,
32 unsigned const global_dim, bool const flush_stdout)
33 : SourceTerm(std::move(source_term_dof_table)),
34 _source_term_data(std::move(source_term_data)),
35 _flush_stdout(flush_stdout)
36{
41 NumLib::IntegrationOrder{integration_order},
44}
45
46void PythonSourceTerm::integrate(const double t, const GlobalVector& x,
47 GlobalVector& b, GlobalMatrix* Jac) const
48{
49 FlushStdoutGuard guard(_flush_stdout);
50
51 try
52 {
56 }
57 catch (pybind11::error_already_set const& e)
58 {
59 OGS_FATAL("Error evaluating source term in Python: {}", e.what());
60 }
61}
62
63} // namespace Python
64} // namespace SourceTerms
65} // 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