OGS
ProcessLib::HeatTransportBHE Namespace Reference

Namespaces

 BHE
 
 detail
 

Classes

struct  BHEMeshData
 
class  BHEBottomDirichletBoundaryCondition
 
class  BHEInflowDirichletBoundaryCondition
 
class  HeatTransportBHEProcess
 
struct  HeatTransportBHEProcessData
 
class  HeatTransportBHELocalAssemblerBHE
 
class  HeatTransportBHELocalAssemblerSoil
 
class  HeatTransportBHELocalAssemblerInterface
 
struct  IntegrationPointDataBHE
 
struct  IntegrationPointDataSoil
 
class  LocalDataInitializer
 
struct  SecondaryData
 

Functions

BHEMeshData getBHEDataInMesh (MeshLib::Mesh const &mesh)
 
std::unique_ptr< BHEBottomDirichletBoundaryConditioncreateBHEBottomDirichletBoundaryCondition (std::pair< GlobalIndexType, GlobalIndexType > &&in_out_global_indices)
 
template<typename BHEUpdateCallback >
std::unique_ptr< BHEInflowDirichletBoundaryCondition< BHEUpdateCallback > > createBHEInflowDirichletBoundaryCondition (std::pair< GlobalIndexType, GlobalIndexType > &&in_out_global_indices, BHEUpdateCallback bhe_update_callback)
 
std::unique_ptr< ProcesscreateHeatTransportBHEProcess (std::string name, MeshLib::Mesh &mesh, std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&jacobian_assembler, std::vector< ProcessVariable > const &variables, std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &parameters, unsigned const integration_order, BaseLib::ConfigTree const &config, std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation >> const &curves, std::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &media)
 
template<template< typename, typename > class LocalAssemblerSoilImplementation, template< typename, typename, typename > class LocalAssemblerBHEImplementation, typename LocalAssemblerInterface , typename... ExtraCtorArgs>
void createLocalAssemblers (std::vector< MeshLib::Element * > const &mesh_elements, NumLib::LocalToGlobalIndexMap const &dof_table, std::vector< std::unique_ptr< LocalAssemblerInterface >> &local_assemblers, ExtraCtorArgs &&... extra_ctor_args)
 
Eigen::Vector3d compute1Dto3DRotationMatrix (MeshLib::Element const &e)
 

Function Documentation

◆ compute1Dto3DRotationMatrix()

Eigen::Vector3d ProcessLib::HeatTransportBHE::compute1Dto3DRotationMatrix ( MeshLib::Element const &  e)

Definition at line 22 of file HeatTransportBHELocalAssemblerBHE-impl.h.

23 {
24  constexpr int global_dim = 3;
25  constexpr int element_dim = 1;
26 
27  assert(e.getDimension() == element_dim);
28  const MeshLib::ElementCoordinatesMappingLocal ele_local_coord(e,
29  global_dim);
30  return ele_local_coord.getRotationMatrixToGlobal()
31  .template topLeftCorner<global_dim, element_dim>();
32 }

References MeshLib::Element::getDimension(), and MeshLib::ElementCoordinatesMappingLocal::getRotationMatrixToGlobal().

◆ createBHEBottomDirichletBoundaryCondition()

std::unique_ptr< BHEBottomDirichletBoundaryCondition > ProcessLib::HeatTransportBHE::createBHEBottomDirichletBoundaryCondition ( std::pair< GlobalIndexType, GlobalIndexType > &&  in_out_global_indices)

Definition at line 32 of file BHEBottomDirichletBoundaryCondition.cpp.

34 {
35  DBUG("Constructing BHEBottomDirichletBoundaryCondition.");
36 
37  // In case of partitioned mesh the boundary could be empty, i.e. there is no
38  // boundary condition.
39 #ifdef USE_PETSC
40  // For this special boundary condition the boundary condition is not empty
41  // if the global indices are non-negative.
42  if (in_out_global_indices.first < 0 && in_out_global_indices.second < 0)
43  {
44  return nullptr;
45  }
46  // If only one of the global indices (in or out) is negative the
47  // implementation is not valid.
48  if (in_out_global_indices.first < 0 || in_out_global_indices.second < 0)
49  {
50  OGS_FATAL(
51  "The partition cuts the BHE into two independent parts. This "
52  "behaviour is not implemented.");
53  }
54 #endif // USE_PETSC
55 
56  return std::make_unique<BHEBottomDirichletBoundaryCondition>(
57  std::move(in_out_global_indices));
58 }
#define OGS_FATAL(...)
Definition: Error.h:26
void DBUG(char const *fmt, Args const &... args)
Definition: Logging.h:27

References DBUG(), and OGS_FATAL.

Referenced by ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::createBHEBoundaryConditionTopBottom().

◆ createBHEInflowDirichletBoundaryCondition()

template<typename BHEUpdateCallback >
std::unique_ptr<BHEInflowDirichletBoundaryCondition<BHEUpdateCallback> > ProcessLib::HeatTransportBHE::createBHEInflowDirichletBoundaryCondition ( std::pair< GlobalIndexType, GlobalIndexType > &&  in_out_global_indices,
BHEUpdateCallback  bhe_update_callback 
)

Definition at line 50 of file BHEInflowDirichletBoundaryCondition.h.

53 {
54  DBUG("Constructing BHEInflowDirichletBoundaryCondition.");
55 
56  // In case of partitioned mesh the boundary could be empty, i.e. there is no
57  // boundary condition.
58 #ifdef USE_PETSC
59  // For this special boundary condition the boundary condition is not empty
60  // if the global indices are non-negative.
61  if (in_out_global_indices.first < 0 && in_out_global_indices.second < 0)
62  {
63  return nullptr;
64  }
65  // If only one of the global indices (in or out) is negative the
66  // implementation is not valid.
67  if (in_out_global_indices.first < 0 || in_out_global_indices.second < 0)
68  {
69  OGS_FATAL(
70  "The partition cuts the BHE into two independent parts. This "
71  "behaviour is not implemented.");
72  }
73 #endif // USE_PETSC
74 
75  return std::make_unique<
76  BHEInflowDirichletBoundaryCondition<BHEUpdateCallback>>(
77  std::move(in_out_global_indices), bhe_update_callback);
78 }

References DBUG(), and OGS_FATAL.

Referenced by ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::createBHEBoundaryConditionTopBottom().

◆ createHeatTransportBHEProcess()

std::unique_ptr< Process > ProcessLib::HeatTransportBHE::createHeatTransportBHEProcess ( std::string  name,
MeshLib::Mesh mesh,
std::unique_ptr< ProcessLib::AbstractJacobianAssembler > &&  jacobian_assembler,
std::vector< ProcessVariable > const &  variables,
std::vector< std::unique_ptr< ParameterLib::ParameterBase >> const &  parameters,
unsigned const  integration_order,
BaseLib::ConfigTree const &  config,
std::map< std::string, std::unique_ptr< MathLib::PiecewiseLinearInterpolation >> const &  curves,
std::map< int, std::shared_ptr< MaterialPropertyLib::Medium >> const &  media 
)
Input File Parameter:
prj__processes__process__type
Input File Parameter:
prj__processes__process__HEAT_TRANSPORT_BHE__process_variables
Input File Parameter:
prj__processes__process__HEAT_TRANSPORT_BHE__process_variables__process_variable
Input File Parameter:
prj__processes__process__HEAT_TRANSPORT_BHE__borehole_heat_exchangers
Input File Parameter:
prj__processes__process__HEAT_TRANSPORT_BHE__use_server_communication
Input File Parameter:
prj__processes__process__HEAT_TRANSPORT_BHE__borehole_heat_exchangers__borehole_heat_exchanger
Input File Parameter:
prj__processes__process__HEAT_TRANSPORT_BHE__borehole_heat_exchangers__borehole_heat_exchanger__type

Python object computing BC values.

Definition at line 31 of file CreateHeatTransportBHEProcess.cpp.

43 {
45  config.checkConfigParameter("type", "HEAT_TRANSPORT_BHE");
46 
47  DBUG("Create HeatTransportBHE Process.");
48 
49  // Process variable.
50 
52  auto const pv_config = config.getConfigSubtree("process_variables");
53  std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
54  process_variables;
55 
56  // reading primary variables for each
57  // BHE----------------------------------------------------------
58  auto range =
60  pv_config.getConfigParameterList<std::string>("process_variable");
61  std::vector<std::reference_wrapper<ProcessVariable>> per_process_variables;
62 
63  for (std::string const& pv_name : range)
64  {
65  if (pv_name != "temperature_soil" &&
66  pv_name.find("temperature_BHE") == std::string::npos)
67  {
68  OGS_FATAL(
69  "Found a process variable name '{:s}'. It should be "
70  "'temperature_soil' or 'temperature_BHE_X'");
71  }
72  auto variable = std::find_if(variables.cbegin(), variables.cend(),
73  [&pv_name](ProcessVariable const& v)
74  { return v.getName() == pv_name; });
75 
76  if (variable == variables.end())
77  {
78  OGS_FATAL(
79  "Could not find process variable '{:s}' in the provided "
80  "variables list for config tag <{:s}>.",
81  pv_name, "process_variable");
82  }
83  DBUG("Found process variable '{:s}' for config tag <{:s}>.",
84  variable->getName(), "process_variable");
85 
86  per_process_variables.emplace_back(
87  const_cast<ProcessVariable&>(*variable));
88  }
89  process_variables.push_back(std::move(per_process_variables));
90  // end of reading primary variables for each
91  // BHE----------------------------------------------------------
92 
93  // reading BHE parameters --------------------------------------------------
94  std::vector<BHE::BHETypes> bhes;
95 
96  auto const& bhe_configs =
98  config.getConfigSubtree("borehole_heat_exchangers");
99 
100  auto const using_server_communication =
102  config.getConfigParameter<bool>("use_server_communication", false);
103 
104  for (
105  auto const& bhe_config :
107  bhe_configs.getConfigSubtreeList("borehole_heat_exchanger"))
108  {
109  // read in the parameters
110  const std::string bhe_type =
112  bhe_config.getConfigParameter<std::string>("type");
113 
114  if (bhe_type == "1U")
115  {
116  bhes.emplace_back(
117  BHE::createBHEUType<BHE::BHE_1U>(bhe_config, curves));
118  continue;
119  }
120 
121  if (bhe_type == "CXA")
122  {
123  bhes.emplace_back(
124  BHE::createBHECoaxial<BHE::BHE_CXA>(bhe_config, curves));
125  continue;
126  }
127 
128  if (bhe_type == "CXC")
129  {
130  bhes.emplace_back(
131  BHE::createBHECoaxial<BHE::BHE_CXC>(bhe_config, curves));
132  continue;
133  }
134 
135  if (bhe_type == "2U")
136  {
137  bhes.emplace_back(
138  BHE::createBHEUType<BHE::BHE_2U>(bhe_config, curves));
139  continue;
140  }
141 
142  if (bhe_type == "1P")
143  {
144  bhes.emplace_back(
145  BHE::createBHE1PType<BHE::BHE_1P>(bhe_config, curves));
146  continue;
147  }
148  OGS_FATAL("Unknown BHE type '{:s}'.", bhe_type);
149  }
150  // end of reading BHE parameters -------------------------------------------
151 
152  auto media_map =
154 
155  // find if bhe uses python boundary condition
156  auto const using_tespy =
157  visit([](auto const& bhe) { return bhe.use_python_bcs; }, bhes[0]);
158 
160  BHEInflowPythonBoundaryConditionPythonSideInterface* py_object = nullptr;
161  // create a pythonBoundaryCondition object
162  if (using_tespy || using_server_communication)
163  {
164 #ifdef OGS_USE_PYTHON
165  // Evaluate Python code in scope of main module
166  pybind11::object scope =
167  pybind11::module::import("__main__").attr("__dict__");
168 
169  if (!scope.contains("bc_bhe"))
170  OGS_FATAL(
171  "Function 'bc_bhe' is not defined in the python script file, "
172  "or there was no python script file specified.");
173 
174  py_object =
175  scope["bc_bhe"]
176  .cast<BHEInflowPythonBoundaryConditionPythonSideInterface*>();
177 
178  if (py_object == nullptr)
179  OGS_FATAL(
180  "Not able to access the correct bc pointer from python script "
181  "file specified.");
182 
183  // create BHE network dataframe from Python
184  py_object->dataframe_network = py_object->initializeDataContainer();
185  if (!py_object->isOverriddenEssential())
186  {
187  DBUG(
188  "Method `initializeDataContainer' not overridden in Python "
189  "script.");
190  }
191  // clear ogs bc_node_id memory in dataframe
192  std::get<3>(py_object->dataframe_network).clear(); // ogs_bc_node_id
193 
194  // here calls the tespyHydroSolver to get the pipe flow velocity in bhe
195  // network
196  /* for 2U type the flowrate initialization process below causes conflict
197  // replace the value in flow velocity Matrix _u
198  auto const tespy_flow_rate = std::get<4>(py_object->dataframe_network);
199  const std::size_t n_bhe = tespy_flow_rate.size();
200  if (bhes.size() != n_bhe)
201  OGS_FATAL(
202  "The number of BHEs defined in OGS and TESPy are not the "
203  "same!");
204 
205  for (std::size_t idx_bhe = 0; idx_bhe < n_bhe; idx_bhe++)
206  {
207  // the flow_rate in OGS should be updated from the flow_rate
208  // computed by TESPy.
209  auto update_flow_rate = [&](auto& bhe) {
210  bhe.updateHeatTransferCoefficients(tespy_flow_rate[idx_bhe]);
211  };
212  visit(update_flow_rate, bhes[idx_bhe]);
213  }
214  */
215 #else
216  OGS_FATAL(
217  "Input files suggest the coupling of BHE with pipe network. "
218  "This means the compiling flag OGS_USE_PYTHON must be switched "
219  "on. ");
220 #endif // OGS_USE_PYTHON
221  }
222 
223  HeatTransportBHEProcessData process_data(
224  std::move(media_map), std::move(bhes), py_object, using_tespy,
225  using_server_communication);
226 
227  SecondaryVariableCollection secondary_variables;
228 
229  ProcessLib::createSecondaryVariables(config, secondary_variables);
230 
231  return std::make_unique<HeatTransportBHEProcess>(
232  std::move(name), mesh, std::move(jacobian_assembler), parameters,
233  integration_order, std::move(process_variables),
234  std::move(process_data), std::move(secondary_variables));
235 }
std::unique_ptr< MaterialSpatialDistributionMap > createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium >> const &media, MeshLib::Mesh const &mesh)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)

References BaseLib::ConfigTree::checkConfigParameter(), MaterialPropertyLib::createMaterialSpatialDistributionMap(), ProcessLib::createSecondaryVariables(), DBUG(), BaseLib::ConfigTree::getConfigParameter(), BaseLib::ConfigTree::getConfigParameterList(), BaseLib::ConfigTree::getConfigSubtree(), MaterialPropertyLib::name, and OGS_FATAL.

Referenced by ProjectData::parseProcesses().

◆ createLocalAssemblers()

template<template< typename, typename > class LocalAssemblerSoilImplementation, template< typename, typename, typename > class LocalAssemblerBHEImplementation, typename LocalAssemblerInterface , typename... ExtraCtorArgs>
void ProcessLib::HeatTransportBHE::createLocalAssemblers ( std::vector< MeshLib::Element * > const &  mesh_elements,
NumLib::LocalToGlobalIndexMap const &  dof_table,
std::vector< std::unique_ptr< LocalAssemblerInterface >> &  local_assemblers,
ExtraCtorArgs &&...  extra_ctor_args 
)

Creates local assemblers for each element of the given mesh.

Template Parameters
LocalAssemblerImplementationthe individual local assembler type
LocalAssemblerInterfacethe general local assembler interface
ExtraCtorArgstypes of additional constructor arguments. Those arguments will be passed to the constructor of LocalAssemblerImplementation.

The first two template parameters cannot be deduced from the arguments. Therefore they always have to be provided manually.

Definition at line 71 of file CreateLocalAssemblers.h.

76 {
77  DBUG("Create local assemblers for the HeatTransportBHE process.");
78 
79  detail::createLocalAssemblers<LocalAssemblerSoilImplementation,
80  LocalAssemblerBHEImplementation>(
81  dof_table, mesh_elements, local_assemblers,
82  std::forward<ExtraCtorArgs>(extra_ctor_args)...);
83 }
void createLocalAssemblers(const unsigned dimension, std::vector< MeshLib::Element * > const &mesh_elements, NumLib::LocalToGlobalIndexMap const &dof_table, const unsigned shapefunction_order, std::vector< std::unique_ptr< LocalAssemblerInterface >> &local_assemblers, ExtraCtorArgs &&... extra_ctor_args)

References ProcessLib::HeatTransportBHE::detail::createLocalAssemblers(), and DBUG().

Referenced by ProcessLib::HeatTransportBHE::HeatTransportBHEProcess::initializeConcreteProcess().

◆ getBHEDataInMesh()

BHEMeshData ProcessLib::HeatTransportBHE::getBHEDataInMesh ( MeshLib::Mesh const &  mesh)

get data about fracture and matrix elements/nodes from a mesh

Parameters
meshA mesh which includes BHE elements, i.e. 1-dimensional elements. It is assumed that elements forming a BHE have a distinct material ID.

Definition at line 51 of file MeshUtils.cpp.

52 {
53  std::vector<MeshLib::Element*> const all_bhe_elements =
54  extractOneDimensionalElements(mesh.getElements());
55 
56  // finally counting two types of elements
57  // They are (i) soil, and (ii) BHE type of elements
58  DBUG("-> found total {:d} soil elements and {:d} BHE elements",
59  mesh.getNumberOfElements() - all_bhe_elements.size(),
60  all_bhe_elements.size());
61 
62  // get BHE material IDs
63  auto const* const opt_material_ids = MeshLib::materialIDs(mesh);
64  if (opt_material_ids == nullptr)
65  {
66  OGS_FATAL("Not able to get material IDs! ");
67  }
68  auto const& material_ids = *opt_material_ids;
69 
70  auto const& bhe_material_ids =
71  getUniqueMaterialIds(material_ids, all_bhe_elements);
72  DBUG("-> found {:d} BHE material groups", bhe_material_ids.size());
73 
74  // create a vector of BHE elements for each group
75  std::vector<std::vector<MeshLib::Element*>> bhe_elements;
76  bhe_elements.resize(bhe_material_ids.size());
77  for (unsigned bhe_id = 0; bhe_id < bhe_material_ids.size(); bhe_id++)
78  {
79  const auto bhe_mat_id = bhe_material_ids[bhe_id];
80  std::vector<MeshLib::Element*>& vec_elements = bhe_elements[bhe_id];
81  copy_if(begin(all_bhe_elements), end(all_bhe_elements),
82  back_inserter(vec_elements),
83  [&](MeshLib::Element* e)
84  { return material_ids[e->getID()] == bhe_mat_id; });
85  DBUG("-> found {:d} elements on the BHE_{:d}", vec_elements.size(),
86  bhe_id);
87  }
88 
89  // get a vector of BHE nodes
90  std::vector<std::vector<MeshLib::Node*>> bhe_nodes;
91  bhe_nodes.resize(bhe_material_ids.size());
92  for (unsigned bhe_id = 0; bhe_id < bhe_material_ids.size(); bhe_id++)
93  {
94  std::vector<MeshLib::Node*>& vec_nodes = bhe_nodes[bhe_id];
95  for (MeshLib::Element* e : bhe_elements[bhe_id])
96  {
97  for (unsigned i = 0; i < e->getNumberOfNodes(); i++)
98  {
99  vec_nodes.push_back(const_cast<MeshLib::Node*>(e->getNode(i)));
100  }
101  }
102  BaseLib::makeVectorUnique(vec_nodes,
103  [](MeshLib::Node* node1, MeshLib::Node* node2)
104  { return node1->getID() < node2->getID(); });
105  DBUG("-> found {:d} nodes on the BHE_{:d}", vec_nodes.size(), bhe_id);
106  }
107 
108  return {bhe_material_ids, bhe_elements, bhe_nodes};
109 }
std::size_t getID() const
Definition: Point3dWithID.h:62
virtual const Node * getNode(unsigned idx) const =0
virtual unsigned getNumberOfNodes() const =0
virtual std::size_t getID() const final
Returns the ID of the element.
Definition: Element.h:82
void makeVectorUnique(std::vector< T > &v)
Definition: Algorithm.h:209
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition: Mesh.cpp:258
std::vector< int > getUniqueMaterialIds(std::vector< int > const &material_ids, std::vector< MeshLib::Element * > const &elements)
Definition: MeshUtils.cpp:34
std::vector< MeshLib::Element * > extractOneDimensionalElements(std::vector< MeshLib::Element * > const &elements)
Definition: MeshUtils.cpp:22

References DBUG(), anonymous_namespace{MeshUtils.cpp}::extractOneDimensionalElements(), MeshLib::Mesh::getElements(), MathLib::Point3dWithID::getID(), MeshLib::Element::getID(), MeshLib::Mesh::getNumberOfElements(), anonymous_namespace{MeshUtils.cpp}::getUniqueMaterialIds(), BaseLib::makeVectorUnique(), MeshLib::materialIDs(), and OGS_FATAL.