version 3.11-dev
variablesadapter.hh
Go to the documentation of this file.
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//
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#include <dumux/common/concepts/ipdata_.hh>
16
17namespace Dumux::Detail::CVFE {
18
20template<class Imp, class ES, class P, class E, class SCV>
21using UpdateFunctionDetector = decltype(
22 std::declval<Imp>().update(std::declval<ES>(), std::declval<P>(), std::declval<E>(), std::declval<SCV>())
23);
24
26template<class Imp, class ES, class P, class E, class SCV>
27constexpr inline bool hasUpdateFunctionForScvs()
28{ return Dune::Std::is_detected<UpdateFunctionDetector, Imp, ES, P, E, SCV>::value; }
29
34template <class VolumeVariables>
35class VariablesAdapter : public VolumeVariables
36{
37public:
39 using PrimaryVariables = typename VolumeVariables::PrimaryVariables;
40
42 using Indices = typename VolumeVariables::Indices;
43
53 using VolumeVariables::update;
54 template<class ElementSolution, class Problem, class FVElementGeometry, Concept::LocalDofIpData IpData>
55 void update(const ElementSolution& elemSol,
56 const Problem& problem,
57 const FVElementGeometry& fvGeometry,
58 const IpData& ipData)
59 {
60 // As default we assume that for each localDof there is a corresponding scv
61 // such that the update interface of VolumeVariables can still be used.
62 if constexpr (hasUpdateFunctionForScvs<VolumeVariables, ElementSolution, Problem,
63 typename FVElementGeometry::Element, typename FVElementGeometry::SubControlVolume>())
64 VolumeVariables::update(elemSol, problem, fvGeometry.element(), fvGeometry.scv(ipData.localDofIndex()));
65 else
66 VolumeVariables::update(elemSol, problem, fvGeometry, ipData);
67 };
68};
69
70} // end namespace Dumux
71
72#endif
A class for providing the new update interface of variables. This allows to still use the VolumesVari...
Definition: variablesadapter.hh:36
typename VolumeVariables::Indices Indices
export the indices type
Definition: variablesadapter.hh:42
typename VolumeVariables::PrimaryVariables PrimaryVariables
export the type used for the primary variables
Definition: variablesadapter.hh:39
void update(const ElementSolution &elemSol, const Problem &problem, const FVElementGeometry &fvGeometry, const IpData &ipData)
Definition: variablesadapter.hh:55
Definition: elementvariables.hh:24
decltype(std::declval< Imp >().update(std::declval< ES >(), std::declval< P >(), std::declval< E >(), std::declval< SCV >())) UpdateFunctionDetector
helper struct detecting if volumeVariables class has update function for scvs (old interface)
Definition: variablesadapter.hh:23
constexpr bool hasUpdateFunctionForScvs()
Whenever the old interface is supported, we update related to scvs.
Definition: variablesadapter.hh:27