OGS
ProcessLib::HeatTransportBHE::HeatTransportBHEProcess Class Referencefinal

Detailed Description

Definition at line 24 of file HeatTransportBHEProcess.h.

#include <HeatTransportBHEProcess.h>

Inheritance diagram for ProcessLib::HeatTransportBHE::HeatTransportBHEProcess:
[legend]
Collaboration diagram for ProcessLib::HeatTransportBHE::HeatTransportBHEProcess:
[legend]

Public Member Functions

 HeatTransportBHEProcess (std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > &&process_variables, HeatTransportBHEProcessData &&process_data, SecondaryVariableCollection &&secondary_variables)
 
- Public Member Functions inherited from ProcessLib::Process
 Process (std::string name_, MeshLib::Mesh &mesh, std::unique_ptr< AbstractJacobianAssembler > &&jacobian_assembler, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > &&process_variables, SecondaryVariableCollection &&secondary_variables, const bool use_monolithic_scheme=true)
 
void preTimestep (std::vector< GlobalVector * > const &x, const double t, const double delta_t, const int process_id)
 Preprocessing before starting assembly for new timestep.
 
void postTimestep (std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, const double t, const double delta_t, int const process_id)
 Postprocessing after a complete timestep.
 
void postNonLinearSolver (std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, const double t, double const dt, int const process_id)
 
void preIteration (const unsigned iter, GlobalVector const &x) final
 
void computeSecondaryVariable (double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_prev, int const process_id)
 compute secondary variables for the coupled equations or for output.
 
NumLib::IterationResult postIteration (GlobalVector const &x) final
 
void initialize (std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
 
void setInitialConditions (std::vector< GlobalVector * > &process_solutions, std::vector< GlobalVector * > const &process_solutions_prev, double const t, int const process_id)
 
MathLib::MatrixSpecifications getMatrixSpecifications (const int process_id) const override
 
void updateDeactivatedSubdomains (double const time, const int process_id)
 
virtual bool isMonolithicSchemeUsed () const
 
virtual void extrapolateIntegrationPointValuesToNodes (const double, std::vector< GlobalVector * > const &, std::vector< GlobalVector * > &)
 
void preAssemble (const double t, double const dt, GlobalVector const &x) final
 
void assemble (const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b) final
 
void assembleWithJacobian (const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, GlobalMatrix &Jac) final
 
void preOutput (const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id)
 
std::vector< NumLib::IndexValueVector< GlobalIndexType > > const * getKnownSolutions (double const t, GlobalVector const &x, int const process_id) const final
 
virtual NumLib::LocalToGlobalIndexMap const & getDOFTable (const int) const
 
MeshLib::MeshgetMesh () const
 
std::vector< std::reference_wrapper< ProcessVariable > > const & getProcessVariables (const int process_id) const
 
std::vector< std::size_t > const & getActiveElementIDs () const
 
SecondaryVariableCollection const & getSecondaryVariables () const
 
std::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > const & getIntegrationPointWriters () const
 
virtual Eigen::Vector3d getFlux (std::size_t, MathLib::Point3d const &, double const, std::vector< GlobalVector * > const &) const
 
virtual void solveReactionEquation (std::vector< GlobalVector * > &, std::vector< GlobalVector * > const &, double const, double const, NumLib::EquationSystem &, int const)
 
- Public Member Functions inherited from ProcessLib::SubmeshAssemblySupport
virtual std::vector< std::string > initializeAssemblyOnSubmeshes (std::vector< std::reference_wrapper< MeshLib::Mesh > > const &meshes)
 
virtual ~SubmeshAssemblySupport ()=default
 

ODESystem interface

HeatTransportBHEProcessData _process_data
 
std::vector< std::unique_ptr< HeatTransportBHELocalAssemblerInterface > > _local_assemblers
 
std::vector< std::unique_ptr< MeshLib::MeshSubset const > > _mesh_subset_BHE_nodes
 
std::vector< std::unique_ptr< MeshLib::MeshSubset const > > _mesh_subset_BHE_soil_nodes
 
std::unique_ptr< MeshLib::MeshSubset const > _mesh_subset_soil_nodes
 
const BHEMeshData _bheMeshData
 
bool isLinear () const override
 
void computeSecondaryVariableConcrete (double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_prev, int const process_id) override
 
void constructDofTable () override
 
void initializeConcreteProcess (NumLib::LocalToGlobalIndexMap const &dof_table, MeshLib::Mesh const &mesh, unsigned const integration_order) override
 Process specific initialization called by initialize().
 
void assembleConcreteProcess (const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b) override
 
void assembleWithJacobianConcreteProcess (const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, GlobalMatrix &Jac) override
 
void createBHEBoundaryConditionTopBottom (std::vector< std::vector< MeshLib::Node * > > const &all_bhe_nodes)
 
void preTimestepConcreteProcess (std::vector< GlobalVector * > const &x, const double t, const double dt, int const process_id) override
 
void postTimestepConcreteProcess (std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, const double t, const double dt, int const process_id) override
 
NumLib::IterationResult postIterationConcreteProcess (GlobalVector const &x) override
 

Additional Inherited Members

- Public Attributes inherited from ProcessLib::Process
std::string const name
 
- Static Public Attributes inherited from ProcessLib::Process
static PROCESSLIB_EXPORT const std::string constant_one_parameter_name = "constant_one"
 
- Protected Member Functions inherited from ProcessLib::Process
std::vector< NumLib::LocalToGlobalIndexMap const * > getDOFTables (int const number_of_processes) const
 
NumLib::ExtrapolatorgetExtrapolator () const
 
NumLib::LocalToGlobalIndexMap const & getSingleComponentDOFTable () const
 
void initializeProcessBoundaryConditionsAndSourceTerms (const NumLib::LocalToGlobalIndexMap &dof_table, const int process_id, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium > > const &media)
 
void constructMonolithicProcessDofTable ()
 
void constructDofTableOfSpecifiedProcessStaggeredScheme (const int specified_process_id)
 
virtual std::tuple< NumLib::LocalToGlobalIndexMap *, bool > getDOFTableForExtrapolatorData () const
 
std::vector< GlobalIndexTypegetIndicesOfResiduumWithoutInitialCompensation () const override
 
- Protected Attributes inherited from ProcessLib::Process
MeshLib::Mesh_mesh
 
std::unique_ptr< MeshLib::MeshSubset const > _mesh_subset_all_nodes
 
std::unique_ptr< NumLib::LocalToGlobalIndexMap_local_to_global_index_map
 
SecondaryVariableCollection _secondary_variables
 
std::unique_ptr< ProcessLib::AbstractJacobianAssembler_jacobian_assembler
 
VectorMatrixAssembler _global_assembler
 
const bool _use_monolithic_scheme
 
unsigned const _integration_order
 
std::vector< std::unique_ptr< MeshLib::IntegrationPointWriter > > _integration_point_writer
 
GlobalSparsityPattern _sparsity_pattern
 
std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > _process_variables
 
std::vector< BoundaryConditionCollection_boundary_conditions
 

Constructor & Destructor Documentation

◆ HeatTransportBHEProcess()

ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::HeatTransportBHEProcess ( std::string name,
MeshLib::Mesh & mesh,
std::unique_ptr< ProcessLib::AbstractJacobianAssembler > && jacobian_assembler,
std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const & parameters,
unsigned const integration_order,
std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > && process_variables,
HeatTransportBHEProcessData && process_data,
SecondaryVariableCollection && secondary_variables )

Definition at line 27 of file HeatTransportBHEProcess.cpp.

37 : Process(std::move(name), mesh, std::move(jacobian_assembler), parameters,
38 integration_order, std::move(process_variables),
39 std::move(secondary_variables)),
40 _process_data(std::move(process_data)),
42{
43 if (_bheMeshData.BHE_mat_IDs.size() !=
45 {
47 "The number of the given BHE properties ({:d}) are not consistent "
48 "with the number of BHE groups in the mesh ({:d}).",
51 }
52
53 auto material_ids = MeshLib::materialIDs(mesh);
54 if (material_ids == nullptr)
55 {
56 OGS_FATAL("Not able to get material IDs! ");
57 }
58
60
61 // create a map from a material ID to a BHE ID
62 for (int i = 0; i < static_cast<int>(_bheMeshData.BHE_mat_IDs.size()); i++)
63 {
64 // fill in the map structure
66 i;
67 }
68}
#define OGS_FATAL(...)
Definition Error.h:26
std::string const name
Definition Process.h:354
Process(std::string name_, MeshLib::Mesh &mesh, std::unique_ptr< AbstractJacobianAssembler > &&jacobian_assembler, std::vector< std::unique_ptr< ParameterLib::ParameterBase > > const &parameters, unsigned const integration_order, std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > &&process_variables, SecondaryVariableCollection &&secondary_variables, const bool use_monolithic_scheme=true)
Definition Process.cpp:44
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition Mesh.cpp:268
BHEMeshData getBHEDataInMesh(MeshLib::Mesh const &mesh)
Definition MeshUtils.cpp:51

References _bheMeshData, ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::_map_materialID_to_BHE_ID, ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::_mesh_prop_materialIDs, _process_data, ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::_vec_BHE_property, ProcessLib::HeatTransportBHE::BHEMeshData::BHE_mat_IDs, MeshLib::materialIDs(), and OGS_FATAL.

Member Function Documentation

◆ assembleConcreteProcess()

void ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::assembleConcreteProcess ( const double t,
double const dt,
std::vector< GlobalVector * > const & x,
std::vector< GlobalVector * > const & x_prev,
int const process_id,
GlobalMatrix & M,
GlobalMatrix & K,
GlobalVector & b )
overrideprivatevirtual

Implements ProcessLib::Process.

Definition at line 161 of file HeatTransportBHEProcess.cpp.

165{
166 DBUG("Assemble HeatTransportBHE process.");
167
168 ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
169
170 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
172 // Call global assembler for each local assembly item.
175 pv.getActiveElementIDs(), dof_table, t, dt, x, x_prev, process_id, M, K,
176 b);
177}
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
std::vector< std::unique_ptr< HeatTransportBHELocalAssemblerInterface > > _local_assemblers
std::vector< std::size_t > const & getActiveElementIDs() const
std::vector< std::reference_wrapper< ProcessVariable > > const & getProcessVariables(const int process_id) const
Definition Process.h:155
VectorMatrixAssembler _global_assembler
Definition Process.h:367
std::unique_ptr< NumLib::LocalToGlobalIndexMap > _local_to_global_index_map
Definition Process.h:360
void assemble(std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, double const t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b)
static void executeSelectedMemberDereferenced(Object &object, Method method, Container const &container, std::vector< std::size_t > const &active_container_ids, Args &&... args)

References ProcessLib::Process::_global_assembler, _local_assemblers, ProcessLib::Process::_local_to_global_index_map, ProcessLib::VectorMatrixAssembler::assemble(), DBUG(), NumLib::SerialExecutor::executeSelectedMemberDereferenced(), ProcessLib::ProcessVariable::getActiveElementIDs(), and ProcessLib::Process::getProcessVariables().

◆ assembleWithJacobianConcreteProcess()

void ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::assembleWithJacobianConcreteProcess ( const double t,
double const dt,
std::vector< GlobalVector * > const & x,
std::vector< GlobalVector * > const & x_prev,
int const process_id,
GlobalMatrix & M,
GlobalMatrix & K,
GlobalVector & b,
GlobalMatrix & Jac )
overrideprivatevirtual

Implements ProcessLib::Process.

Definition at line 179 of file HeatTransportBHEProcess.cpp.

183{
184 DBUG("AssembleWithJacobian HeatTransportBHE process.");
185
186 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_table = {
188 ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
189
190 // Call global assembler for each local assembly item.
193 _local_assemblers, pv.getActiveElementIDs(), dof_table, t, dt, x,
194 x_prev, process_id, M, K, b, Jac);
195}
void assembleWithJacobian(std::size_t const mesh_item_id, LocalAssemblerInterface &local_assembler, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, const double t, double const dt, std::vector< GlobalVector * > const &x, std::vector< GlobalVector * > const &x_prev, int const process_id, GlobalMatrix &M, GlobalMatrix &K, GlobalVector &b, GlobalMatrix &Jac)

References ProcessLib::Process::_global_assembler, _local_assemblers, ProcessLib::Process::_local_to_global_index_map, ProcessLib::VectorMatrixAssembler::assembleWithJacobian(), DBUG(), NumLib::SerialExecutor::executeSelectedMemberDereferenced(), ProcessLib::ProcessVariable::getActiveElementIDs(), and ProcessLib::Process::getProcessVariables().

◆ computeSecondaryVariableConcrete()

void ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::computeSecondaryVariableConcrete ( double const t,
double const dt,
std::vector< GlobalVector * > const & x,
GlobalVector const & x_prev,
int const process_id )
overridevirtual

Reimplemented from ProcessLib::Process.

Definition at line 197 of file HeatTransportBHEProcess.cpp.

200{
201 DBUG("Compute heat flux for HeatTransportBHE process.");
202
203 std::vector<NumLib::LocalToGlobalIndexMap const*> dof_tables;
204 dof_tables.reserve(x.size());
205 std::generate_n(std::back_inserter(dof_tables), x.size(),
206 [&]() { return _local_to_global_index_map.get(); });
207
208 ProcessLib::ProcessVariable const& pv = getProcessVariables(process_id)[0];
211 _local_assemblers, pv.getActiveElementIDs(), dof_tables, t, dt, x,
212 x_prev, process_id);
213}
virtual void computeSecondaryVariable(std::size_t const mesh_item_id, std::vector< NumLib::LocalToGlobalIndexMap const * > const &dof_tables, double const t, double const dt, std::vector< GlobalVector * > const &x, GlobalVector const &x_prev, int const process_id)
static void executeSelectedMemberOnDereferenced(Method method, Container const &container, std::vector< std::size_t > const &active_container_ids, Args &&... args)

References _local_assemblers, ProcessLib::LocalAssemblerInterface::computeSecondaryVariable(), DBUG(), NumLib::SerialExecutor::executeSelectedMemberOnDereferenced(), ProcessLib::ProcessVariable::getActiveElementIDs(), and ProcessLib::Process::getProcessVariables().

◆ constructDofTable()

void ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::constructDofTable ( )
overrideprivatevirtual

This function is for general cases, in which all equations of the coupled processes have the same number of unknowns. For the general cases with the staggered scheme, all equations of the coupled processes share one DOF table hold by _local_to_global_index_map. Other cases can be considered by overloading this member function in the derived class.

Reimplemented from ProcessLib::Process.

Definition at line 70 of file HeatTransportBHEProcess.cpp.

71{
72 // Create single component dof in every of the mesh's nodes.
74 std::make_unique<MeshLib::MeshSubset>(_mesh, _mesh.getNodes());
75
76 //
77 // Soil temperature variable defined on the whole mesh.
78 //
80 std::make_unique<MeshLib::MeshSubset>(_mesh, _mesh.getNodes());
81 std::vector<MeshLib::MeshSubset> all_mesh_subsets{*_mesh_subset_soil_nodes};
82
83 std::vector<std::vector<MeshLib::Element*> const*> vec_var_elements;
84 vec_var_elements.push_back(&(_mesh.getElements()));
85
86 std::vector<int> vec_n_components{
87 1}; // one component for the soil temperature variable.
88
89 //
90 // BHE nodes with BHE type dependent number of variables.
91 //
92 int const n_BHEs = _process_data._vec_BHE_property.size();
93 assert(n_BHEs == static_cast<int>(_bheMeshData.BHE_mat_IDs.size()));
94 assert(n_BHEs == static_cast<int>(_bheMeshData.BHE_nodes.size()));
95 assert(n_BHEs == static_cast<int>(_bheMeshData.BHE_elements.size()));
96
97 // the BHE nodes need to be cherry-picked from the vector
98 for (int i = 0; i < n_BHEs; i++)
99 {
100 auto const number_of_unknowns =
101 visit([](auto const& bhe) { return bhe.number_of_unknowns; },
103 auto const& bhe_nodes = _bheMeshData.BHE_nodes[i];
104 auto const& bhe_elements = _bheMeshData.BHE_elements[i];
105
106 // All the BHE nodes have additional variables.
107 _mesh_subset_BHE_nodes.push_back(
108 std::make_unique<MeshLib::MeshSubset const>(_mesh, bhe_nodes));
109
110 std::generate_n(std::back_inserter(all_mesh_subsets),
111 // Here the number of components equals to the
112 // number of unknowns on the BHE
113 number_of_unknowns,
114 [&ms = _mesh_subset_BHE_nodes.back()]()
115 { return *ms; });
116
117 vec_n_components.push_back(number_of_unknowns);
118 vec_var_elements.push_back(&bhe_elements);
119 }
120
122 std::make_unique<NumLib::LocalToGlobalIndexMap>(
123 std::move(all_mesh_subsets),
124 vec_n_components,
125 vec_var_elements,
127
128 // in case of debugging the dof table, activate the following line
129 // std::cout << *_local_to_global_index_map << "\n";
130}
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
Definition Mesh.h:106
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
Definition Mesh.h:109
std::unique_ptr< MeshLib::MeshSubset const > _mesh_subset_soil_nodes
std::vector< std::unique_ptr< MeshLib::MeshSubset const > > _mesh_subset_BHE_nodes
std::unique_ptr< MeshLib::MeshSubset const > _mesh_subset_all_nodes
Definition Process.h:358
MeshLib::Mesh & _mesh
Definition Process.h:357
@ BY_COMPONENT
Ordering data by component type.
std::vector< std::vector< MeshLib::Node * > > BHE_nodes
Definition MeshUtils.h:38
std::vector< std::vector< MeshLib::Element * > > BHE_elements
Definition MeshUtils.h:37

References _bheMeshData, ProcessLib::Process::_local_to_global_index_map, ProcessLib::Process::_mesh, ProcessLib::Process::_mesh_subset_all_nodes, _mesh_subset_BHE_nodes, _mesh_subset_soil_nodes, _process_data, ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::_vec_BHE_property, ProcessLib::HeatTransportBHE::BHEMeshData::BHE_elements, ProcessLib::HeatTransportBHE::BHEMeshData::BHE_mat_IDs, ProcessLib::HeatTransportBHE::BHEMeshData::BHE_nodes, NumLib::BY_COMPONENT, MeshLib::Mesh::getElements(), and MeshLib::Mesh::getNodes().

◆ createBHEBoundaryConditionTopBottom()

void ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::createBHEBoundaryConditionTopBottom ( std::vector< std::vector< MeshLib::Node * > > const & all_bhe_nodes)
private

Definition at line 347 of file HeatTransportBHEProcess.cpp.

349{
350 const int process_id = 0;
351 auto& bcs = _boundary_conditions[process_id];
352
353 int const n_BHEs = static_cast<int>(_process_data._vec_BHE_property.size());
354
355 // for each BHE
356 for (int bhe_i = 0; bhe_i < n_BHEs; bhe_i++)
357 {
358 auto const& bhe_nodes = all_bhe_nodes[bhe_i];
359 // find the variable ID
360 // the soil temperature is 0-th variable
361 // the BHE temperature is therefore bhe_i + 1
362 const int variable_id = bhe_i + 1;
363
364 std::vector<MeshLib::Node*> bhe_boundary_nodes;
365
366 // cherry-pick the boundary nodes according to
367 // the number of connected line elements.
368 for (auto const& bhe_node : bhe_nodes)
369 {
370 // Count number of 1d elements connected with every BHE node.
371 auto const& connected_elements =
373 const std::size_t n_line_elements = std::count_if(
374 connected_elements.begin(), connected_elements.end(),
375 [](MeshLib::Element const* elem)
376 { return (elem->getDimension() == 1); });
377
378 if (n_line_elements == 1)
379 {
380 bhe_boundary_nodes.push_back(bhe_node);
381 }
382 }
383
384 if (bhe_boundary_nodes.size() != 2)
385 {
386 OGS_FATAL(
387 "Error!!! The BHE boundary nodes are not correctly found, "
388 "for every single BHE, there should be 2 boundary nodes.");
389 }
390
391 // For 1U, 2U, CXC, CXA type BHE, the node order in the boundary nodes
392 // vector should be rearranged according to its z coordinate in
393 // descending order. In these BHE types, the z coordinate on the top and
394 // bottom node is different. The BHE top node with a higher z coordinate
395 // should be placed at the first, while the BHE bottom node with a lower
396 // z coordinate should be placed at the second. For other horizontal BHE
397 // types e.g. 1P-type BHE, the z coordinate on the top and bottom node
398 // is identical. Thus the node order in the boundary nodes vector can
399 // not be rearranged according to its z coordinate. For these BHE types,
400 // the boundary node order is according to the default node id order in
401 // the model mesh.
402 // for 1P-type BHE
403 if ((*bhe_boundary_nodes[0])[2] == (*bhe_boundary_nodes[1])[2])
404 {
405 INFO(
406 "For 1P-type BHE, the BHE inflow and outflow "
407 "nodes are identified according to their mesh node id in "
408 "ascending order");
409 }
410 // for 1U, 2U, CXC, CXA type BHE
411 else
412 {
413 // swap the boundary nodes if the z coordinate of the
414 // first node is lower than it on the second node
415 if ((*bhe_boundary_nodes[0])[2] < (*bhe_boundary_nodes[1])[2])
416 {
417 std::swap(bhe_boundary_nodes[0], bhe_boundary_nodes[1]);
418 }
419 }
420
421 auto get_global_index =
422 [&](std::size_t const node_id, int const component)
423 {
424 return _local_to_global_index_map->getGlobalIndex(
426 variable_id, component);
427 };
428
429 auto get_global_bhe_bc_indices =
430 [&](std::array<
431 std::pair<std::size_t /*node_id*/, int /*component*/>, 2>
432 nodes_and_components)
433 {
434 return std::make_pair(
435 get_global_index(nodes_and_components[0].first,
436 nodes_and_components[0].second),
437 get_global_index(nodes_and_components[1].first,
438 nodes_and_components[1].second));
439 };
440
441 auto createBCs =
442 [&, bc_top_node_id = bhe_boundary_nodes[0]->getID(),
443 bc_bottom_node_id = bhe_boundary_nodes[1]->getID()](auto& bhe)
444 {
445 for (auto const& in_out_component_id :
446 bhe.inflow_outflow_bc_component_ids)
447 {
448 if (bhe.use_python_bcs ||
450 // call BHEPythonBoundarycondition
451 {
452 if (_process_data.py_bc_object) // the bc object exist
453 {
454 // apply the customized top, inflow BC.
455 bcs.addBoundaryCondition(
457 get_global_bhe_bc_indices(
458 bhe.getBHEInflowDirichletBCNodesAndComponents(
459 bc_top_node_id, bc_bottom_node_id,
460 in_out_component_id.first)),
461 bhe,
463 }
464 else
465 {
466 OGS_FATAL(
467 "The Python Boundary Condition was switched on, "
468 "but the data object does not exist! ");
469 }
470 }
471 else
472 {
473 // Top, inflow, normal case
474 bcs.addBoundaryCondition(
476 get_global_bhe_bc_indices(
477 bhe.getBHEInflowDirichletBCNodesAndComponents(
478 bc_top_node_id, bc_bottom_node_id,
479 in_out_component_id.first)),
480 [&bhe](double const T, double const t) {
481 return bhe.updateFlowRateAndTemperature(T, t);
482 }));
483 }
484
485 auto const bottom_nodes_and_components =
486 bhe.getBHEBottomDirichletBCNodesAndComponents(
487 bc_bottom_node_id,
488 in_out_component_id.first,
489 in_out_component_id.second);
490
491 if (bottom_nodes_and_components)
492 {
493 // Bottom, outflow, all cases
494 bcs.addBoundaryCondition(
496 get_global_bhe_bc_indices(
497 {{{bc_bottom_node_id,
498 in_out_component_id.first},
499 {bc_bottom_node_id,
500 in_out_component_id.second}}})));
501 }
502 }
503 };
504 visit(createBCs, _process_data._vec_BHE_property[bhe_i]);
505 }
506}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:35
std::size_t getID() const
Get id of the mesh.
Definition Mesh.h:121
std::vector< Element const * > const & getElementsConnectedToNode(std::size_t node_id) const
Definition Mesh.cpp:256
std::vector< BoundaryConditionCollection > _boundary_conditions
Definition Process.h:395
std::unique_ptr< BHEInflowDirichletBoundaryCondition< BHEUpdateCallback > > createBHEInflowDirichletBoundaryCondition(std::pair< GlobalIndexType, GlobalIndexType > &&in_out_global_indices, BHEUpdateCallback bhe_update_callback)
std::unique_ptr< BHEBottomDirichletBoundaryCondition > createBHEBottomDirichletBoundaryCondition(std::pair< GlobalIndexType, GlobalIndexType > &&in_out_global_indices)
std::unique_ptr< BHEInflowPythonBoundaryCondition< BHEType > > createBHEInflowPythonBoundaryCondition(std::pair< GlobalIndexType, GlobalIndexType > &&in_out_global_indices, BHEType &bhe, BHEInflowPythonBoundaryConditionPythonSideInterface &py_bc_object)
BHEInflowPythonBoundaryConditionPythonSideInterface * py_bc_object
Python object computing BC values.

References ProcessLib::Process::_boundary_conditions, ProcessLib::Process::_local_to_global_index_map, ProcessLib::Process::_mesh, _process_data, ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::_use_server_communication, ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::_vec_BHE_property, ProcessLib::HeatTransportBHE::createBHEBottomDirichletBoundaryCondition(), ProcessLib::HeatTransportBHE::createBHEInflowDirichletBoundaryCondition(), ProcessLib::createBHEInflowPythonBoundaryCondition(), MeshLib::Mesh::getElementsConnectedToNode(), MeshLib::Mesh::getID(), INFO(), MeshLib::Node, OGS_FATAL, and ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::py_bc_object.

Referenced by initializeConcreteProcess().

◆ initializeConcreteProcess()

void ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::initializeConcreteProcess ( NumLib::LocalToGlobalIndexMap const & dof_table,
MeshLib::Mesh const & mesh,
unsigned const integration_order )
overrideprivatevirtual

Process specific initialization called by initialize().

Implements ProcessLib::Process.

Definition at line 132 of file HeatTransportBHEProcess.cpp.

136{
137 // Quick access map to BHE's through element ids.
138 std::unordered_map<std::size_t, BHE::BHETypes*> element_to_bhe_map;
139 int const n_BHEs = _process_data._vec_BHE_property.size();
140 for (int i = 0; i < n_BHEs; i++)
141 {
142 auto const& bhe_elements = _bheMeshData.BHE_elements[i];
143 for (auto const& e : bhe_elements)
144 {
145 element_to_bhe_map[e->getID()] =
147 }
148 }
149
150 assert(mesh.getDimension() == 3);
152 HeatTransportBHELocalAssemblerSoil, HeatTransportBHELocalAssemblerBHE>(
153 mesh.getElements(), dof_table, _local_assemblers,
154 NumLib::IntegrationOrder{integration_order}, element_to_bhe_map,
155 mesh.isAxiallySymmetric(), _process_data);
156
157 // Create BHE boundary conditions for each of the BHEs
159}
void createBHEBoundaryConditionTopBottom(std::vector< std::vector< MeshLib::Node * > > const &all_bhe_nodes)
void createLocalAssemblers(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)

References _bheMeshData, _local_assemblers, _process_data, ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::_vec_BHE_property, ProcessLib::HeatTransportBHE::BHEMeshData::BHE_elements, ProcessLib::HeatTransportBHE::BHEMeshData::BHE_nodes, createBHEBoundaryConditionTopBottom(), ProcessLib::HeatTransportBHE::createLocalAssemblers(), MeshLib::Mesh::getDimension(), MeshLib::Mesh::getElements(), and MeshLib::Mesh::isAxiallySymmetric().

◆ isLinear()

bool ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::isLinear ( ) const
inlineoverride

Definition at line 42 of file HeatTransportBHEProcess.h.

42{ return false; }

◆ postIterationConcreteProcess()

NumLib::IterationResult ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::postIterationConcreteProcess ( GlobalVector const & x)
overrideprivatevirtual

Reimplemented from ProcessLib::Process.

Definition at line 215 of file HeatTransportBHEProcess.cpp.

217{
218 // if the process use python boundary condition
221
222 // Here the task is to get current time flowrate and flow temperature from
223 // TESPy and determine whether it converges.
224 auto const Tout_nodes_id =
226 const std::size_t n_bc_nodes = Tout_nodes_id.size();
227
228 for (std::size_t i = 0; i < n_bc_nodes; i++)
229 {
230 // read the T_out and store them in dataframe
232 x[Tout_nodes_id[i]];
233 }
234 // Transfer Tin and Tout to TESPy and return the results
235 auto const tespy_result = _process_data.py_bc_object->tespySolver(
237 std::get<1>(_process_data.py_bc_object->dataframe_network), // T_in
238 std::get<2>(_process_data.py_bc_object->dataframe_network)); // T_out
240 {
241 DBUG("Method `tespySolver' not overridden in Python script.");
242 }
243
244 // update the Tin and flow rate
245 for (std::size_t i = 0; i < n_bc_nodes; i++)
246 {
248 std::get<2>(tespy_result)[i];
250 std::get<3>(tespy_result)[i];
251 }
252 auto const tespy_has_converged = std::get<1>(tespy_result);
253 if (tespy_has_converged == true)
255
257}
std::tuple< double, std::vector< double >, std::vector< double >, std::vector< int >, std::vector< double > > dataframe_network
virtual std::tuple< bool, bool, std::vector< double >, std::vector< double > > tespySolver(double, std::vector< double > const &, std::vector< double > const &) const

References _process_data, ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::_use_tespy, ProcessLib::BHEInflowPythonBoundaryConditionPythonSideInterface::dataframe_network, DBUG(), ProcessLib::BHEInflowPythonBoundaryConditionPythonSideInterface::isOverriddenTespy(), ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::py_bc_object, NumLib::REPEAT_ITERATION, NumLib::SUCCESS, and ProcessLib::BHEInflowPythonBoundaryConditionPythonSideInterface::tespySolver().

◆ postTimestepConcreteProcess()

void ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::postTimestepConcreteProcess ( std::vector< GlobalVector * > const & x,
std::vector< GlobalVector * > const & x_prev,
const double t,
const double dt,
int const process_id )
overrideprivatevirtual

Reimplemented from ProcessLib::Process.

Definition at line 308 of file HeatTransportBHEProcess.cpp.

312{
313 if (_process_data.py_bc_object == nullptr ||
315 {
316 return;
317 }
318
319 auto& [time, Tin_value, Tout_value, Tout_nodes_ids, flowrate] =
321
322 // We found the problem that time != t, but it always equals the last
323 // step. The following line is to correct this, although we do not use
324 // it for server communication.
325 time = t;
326
327 auto const& solution = *x[process_id];
328
329 // Iterate through each BHE
330 const std::size_t n_bc_nodes = Tout_nodes_ids.size();
331 for (std::size_t i = 0; i < n_bc_nodes; i++)
332 {
333 // read the T_out and store them in dataframe
334 Tout_value[i] = solution[Tout_nodes_ids[i]];
335 }
336
337 // Transfer T_out to server_Communication
339 t, dt, Tin_value, Tout_value, flowrate);
342 {
343 DBUG("Method `serverCommunication' not overridden in Python script.");
344 }
345}
virtual void serverCommunicationPostTimestep(double, double, std::vector< double > const &, std::vector< double > const &, std::vector< double > const &) const

References _process_data, ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::_use_server_communication, ProcessLib::BHEInflowPythonBoundaryConditionPythonSideInterface::dataframe_network, DBUG(), ProcessLib::BHEInflowPythonBoundaryConditionPythonSideInterface::isOverriddenServerCommunicationPostTimestep(), ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::py_bc_object, and ProcessLib::BHEInflowPythonBoundaryConditionPythonSideInterface::serverCommunicationPostTimestep().

◆ preTimestepConcreteProcess()

void ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::preTimestepConcreteProcess ( std::vector< GlobalVector * > const & x,
const double t,
const double dt,
int const process_id )
overrideprivatevirtual

Reimplemented from ProcessLib::Process.

Definition at line 259 of file HeatTransportBHEProcess.cpp.

262{
263 if (_process_data.py_bc_object == nullptr ||
265 {
266 return;
267 }
268
269 auto& [time, Tin_value, Tout_value, Tout_nodes_ids, flowrate] =
271
272 // We found the problem that time != t, but it always equals the last
273 // step. The following line is to correct this, although we do not use
274 // it for server communication.
275 time = t;
276
277 auto const& solution = *x[process_id];
278
279 // Iterate through each BHE
280 const std::size_t n_bc_nodes = Tout_nodes_ids.size();
281 for (std::size_t i = 0; i < n_bc_nodes; i++)
282 {
283 // read the T_out and store them in dataframe
284 Tout_value[i] = solution[Tout_nodes_ids[i]];
285 }
286
287 // Transfer T_out to server_Communication and get back T_in and flowrate
288 auto const server_communication_result =
290 t, dt, Tin_value, Tout_value, flowrate);
293 {
294 DBUG("Method `serverCommunication' not overridden in Python script.");
295 }
296
297 auto const& [server_communication_Tin_value,
298 server_communication_flowrate] = server_communication_result;
299
300 std::copy(begin(server_communication_Tin_value),
301 end(server_communication_Tin_value),
302 begin(Tin_value));
303 std::copy(begin(server_communication_flowrate),
304 end(server_communication_flowrate),
305 begin(flowrate));
306}
virtual std::tuple< std::vector< double >, std::vector< double > > serverCommunicationPreTimestep(double, double, std::vector< double > const &, std::vector< double > const &, std::vector< double > const &) const

References _process_data, ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::_use_server_communication, ProcessLib::BHEInflowPythonBoundaryConditionPythonSideInterface::dataframe_network, DBUG(), ProcessLib::BHEInflowPythonBoundaryConditionPythonSideInterface::isOverriddenServerCommunicationPreTimestep(), ProcessLib::HeatTransportBHE::HeatTransportBHEProcessData::py_bc_object, and ProcessLib::BHEInflowPythonBoundaryConditionPythonSideInterface::serverCommunicationPreTimestep().

Member Data Documentation

◆ _bheMeshData

const BHEMeshData ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::_bheMeshData
private

◆ _local_assemblers

std::vector<std::unique_ptr<HeatTransportBHELocalAssemblerInterface> > ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::_local_assemblers
private

◆ _mesh_subset_BHE_nodes

std::vector<std::unique_ptr<MeshLib::MeshSubset const> > ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::_mesh_subset_BHE_nodes
private

Definition at line 89 of file HeatTransportBHEProcess.h.

Referenced by constructDofTable().

◆ _mesh_subset_BHE_soil_nodes

std::vector<std::unique_ptr<MeshLib::MeshSubset const> > ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::_mesh_subset_BHE_soil_nodes
private

Definition at line 92 of file HeatTransportBHEProcess.h.

◆ _mesh_subset_soil_nodes

std::unique_ptr<MeshLib::MeshSubset const> ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::_mesh_subset_soil_nodes
private

Definition at line 94 of file HeatTransportBHEProcess.h.

Referenced by constructDofTable().

◆ _process_data


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