12#ifndef DUMUX_CVFE_ELEMENT_SOLUTION_HH
13#define DUMUX_CVFE_ELEMENT_SOLUTION_HH
16#include <dune/common/reservedvector.hh>
19#include <dumux/common/typetraits/localdofs_.hh>
27template<
class ElementVariables>
30 if constexpr (
requires {
typename ElementVariables::Variables::PrimaryVariables; })
31 return std::type_identity<typename ElementVariables::Variables::PrimaryVariables>{};
32 else if constexpr (
requires {
typename ElementVariables::VolumeVariables::PrimaryVariables; })
33 return std::type_identity<typename ElementVariables::VolumeVariables::PrimaryVariables>{};
35 return std::type_identity<void>{};
38template<
class ElementVariables>
47template<
class FVElementGeometry,
class PV>
50 using GridGeometry =
typename FVElementGeometry::GridGeometry;
51 using GridView =
typename GridGeometry::GridView;
52 using Element =
typename GridView::template Codim<0>::Entity;
54 static constexpr int dim = GridView::dimension;
57 static constexpr int maxNumLocalDofs = Detail::LocalDofs::maxNumLocalDofs<FVElementGeometry>();
67 template<
class SolutionVector>
69 const GridGeometry& gridGeometry)
71 update(element, sol, gridGeometry);
75 template<
class ElementVariables>
77 const FVElementGeometry& fvGeometry)
79 priVars_.resize(Detail::LocalDofs::numLocalDofs(fvGeometry));
80 for (
const auto& localDof :
localDofs(fvGeometry))
81 priVars_[localDof.index()] = elemVars[localDof.index()].priVars();
85 template<
class SolutionVector>
86 void update(
const Element& element,
const SolutionVector& sol,
87 const GridGeometry& gridGeometry)
96 const auto& localCoeff = gridGeometry.feCache().get(element.type()).localCoefficients();
97 priVars_.resize(localCoeff.size());
98 for (
int localDofIdx = 0; localDofIdx < localCoeff.size(); ++localDofIdx)
100 const auto& localKey = localCoeff.localKey(localDofIdx);
101 if constexpr (
requires { gridGeometry.dofIndex(element, localKey); })
102 priVars_[localDofIdx] = sol[gridGeometry.dofIndex(element, localKey)];
104 priVars_[localDofIdx] = sol[
105 gridGeometry.dofMapper().subIndex(
106 element, localKey.subEntity(), localKey.codim()
113 template<
class SolutionVector>
114 void update(
const Element& element,
const SolutionVector& sol,
115 const FVElementGeometry& fvGeometry)
117 priVars_.resize(Detail::LocalDofs::numLocalDofs(fvGeometry));
118 for (
const auto& localDof :
localDofs(fvGeometry))
119 priVars_[localDof.index()] = sol[localDof.dofIndex()];
124 {
return priVars_.size(); }
127 template<
typename IndexType>
129 {
return priVars_[i]; }
132 template<
typename IndexType>
134 {
return priVars_[i]; }
137 Dune::ReservedVector<PrimaryVariables, maxNumLocalDofs> priVars_;
141template<
class Element,
class SolutionVector,
class Gr
idGeometry>
142auto elementSolution(
const Element& element,
const SolutionVector& sol,
const GridGeometry& gg)
143-> std::enable_if_t<DiscretizationMethods::isCVFE<typename GridGeometry::DiscretizationMethod>,
145 std::decay_t<decltype(std::declval<SolutionVector>()[0])>>
148 using PrimaryVariables = std::decay_t<decltype(std::declval<SolutionVector>()[0])>;
153template<
class Element,
class ElementVariables,
class FVElementGeometry>
154 requires ((
requires {
typename FVElementGeometry::GridDiscretization; }
155 ||
requires {
typename FVElementGeometry::GridGeometry; })
157 && !std::is_void_v<Detail::PrimaryVariables_t<ElementVariables>>)
158auto elementSolution(
const Element& element,
const ElementVariables& elemVars,
const FVElementGeometry& gg)
The element solution vector.
Definition cvfe/elementsolution.hh:49
CVFEElementSolution(const Element &element, const ElementVariables &elemVars, const FVElementGeometry &fvGeometry)
Constructor with element and elemVolVars and fvGeometry.
Definition cvfe/elementsolution.hh:76
const PrimaryVariables & operator[](IndexType i) const
bracket operator const access
Definition cvfe/elementsolution.hh:128
PV PrimaryVariables
export the primary variables type
Definition cvfe/elementsolution.hh:61
CVFEElementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gridGeometry)
Constructor with element and solution and grid geometry.
Definition cvfe/elementsolution.hh:68
void update(const Element &element, const SolutionVector &sol, const FVElementGeometry &fvGeometry)
extract the element solution from the solution vector using a local fv geometry
Definition cvfe/elementsolution.hh:114
std::size_t size() const
return the size of the element solution
Definition cvfe/elementsolution.hh:123
void update(const Element &element, const SolutionVector &sol, const GridGeometry &gridGeometry)
extract the element solution from the solution vector using a mapper
Definition cvfe/elementsolution.hh:86
CVFEElementSolution()=default
Default constructor.
Type traits for classes providing a grid discretization.
auto elementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gg) -> std::enable_if_t< GridGeometry::discMethod==DiscretizationMethods::cctpfa||GridGeometry::discMethod==DiscretizationMethods::ccmpfa, CCElementSolution< typename GridGeometry::LocalView, std::decay_t< decltype(std::declval< SolutionVector >()[0])> > >
Make an element solution for cell-centered schemes.
Definition cellcentered/elementsolution.hh:101
Class representing dofs on elements for control-volume finite element schemes.
The available discretization methods in Dumux.
Definition cvfelocalresidual.hh:25
constexpr auto primaryVariablesType()
Definition cvfe/elementsolution.hh:28
typename decltype(primaryVariablesType< ElementVariables >())::type PrimaryVariables_t
Definition cvfe/elementsolution.hh:39
constexpr bool isCVFE
Definition method.hh:67
auto localDofs(const FVElementGeometry &fvGeometry)
range over local dofs
Definition localdof.hh:50