OGS
PythonBoundaryCondition.h
Go to the documentation of this file.
1
11#pragma once
12
18#include "Utils/BcOrStData.h"
19
20namespace ProcessLib
21{
22class ProcessVariable;
23
29
30struct PythonBcData final
32 PythonBoundaryConditionPythonSideInterface>
33{
39 getFlagAndFluxAndDFlux(double const t, std::array<double, 3> const coords,
40 std::vector<double> const& prim_vars_data) const
41 {
42 auto [flag, flux, dFlux] =
43 bc_or_st_object->getFlux(t, coords, prim_vars_data);
44
46 {
47 // getFlux() is not overridden in Python, so we can skip the
48 // whole BC assembly (i.e., for all boundary elements).
50 }
51
52 return {flag, flux, std::move(dFlux)};
53 }
54};
55
58{
59public:
61 PythonBcData&& bc_data,
62 unsigned const integration_order,
63 bool const flush_stdout,
64 unsigned const bulk_mesh_dimension,
65 NumLib::LocalToGlobalIndexMap const& dof_table_bulk);
66
68 const double t, const GlobalVector& x,
69 NumLib::IndexValueVector<GlobalIndexType>& bc_values) const override;
70
71 void applyNaturalBC(const double t, std::vector<GlobalVector*> const& x,
72 int const process_id, GlobalMatrix* K, GlobalVector& b,
73 GlobalMatrix* Jac) override;
74
75private:
84 void collectPrimaryVariables(std::vector<double>& primary_variables,
85 MeshLib::Node const& boundary_node,
86 GlobalVector const& x) const;
87
90 GlobalIndexType getDofIdx(std::size_t const boundary_node_id) const;
91
94 GlobalIndexType getDofIdx(std::size_t const boundary_node_id, int const var,
95 int const comp) const;
96
100 GlobalVector const& x, int const var, int const comp,
101 MeshLib::Node const& boundary_node) const;
102
105
107 std::unique_ptr<NumLib::LocalToGlobalIndexMap> _dof_table_boundary;
108
110 std::vector<std::unique_ptr<PythonBoundaryConditionLocalAssemblerInterface>>
112
116 bool const _flush_stdout;
117};
118
120std::unique_ptr<PythonBoundaryCondition> createPythonBoundaryCondition(
121 BaseLib::ConfigTree const& config, MeshLib::Mesh const& boundary_mesh,
122 NumLib::LocalToGlobalIndexMap const& dof_table_bulk,
123 MeshLib::Mesh const& bulk_mesh, int const variable_id,
124 int const component_id, unsigned const integration_order,
125 unsigned const shapefunction_order,
126 std::vector<std::reference_wrapper<ProcessVariable>> const&
127 all_process_variables_for_this_process);
128
129} // namespace ProcessLib
GlobalMatrix::IndexType GlobalIndexType
Global vector based on Eigen vector.
Definition EigenVector.h:25
virtual std::tuple< bool, double, std::vector< double > > getFlux(double, std::array< double, 3 >, std::vector< double > const &) const
A boundary condition whose values are computed by a Python script.
std::unique_ptr< NumLib::LocalToGlobalIndexMap > _dof_table_boundary
Local dof table for the boundary mesh.
double interpolateToHigherOrderNode(GlobalVector const &x, int const var, int const comp, MeshLib::Node const &boundary_node) const
PythonBcData _bc_data
Auxiliary data used by the local assemblers.
void applyNaturalBC(const double t, std::vector< GlobalVector * > const &x, int const process_id, GlobalMatrix *K, GlobalVector &b, GlobalMatrix *Jac) override
std::vector< std::unique_ptr< PythonBoundaryConditionLocalAssemblerInterface > > _local_assemblers
Local assemblers for all elements of the boundary mesh.
void getEssentialBCValues(const double t, const GlobalVector &x, NumLib::IndexValueVector< GlobalIndexType > &bc_values) const override
Writes the values of essential BCs to bc_values.
GlobalIndexType getDofIdx(std::size_t const boundary_node_id) const
void collectPrimaryVariables(std::vector< double > &primary_variables, MeshLib::Node const &boundary_node, GlobalVector const &x) const
PythonBoundaryCondition(PythonBcData &&bc_data, unsigned const integration_order, bool const flush_stdout, unsigned const bulk_mesh_dimension, NumLib::LocalToGlobalIndexMap const &dof_table_bulk)
std::unique_ptr< PythonBoundaryCondition > createPythonBoundaryCondition(BaseLib::ConfigTree const &config, MeshLib::Mesh const &boundary_mesh, NumLib::LocalToGlobalIndexMap const &dof_table_bulk, MeshLib::Mesh const &bulk_mesh, int const variable_id, int const component_id, unsigned const integration_order, unsigned const shapefunction_order, std::vector< std::reference_wrapper< ProcessVariable > > const &all_process_variables_for_this_process)
Creates a new PythonBoundaryCondition object.
ProcessLib::BoundaryConditionAndSourceTerm::Python::FlagAndFluxAndDFlux getFlagAndFluxAndDFlux(double const t, std::array< double, 3 > const coords, std::vector< double > const &prim_vars_data) const