OGS
BHEInflowDirichletBoundaryCondition.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#pragma once
5
6#include "BaseLib/Error.h"
7#include "BaseLib/Logging.h"
10
12{
13template <typename BHEUpdateCallback>
15{
16public:
18 std::pair<GlobalIndexType, GlobalIndexType>&& in_out_global_indices,
19 BHEUpdateCallback bhe_update_callback)
20 : _in_out_global_indices(std::move(in_out_global_indices)),
21 _bhe_update_callback(bhe_update_callback)
22 {
23 }
24
26 const double t, GlobalVector const& x,
27 NumLib::IndexValueVector<GlobalIndexType>& bc_values) const override
28 {
29 bc_values.ids.resize(1);
30 bc_values.values.resize(1);
31
32 bc_values.ids[0] = _in_out_global_indices.first;
33 // here call the corresponding BHE functions
34 auto const T_out = x[_in_out_global_indices.second];
35 bc_values.values[0] = _bhe_update_callback(T_out, t);
36 }
37
38private:
39 std::pair<GlobalIndexType, GlobalIndexType> const _in_out_global_indices;
40 BHEUpdateCallback _bhe_update_callback;
41};
42
43template <typename BHEUpdateCallback>
44std::unique_ptr<BHEInflowDirichletBoundaryCondition<BHEUpdateCallback>>
46 std::pair<GlobalIndexType, GlobalIndexType>&& in_out_global_indices,
47 BHEUpdateCallback bhe_update_callback)
48{
49 DBUG("Constructing BHEInflowDirichletBoundaryCondition.");
50
51 // In case of partitioned mesh the boundary could be empty, i.e. there is no
52 // boundary condition.
53#ifdef USE_PETSC
54 // For this special boundary condition the boundary condition is not empty
55 // if the global indices are non-negative.
56 if (in_out_global_indices.first < 0 && in_out_global_indices.second < 0)
57 {
58 return nullptr;
59 }
60 // If only one of the global indices (in or out) is negative the
61 // implementation is not valid.
62 if (in_out_global_indices.first < 0 || in_out_global_indices.second < 0)
63 {
65 "The partition cuts the BHE into two independent parts. This "
66 "behaviour is not implemented.");
67 }
68#endif // USE_PETSC
69
70 return std::make_unique<
72 std::move(in_out_global_indices), bhe_update_callback);
73}
74} // namespace ProcessLib::HeatTransportBHE
#define OGS_FATAL(...)
Definition Error.h:19
MathLib::EigenVector GlobalVector
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:22
BHEInflowDirichletBoundaryCondition(std::pair< GlobalIndexType, GlobalIndexType > &&in_out_global_indices, BHEUpdateCallback bhe_update_callback)
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::unique_ptr< BHEInflowDirichletBoundaryCondition< BHEUpdateCallback > > createBHEInflowDirichletBoundaryCondition(std::pair< GlobalIndexType, GlobalIndexType > &&in_out_global_indices, BHEUpdateCallback bhe_update_callback)
std::vector< IndexType > ids
std::vector< double > values