OGS
ProcessLib::SourceTerms::Python::PythonSourceTerm Class Referencefinal

Detailed Description

A source term whose values are computed by a Python script.

Definition at line 44 of file PythonSourceTerm.h.

#include <PythonSourceTerm.h>

Inheritance diagram for ProcessLib::SourceTerms::Python::PythonSourceTerm:
[legend]
Collaboration diagram for ProcessLib::SourceTerms::Python::PythonSourceTerm:
[legend]

Public Member Functions

 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)
 
void integrate (const double t, GlobalVector const &x, GlobalVector &b, GlobalMatrix *jac) const override
 
- Public Member Functions inherited from ProcessLib::SourceTerm
 SourceTerm (std::unique_ptr< NumLib::LocalToGlobalIndexMap > source_term_dof_table)
 
virtual ~SourceTerm ()=default
 

Private Attributes

PythonStData _source_term_data
 Auxiliary data used by the local assemblers.
 
std::vector< std::unique_ptr< PythonSourceTermLocalAssemblerInterface > > _local_assemblers
 Local assemblers for all elements of the source term mesh.
 
bool const _flush_stdout
 

Additional Inherited Members

- Protected Attributes inherited from ProcessLib::SourceTerm
std::unique_ptr< NumLib::LocalToGlobalIndexMap > const _source_term_dof_table
 

Constructor & Destructor Documentation

◆ PythonSourceTerm()

ProcessLib::SourceTerms::Python::PythonSourceTerm::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 )
explicit

Definition at line 30 of file PythonSourceTerm.cpp.

34 : SourceTerm(std::move(source_term_dof_table)),
35 _source_term_data(std::move(source_term_data)),
36 _flush_stdout(flush_stdout)
37{
39 PythonSourceTermLocalAssembler>(
42 NumLib::IntegrationOrder{integration_order},
45}
bool isAxiallySymmetric() const
Definition Mesh.h:137
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
SourceTerm(std::unique_ptr< NumLib::LocalToGlobalIndexMap > source_term_dof_table)
Definition SourceTerm.h:23
std::unique_ptr< NumLib::LocalToGlobalIndexMap > const _source_term_dof_table
Definition SourceTerm.h:35
std::vector< std::unique_ptr< PythonSourceTermLocalAssemblerInterface > > _local_assemblers
Local assemblers for all elements of the source term mesh.
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)
MeshLib::Mesh const & bc_or_st_mesh
The domain, where this BC or ST will be applied.
Definition BcOrStData.h:46

References _local_assemblers, _source_term_data, ProcessLib::SourceTerm::_source_term_dof_table, ProcessLib::BoundaryConditionAndSourceTerm::Python::BcOrStData< BcOrStPythonSideInterface >::bc_or_st_mesh, ProcessLib::BoundaryConditionAndSourceTerm::createLocalAssemblersPython(), MeshLib::Mesh::getElements(), and MeshLib::Mesh::isAxiallySymmetric().

Member Function Documentation

◆ integrate()

void ProcessLib::SourceTerms::Python::PythonSourceTerm::integrate ( const double t,
GlobalVector const & x,
GlobalVector & b,
GlobalMatrix * jac ) const
overridevirtual

Implements ProcessLib::SourceTerm.

Definition at line 47 of file PythonSourceTerm.cpp.

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}
#define OGS_FATAL(...)
Definition Error.h:26
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
static void executeMemberOnDereferenced(Method method, Container const &container, Args &&... args)

References _flush_stdout, _local_assemblers, ProcessLib::SourceTerm::_source_term_dof_table, ProcessLib::SourceTerms::Python::PythonSourceTermLocalAssemblerInterface::assemble(), NumLib::SerialExecutor::executeMemberOnDereferenced(), and OGS_FATAL.

Member Data Documentation

◆ _flush_stdout

bool const ProcessLib::SourceTerms::Python::PythonSourceTerm::_flush_stdout
private

Whether or not to flush standard output before and after each call to Python code. Ensures right order of output messages and therefore simplifies debugging.

Definition at line 66 of file PythonSourceTerm.h.

Referenced by integrate().

◆ _local_assemblers

std::vector<std::unique_ptr<PythonSourceTermLocalAssemblerInterface> > ProcessLib::SourceTerms::Python::PythonSourceTerm::_local_assemblers
private

Local assemblers for all elements of the source term mesh.

Definition at line 61 of file PythonSourceTerm.h.

Referenced by PythonSourceTerm(), and integrate().

◆ _source_term_data

PythonStData ProcessLib::SourceTerms::Python::PythonSourceTerm::_source_term_data
private

Auxiliary data used by the local assemblers.

Definition at line 57 of file PythonSourceTerm.h.

Referenced by PythonSourceTerm().


The documentation for this class was generated from the following files: