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 template<class ElementSolution, class Problem, class FVElementGeometry, Concept::LocalDofIpData IpData>
54 void update(const ElementSolution& elemSol,
55 const Problem& problem,
56 const FVElementGeometry& fvGeometry,
57 const IpData& ipData)
58 {
59 // As default we assume that for each localDof there is a corresponding scv
60 // such that the update interface of VolumeVariables can still be used.
61 if constexpr (hasUpdateFunctionForScvs<VolumeVariables, ElementSolution, Problem,
62 typename FVElementGeometry::Element, typename FVElementGeometry::SubControlVolume>())
63 VolumeVariables::update(elemSol, problem, fvGeometry.element(), fvGeometry.scv(ipData.localDofIndex()));
64 else
65 VolumeVariables::update(elemSol, problem, fvGeometry, ipData);
66 };
67};
68
69} // end namespace Dumux
70
71#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)
Update all quantities for a given control volume.
Definition: variablesadapter.hh:54
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