version 3.11-dev
Loading...
Searching...
No Matches
multistagefvlocaloperator.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//
13#ifndef DUMUX_EXPERIMENTAL_MULTISTAGE_FV_LOCAL_OPERATOR_HH
14#define DUMUX_EXPERIMENTAL_MULTISTAGE_FV_LOCAL_OPERATOR_HH
15
16#include <cmath>
18
19namespace Dumux::Experimental {
20
21template<class LocalOperator>
23{
24 using ElementOperatorResultVector = typename LocalOperator::ElementResidualVector;
25public:
26 // compatibility
27 using ElementResidualVector = ElementOperatorResultVector;
28
29 MultiStageFVLocalOperator(const LocalOperator& op)
30 : op_(op)
31 , spatialWeight_(1.0)
32 , temporalWeight_(1.0)
33 {}
34
35 // discretization-agnostic interface (apart from FV)
36 template<class FVGeometry, class ElemVolVars>
37 ElementOperatorResultVector evalStorage(
38 const FVGeometry& fvGeometry,
39 const ElemVolVars& elemVolVars
40 ) const {
41 ElementOperatorResultVector result(fvGeometry.numScv());
42
43 if (!skipTemporal_)
44 {
45 for (const auto& scv : scvs(fvGeometry))
46 result[scv.localDofIndex()] +=
47 op_.computeStorage(op_.problem(), scv, elemVolVars[scv])
48 * elemVolVars[scv].extrusionFactor()
50 * temporalWeight_;
51 }
52
53 return result;
54 }
55
56 // discretization-agnostic interface (apart from FV)
57 template<class FVGeometry, class ElemVolVars, class ElemFluxVars, class ElemBCTypes>
58 ElementOperatorResultVector evalFluxAndSource(
59 const typename FVGeometry::Element&, // not needed, here for compatibility
60 const FVGeometry& fvGeometry,
61 const ElemVolVars& elemVolVars,
62 const ElemFluxVars& elemFluxVarsCache,
63 const ElemBCTypes& bcTypes
64 ) const {
65 ElementOperatorResultVector result(fvGeometry.numScv());
66 if (!skipSpatial_)
67 {
68 result = op_.evalFluxAndSource(fvGeometry.element(), fvGeometry, elemVolVars, elemFluxVarsCache, bcTypes);
69 for (auto& r : result)
70 r *= spatialWeight_;
71 }
72
73 return result;
74 }
75
76 // interface allowing for optimization when computing the cell-centered finite volume Jacobian
77 template<class Problem, class FVGeometry, class ElemVolVars, class ElemFluxVars>
79 const Problem&, // not needed
80 const typename FVGeometry::Element& element, // can be neighbor
81 const FVGeometry& fvGeometry,
82 const ElemVolVars& elemVolVars,
83 const ElemFluxVars& elemFluxVarsCache,
84 const typename FVGeometry::SubControlVolumeFace& scvf
85 ) const {
86 using NumEqVector = std::decay_t<decltype(op_.evalFlux(op_.problem(), element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf))>;
87 NumEqVector result(0.0);
88 if (!skipSpatial_)
89 {
90 result = op_.evalFlux(op_.problem(), element, fvGeometry, elemVolVars, elemFluxVarsCache, scvf);
91 result *= spatialWeight_;
92 }
93 return result;
94 }
95
97 void spatialWeight(double w, bool skip = false) { spatialWeight_ = w; skipSpatial_ = skip; }
98 double spatialWeight() const { return spatialWeight_; }
99 bool skipSpatial() const { return skipSpatial_; }
100
102 void temporalWeight(double w, bool skip = false) { temporalWeight_ = w; skipTemporal_ = skip; }
103 double temporalWeight() const { return temporalWeight_; }
104 bool skipTemporal() const { return skipTemporal_; }
105
106 const auto& problem() const
107 { return op_.problem(); }
108
109 // some old interface (TODO: get rid of this)
110 // (stationary is also the wrong word by the way, systems with zero
111 // time derivative are in a steady-state but not necessarily stationary/not-moving at all)
112 // can we decide this somehow from the temporal weight?
113 bool isStationary() const
114 { return false; }
115
116private:
117 LocalOperator op_;
118 double spatialWeight_, temporalWeight_; // TODO: get correct type
119 bool skipSpatial_ = false, skipTemporal_ = false;
120};
121
122} // end namespace Dumux::Experimental
123
124#endif
bool skipTemporal() const
Definition multistagefvlocaloperator.hh:104
ElementOperatorResultVector evalFluxAndSource(const typename FVGeometry::Element &, const FVGeometry &fvGeometry, const ElemVolVars &elemVolVars, const ElemFluxVars &elemFluxVarsCache, const ElemBCTypes &bcTypes) const
Definition multistagefvlocaloperator.hh:58
void temporalWeight(double w, bool skip=false)
set the weight of the temporal operator and whether it is structurally zero
Definition multistagefvlocaloperator.hh:102
bool skipSpatial() const
Definition multistagefvlocaloperator.hh:99
bool isStationary() const
Definition multistagefvlocaloperator.hh:113
ElementOperatorResultVector ElementResidualVector
Definition multistagefvlocaloperator.hh:27
double temporalWeight() const
Definition multistagefvlocaloperator.hh:103
ElementOperatorResultVector evalStorage(const FVGeometry &fvGeometry, const ElemVolVars &elemVolVars) const
Definition multistagefvlocaloperator.hh:37
void spatialWeight(double w, bool skip=false)
set the weight of the spatial operator and whether it is structurally zero
Definition multistagefvlocaloperator.hh:97
const auto & problem() const
Definition multistagefvlocaloperator.hh:106
auto evalFlux(const Problem &, const typename FVGeometry::Element &element, const FVGeometry &fvGeometry, const ElemVolVars &elemVolVars, const ElemFluxVars &elemFluxVarsCache, const typename FVGeometry::SubControlVolumeFace &scvf) const
Definition multistagefvlocaloperator.hh:78
double spatialWeight() const
Definition multistagefvlocaloperator.hh:98
MultiStageFVLocalOperator(const LocalOperator &op)
Definition multistagefvlocaloperator.hh:29
Base class for all standard finite volume or finite element problems.
Definition common/problem.hh:39
Helper classes to compute the integration elements.
typename NumEqVectorTraits< PrimaryVariables >::type NumEqVector
A vector with the same size as numbers of equations This is the default implementation and has to be ...
Definition numeqvector.hh:34
Definition assembly/assembler.hh:44
const Scalar PengRobinsonMixture< Scalar, StaticParameters >::w
Definition pengrobinsonmixture.hh:140
std::ranges::range auto scvs(const FVElementGeometry &fvGeometry, const LocalDof &localDof)
Definition localdof.hh:82
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition extrusion.hh:257