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
8
10{
11template <typename BHEUpdateCallback>
13{
14public:
16 std::pair<GlobalIndexType, GlobalIndexType>&& in_out_global_indices,
17 BHEUpdateCallback bhe_update_callback)
18 : _in_out_global_indices(std::move(in_out_global_indices)),
19 _bhe_update_callback(bhe_update_callback)
20 {
21 }
22
24 const double t, GlobalVector const& x,
25 NumLib::IndexValueVector<GlobalIndexType>& bc_values) const override
26 {
27 bc_values.ids.resize(1);
28 bc_values.values.resize(1);
29
30 bc_values.ids[0] = _in_out_global_indices.first;
31 // here call the corresponding BHE functions
32 auto const T_out = x[_in_out_global_indices.second];
33 bc_values.values[0] = _bhe_update_callback(T_out, t);
34 }
35
36private:
37 std::pair<GlobalIndexType, GlobalIndexType> const _in_out_global_indices;
38 BHEUpdateCallback _bhe_update_callback;
39};
40
41template <typename BHEUpdateCallback>
42std::unique_ptr<BHEInflowDirichletBoundaryCondition<BHEUpdateCallback>>
44 std::pair<GlobalIndexType, GlobalIndexType>&& in_out_global_indices,
45 BHEUpdateCallback bhe_update_callback)
46{
47 DBUG("Constructing BHEInflowDirichletBoundaryCondition.");
48
49 // In case of partitioned mesh the boundary could be empty, i.e. there is no
50 // boundary condition.
51#ifdef USE_PETSC
52 // For this special boundary condition the boundary condition is not empty
53 // if the global indices are non-negative.
54 if (in_out_global_indices.first < 0 && in_out_global_indices.second < 0)
55 {
56 return nullptr;
57 }
58 // If only one of the global indices (in or out) is negative the
59 // implementation is not valid.
60 if (in_out_global_indices.first < 0 || in_out_global_indices.second < 0)
61 {
63 "The partition cuts the BHE into two independent parts. This "
64 "behaviour is not implemented.");
65 }
66#endif // USE_PETSC
67
68 return std::make_unique<
70 std::move(in_out_global_indices), bhe_update_callback);
71}
72} // 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