OGS 6.1.0-1699-ge946d4c5f
BHEInflowDirichletBoundaryCondition.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include "BoundaryCondition.h"
15 
16 namespace ProcessLib
17 {
18 template <typename BHEType>
20 {
21 public:
23  std::pair<GlobalIndexType, GlobalIndexType>&& in_out_global_indices,
24  BHEType& bhe)
25  : _in_out_global_indices(std::move(in_out_global_indices)), _bhe(bhe)
26  {
27  }
28 
30  const double t, GlobalVector const& x,
31  NumLib::IndexValueVector<GlobalIndexType>& bc_values) const override
32  {
33  bc_values.ids.resize(1);
34  bc_values.values.resize(1);
35 
36  bc_values.ids[0] = _in_out_global_indices.first;
37  // here call the corresponding BHE functions
38  auto const T_out = x[_in_out_global_indices.second];
39  bc_values.values[0] = _bhe.updateFlowRateAndTemperature(T_out, t);
40  }
41 
42 private:
43  std::pair<GlobalIndexType, GlobalIndexType> const _in_out_global_indices;
44  BHEType& _bhe;
45 };
46 
47 template <typename BHEType>
48 std::unique_ptr<BHEInflowDirichletBoundaryCondition<BHEType>>
50  std::pair<GlobalIndexType, GlobalIndexType>&& in_out_global_indices,
51  BHEType& bhe)
52 {
53  DBUG("Constructing BHEInflowDirichletBoundaryCondition.");
54 
55  // In case of partitioned mesh the boundary could be empty, i.e. there is no
56  // boundary condition.
57 #ifdef USE_PETSC
58  // For this special boundary condition the boundary condition is not empty
59  // if the global indices are non-negative.
60  if (in_out_global_indices.first < 0 && in_out_global_indices.second < 0)
61  {
62  return nullptr;
63  }
64  // If only one of the global indices (in or out) is negative the
65  // implementation is not valid.
66  if (in_out_global_indices.first < 0 || in_out_global_indices.second < 0)
67  {
68  OGS_FATAL(
69  "The partition cuts the BHE into two independent parts. This "
70  "behaviour is not implemented.");
71  }
72 #endif // USE_PETSC
73 
74  return std::make_unique<BHEInflowDirichletBoundaryCondition<BHEType>>(
75  std::move(in_out_global_indices), bhe);
76 }
77 } // namespace ProcessLib
std::unique_ptr< BHEInflowDirichletBoundaryCondition< BHEType > > createBHEInflowDirichletBoundaryCondition(std::pair< GlobalIndexType, GlobalIndexType > &&in_out_global_indices, BHEType &bhe)
void getEssentialBCValues(const double t, GlobalVector const &x, NumLib::IndexValueVector< GlobalIndexType > &bc_values) const override
Writes the values of essential BCs to bc_values.
std::vector< IndexType > ids
BHEInflowDirichletBoundaryCondition(std::pair< GlobalIndexType, GlobalIndexType > &&in_out_global_indices, BHEType &bhe)
#define OGS_FATAL(fmt,...)
Definition: Error.h:71
std::vector< double > values
std::pair< GlobalIndexType, GlobalIndexType > const _in_out_global_indices