version 3.11-dev
discretization/cvfe/hybrid/fluxvariablescache.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//
12#ifndef DUMUX_DISCRETIZATION_HYBRID_CVFE_FLUXVARIABLES_CACHE_HH
13#define DUMUX_DISCRETIZATION_HYBRID_CVFE_FLUXVARIABLES_CACHE_HH
14
15#include <vector>
16
17#include <dune/common/fvector.hh>
18#include <dumux/common/typetraits/localdofs_.hh>
19#include <dumux/common/concepts/ipdata_.hh>
21
22namespace Dumux {
23
30template< class Scalar, class GridGeometry >
32{
33 using GridView = typename GridGeometry::GridView;
34 using Element = typename GridView::template Codim<0>::Entity;
35 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
36 using LocalPosition = typename Element::Geometry::LocalCoordinate;
37
38 using FVElementGeometry = typename GridGeometry::LocalView;
39 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
40
41 static const int dim = GridView::dimension;
42 static const int dimWorld = GridView::dimensionworld;
43
44 using CoordScalar = typename GridView::ctype;
45 using FeLocalBasis = typename GridGeometry::FeCache::FiniteElementType::Traits::LocalBasisType;
46 using ShapeJacobian = typename FeLocalBasis::Traits::JacobianType;
47 using ShapeValue = typename Dune::FieldVector<Scalar, 1>;
48 using JacobianInverseTransposed = typename Element::Geometry::JacobianInverseTransposed;
49
50public:
51 using ScvfQuadratureRule = typename GridGeometry::ScvfQuadratureRule;
52
54 static bool constexpr isSolDependent = false;
55
57 template< class Problem, class ElementVolumeVariables >
58 void update(const Problem& problem,
59 const Element& element,
60 const FVElementGeometry& fvGeometry,
61 const ElementVolumeVariables& elemVolVars,
62 const GlobalPosition& globalPos)
63 {
64 update_(fvGeometry, fvGeometry.elementGeometry().local(globalPos), globalPos);
65 }
66
68 template< class Problem, class ElementVolumeVariables, Concept::IpData IpData >
69 void update(const Problem& problem,
70 const Element& element,
71 const FVElementGeometry& fvGeometry,
72 const ElementVolumeVariables& elemVolVars,
73 const IpData& ipData)
74 {
75 update_(fvGeometry, ipData.local(), ipData.global());
76 }
77
79 const GlobalPosition& ipGlobal() const { return ipGlobal_; }
81 const LocalPosition& ipLocal() const { return ipLocal_; }
83 const std::vector<ShapeJacobian>& shapeJacobian() const { return shapeJacobian_; }
85 const std::vector<ShapeValue>& shapeValues() const { return shapeValues_; }
87 const JacobianInverseTransposed& jacInvT() const { return jacInvT_; }
89 const GlobalPosition& gradN(unsigned int scvIdxInElement) const { return gradN_[scvIdxInElement]; }
90
91private:
93 void update_(const FVElementGeometry& fvGeometry,
94 const LocalPosition& localPos,
95 const GlobalPosition& globalPos)
96 {
97 const auto& geometry = fvGeometry.elementGeometry();
98 const auto& localBasis = fvGeometry.feLocalBasis();
99
100 // evaluate shape functions and gradients at the interpolation point
101 ipGlobal_ = globalPos;
102 ipLocal_ = localPos;
103 jacInvT_ = geometry.jacobianInverseTransposed(ipLocal_);
104 localBasis.evaluateJacobian(ipLocal_, shapeJacobian_);
105 localBasis.evaluateFunction(ipLocal_, shapeValues_); // shape values for rho
106
107 // compute the gradN at for every scv/dof
108 gradN_.resize(Detail::LocalDofs::numLocalDofs(fvGeometry));
109 for (const auto& localDof: localDofs(fvGeometry))
110 jacInvT_.mv(shapeJacobian_[localDof.index()][0], gradN_[localDof.index()]);
111 }
112
113 std::vector<GlobalPosition> gradN_;
114 std::vector<ShapeJacobian> shapeJacobian_;
115 std::vector<ShapeValue> shapeValues_;
116 JacobianInverseTransposed jacInvT_;
117 GlobalPosition ipGlobal_;
118 LocalPosition ipLocal_;
119};
120
121} // end namespace Dumux
122
123#endif
Flux variables cache class for control-volume finite element schemes. For control-volume finite eleme...
Definition: discretization/cvfe/hybrid/fluxvariablescache.hh:32
static bool constexpr isSolDependent
whether the cache needs an update when the solution changes
Definition: discretization/cvfe/hybrid/fluxvariablescache.hh:54
const LocalPosition & ipLocal() const
returns the local position for which this cache has been updated
Definition: discretization/cvfe/hybrid/fluxvariablescache.hh:81
const GlobalPosition & gradN(unsigned int scvIdxInElement) const
returns the shape function gradients in global coordinates at the interpolation point
Definition: discretization/cvfe/hybrid/fluxvariablescache.hh:89
const std::vector< ShapeJacobian > & shapeJacobian() const
returns the shape function gradients in local coordinates at the interpolation point
Definition: discretization/cvfe/hybrid/fluxvariablescache.hh:83
const JacobianInverseTransposed & jacInvT() const
returns inverse transposed jacobian at the interpolation point
Definition: discretization/cvfe/hybrid/fluxvariablescache.hh:87
const std::vector< ShapeValue > & shapeValues() const
returns the shape function values at the interpolation point
Definition: discretization/cvfe/hybrid/fluxvariablescache.hh:85
const GlobalPosition & ipGlobal() const
returns the global position for which this cache has been updated
Definition: discretization/cvfe/hybrid/fluxvariablescache.hh:79
void update(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const GlobalPosition &globalPos)
update the cache for a given global position
Definition: discretization/cvfe/hybrid/fluxvariablescache.hh:58
void update(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const IpData &ipData)
update the cache for interpolation point data
Definition: discretization/cvfe/hybrid/fluxvariablescache.hh:69
typename GridGeometry::ScvfQuadratureRule ScvfQuadratureRule
Definition: discretization/cvfe/hybrid/fluxvariablescache.hh:51
Class representing dofs on elements for control-volume finite element schemes.
Definition: adapt.hh:17
auto localDofs(const FVElementGeometry &fvGeometry)
range over local dofs
Definition: localdof.hh:50