OGS 6.2.2-330-gf48c72f61.dirty.20200225212913
ProcessLib::HeatTransportBHE Namespace Reference

Namespaces

 BHE
 
 detail
 

Classes

class  BHEBottomDirichletBoundaryCondition
 
class  BHEInflowDirichletBoundaryCondition
 
struct  BHEMeshData
 
class  HeatTransportBHELocalAssemblerBHE
 
class  HeatTransportBHELocalAssemblerInterface
 
class  HeatTransportBHELocalAssemblerSoil
 
class  HeatTransportBHEProcess
 
struct  HeatTransportBHEProcessData
 
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)
 

Function Documentation

◆ createBHEBottomDirichletBoundaryCondition()

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

Definition at line 31 of file BHEBottomDirichletBoundaryCondition.cpp.

References OGS_FATAL.

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

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

◆ 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.

References OGS_FATAL.

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

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 }
#define OGS_FATAL(fmt,...)
Definition: Error.h:64

◆ 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__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.

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

Referenced by ProjectData::parseProcesses().

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 
77  if (variable == variables.end())
78  {
79  OGS_FATAL(
80  "Could not find process variable '%s' in the provided "
81  "variables "
82  "list for config tag <%s>.",
83  pv_name.c_str(), "process_variable");
84  }
85  DBUG("Found process variable '%s' for config tag <%s>.",
86  variable->getName().c_str(), "process_variable");
87 
88  per_process_variables.emplace_back(
89  const_cast<ProcessVariable&>(*variable));
90  }
91  process_variables.push_back(std::move(per_process_variables));
92  // end of reading primary variables for each
93  // BHE----------------------------------------------------------
94 
95  // reading BHE parameters --------------------------------------------------
96  std::vector<BHE::BHETypes> bhes;
97 
98  auto const& bhe_configs =
100  config.getConfigSubtree("borehole_heat_exchangers");
101 
102  for (
103  auto const& bhe_config :
105  bhe_configs.getConfigSubtreeList("borehole_heat_exchanger"))
106  {
107  // read in the parameters
108  const std::string bhe_type =
110  bhe_config.getConfigParameter<std::string>("type");
111 
112  if (bhe_type == "1U")
113  {
114  bhes.emplace_back(
115  BHE::createBHEUType<BHE::BHE_1U>(bhe_config, curves));
116  continue;
117  }
118 
119  if (bhe_type == "CXA")
120  {
121  bhes.emplace_back(
122  BHE::createBHECoaxial<BHE::BHE_CXA>(bhe_config, curves));
123  continue;
124  }
125 
126  if (bhe_type == "CXC")
127  {
128  bhes.emplace_back(
129  BHE::createBHECoaxial<BHE::BHE_CXC>(bhe_config, curves));
130  continue;
131  }
132 
133  if (bhe_type == "2U")
134  {
135  bhes.emplace_back(
136  BHE::createBHEUType<BHE::BHE_2U>(bhe_config, curves));
137  continue;
138  }
139  OGS_FATAL("Unknown BHE type '%s'.", bhe_type.c_str());
140  }
141  // end of reading BHE parameters -------------------------------------------
142 
143  auto media_map =
145 
146  // find if bhe uses python boundary condition
147  auto const using_python_bcs =
148  visit([](auto const& bhe) { return bhe.use_python_bcs; }, bhes[0]);
149 
151  BHEInflowPythonBoundaryConditionPythonSideInterface* py_object = nullptr;
152  // create a pythonBoundaryCondition object
153  if (using_python_bcs)
154  {
155 #ifdef OGS_USE_PYTHON
156  // Evaluate Python code in scope of main module
157  pybind11::object scope =
158  pybind11::module::import("__main__").attr("__dict__");
159 
160  if (!scope.contains("bc_bhe"))
161  OGS_FATAL(
162  "Function 'bc_bhe' is not defined in the python script file, "
163  "or there "
164  "was no python script file specified.");
165 
166  py_object =
167  scope["bc_bhe"]
168  .cast<BHEInflowPythonBoundaryConditionPythonSideInterface*>();
169 
170  if (py_object == nullptr)
171  OGS_FATAL(
172  "Not able to access the correct bc pointer from python script "
173  "file specified.");
174 
175  // create BHE network dataframe from Python
176  py_object->dataframe_network = py_object->initializeDataContainer();
177  if (!py_object->isOverriddenEssential())
178  {
179  DBUG(
180  "Method `initializeDataContainer' not overridden in Python "
181  "script.");
182  }
183  // clear ogs bc_node_id memory in dataframe
184  std::get<3>(py_object->dataframe_network).clear(); // ogs_bc_node_id
185 
186  // here calls the tespyHydroSolver to get the pipe flow velocity in bhe
187  // network
188  /* for 2U type the flowrate initialization process below causes conflict
189  // replace the value in flow velocity Matrix _u
190  auto const tespy_flow_rate = std::get<4>(py_object->dataframe_network);
191  const std::size_t n_bhe = tespy_flow_rate.size();
192  if (bhes.size() != n_bhe)
193  OGS_FATAL(
194  "The number of BHEs defined in OGS and TESPy are not the "
195  "same!");
196 
197  for (std::size_t idx_bhe = 0; idx_bhe < n_bhe; idx_bhe++)
198  {
199  // the flow_rate in OGS should be updated from the flow_rate
200  // computed by TESPy.
201  auto update_flow_rate = [&](auto& bhe) {
202  bhe.updateHeatTransferCoefficients(tespy_flow_rate[idx_bhe]);
203  };
204  visit(update_flow_rate, bhes[idx_bhe]);
205  }
206  */
207 #else
208  OGS_FATAL(
209  "Input files suggest the coupling of BHE with pipe network. "
210  "This means the compliling flag OGS_USE_PYTHON must be switched "
211  "on. ");
212 #endif // OGS_USE_PYTHON
213  }
214 
215  HeatTransportBHEProcessData process_data(std::move(media_map),
216  std::move(bhes),
217  py_object);
218 
219  SecondaryVariableCollection secondary_variables;
220 
221  ProcessLib::createSecondaryVariables(config, secondary_variables);
222 
223  return std::make_unique<HeatTransportBHEProcess>(
224  std::move(name), mesh, std::move(jacobian_assembler), parameters,
225  integration_order, std::move(process_variables),
226  std::move(process_data), std::move(secondary_variables));
227 }
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)
#define OGS_FATAL(fmt,...)
Definition: Error.h:64

◆ 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.

References ProcessLib::HeatTransportBHE::detail::createLocalAssemblers().

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

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)

◆ 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 50 of file MeshUtils.cpp.

References 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.

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