Line |
Branch |
Exec |
Source |
1 |
|
|
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
2 |
|
|
// vi: set et ts=4 sw=4 sts=4: |
3 |
|
|
// |
4 |
|
|
// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder |
5 |
|
|
// SPDX-License-Identifier: GPL-3.0-or-later |
6 |
|
|
// |
7 |
|
|
/*! |
8 |
|
|
* \file |
9 |
|
|
* \ingroup CVFEDiscretization |
10 |
|
|
*/ |
11 |
|
|
#ifndef DUMUX_CVFE_LOCAL_VARIABLES_ADAPTER_HH |
12 |
|
|
#define DUMUX_CVFE_LOCAL_VARIABLES_ADAPTER_HH |
13 |
|
|
|
14 |
|
|
#include <dune/common/std/type_traits.hh> |
15 |
|
|
|
16 |
|
|
namespace Dumux::Detail::CVFE { |
17 |
|
|
|
18 |
|
|
//! helper struct detecting if volumeVariables class has update function for scvs (old interface) |
19 |
|
|
template<class Imp, class ES, class P, class FVG, class SCV> |
20 |
|
|
using UpdateFunctionDetector = decltype( |
21 |
|
|
std::declval<Imp>().update(std::declval<ES>(), std::declval<P>(), std::declval<FVG>(), std::declval<SCV>()) |
22 |
|
|
); |
23 |
|
|
|
24 |
|
|
//! Whenever the old interface is supported, we update related to scvs |
25 |
|
|
template<class Imp, class ES, class P, class FVG, class SCV = typename FVG::SubControlVolume> |
26 |
|
|
constexpr inline bool hasUpdateFunctionForScvs() |
27 |
|
|
{ return Dune::Std::is_detected<UpdateFunctionDetector, Imp, ES, P, FVG, SCV>::value; } |
28 |
|
|
|
29 |
|
|
/*! |
30 |
|
|
* \ingroup CVFEDiscretization |
31 |
|
|
* \brief A class for providing the new update interface of variables. This allows to still use the VolumesVariables. |
32 |
|
|
*/ |
33 |
|
|
template <class VolumeVariables> |
34 |
|
2309880 |
class VariablesAdapter : public VolumeVariables |
35 |
|
|
{ |
36 |
|
|
public: |
37 |
|
|
//! export the type used for the primary variables |
38 |
|
|
using PrimaryVariables = typename VolumeVariables::PrimaryVariables; |
39 |
|
|
|
40 |
|
|
//! export the indices type |
41 |
|
|
using Indices = typename VolumeVariables::Indices; |
42 |
|
|
|
43 |
|
|
/*! |
44 |
|
|
* \brief Update all quantities for a given control volume |
45 |
|
|
* |
46 |
|
|
* \param elemSol A vector containing all primary variables connected to the element |
47 |
|
|
* \param problem The object specifying the problem which ought to |
48 |
|
|
* be simulated |
49 |
|
|
* \param fvGeometry The local finite volume geometry |
50 |
|
|
* \param localDof The local dof |
51 |
|
|
*/ |
52 |
|
|
template<class ElementSolution, class Problem, class FVElementGeometry, class LocalDof> |
53 |
|
6135332 |
void update(const ElementSolution& elemSol, |
54 |
|
|
const Problem& problem, |
55 |
|
|
const FVElementGeometry& fvGeometry, |
56 |
|
|
const LocalDof& localDof) |
57 |
|
|
{ |
58 |
|
|
// As default we assume that for each localDof there is a corresponding scv |
59 |
|
|
// such that the update interface of VolumeVariables can still be used. |
60 |
|
|
if constexpr (hasUpdateFunctionForScvs<VolumeVariables, ElementSolution, Problem, FVElementGeometry>()) |
61 |
|
6135332 |
VolumeVariables::update(elemSol, problem, fvGeometry.element(), fvGeometry.scv(localDof.index())); |
62 |
|
|
else |
63 |
|
|
VolumeVariables::update(elemSol, problem, fvGeometry, localDof); |
64 |
|
|
|
65 |
|
2911444 |
}; |
66 |
|
|
}; |
67 |
|
|
|
68 |
|
|
} // end namespace Dumux |
69 |
|
|
|
70 |
|
|
#endif |
71 |
|
|
|