12#ifndef DUMUX_CVFE_ELEMENT_SOLUTION_HH
13#define DUMUX_CVFE_ELEMENT_SOLUTION_HH
16#include <dune/common/reservedvector.hh>
18#include <dumux/common/typetraits/localdofs_.hh>
28template<
class FVElementGeometry,
class PV>
31 using GridGeometry =
typename FVElementGeometry::GridGeometry;
32 using GridView =
typename GridGeometry::GridView;
33 using Element =
typename GridView::template Codim<0>::Entity;
35 static constexpr int dim = GridView::dimension;
38 static constexpr int maxNumLocalDofs = Detail::LocalDofs::maxNumLocalDofs<FVElementGeometry>();
48 template<
class SolutionVector>
50 const GridGeometry& gridGeometry)
52 update(element, sol, gridGeometry);
56 template<
class ElementVariables>
58 const FVElementGeometry& fvGeometry)
60 priVars_.resize(Detail::LocalDofs::numLocalDofs(fvGeometry));
61 for (
const auto& localDof :
localDofs(fvGeometry))
62 priVars_[localDof.index()] = elemVars[localDof.index()].priVars();
66 template<
class SolutionVector>
67 void update(
const Element& element,
const SolutionVector& sol,
68 const GridGeometry& gridGeometry)
73 const auto& localCoeff = gridGeometry.feCache().get(element.type()).localCoefficients();
74 priVars_.resize(localCoeff.size());
75 for (
int localDofIdx = 0; localDofIdx < localCoeff.size(); ++localDofIdx)
77 const auto& localKey = localCoeff.localKey(localDofIdx);
78 priVars_[localDofIdx] = sol[
79 gridGeometry.dofMapper().subIndex(
80 element, localKey.subEntity(), localKey.codim()
87 template<
class SolutionVector>
88 void update(
const Element& element,
const SolutionVector& sol,
89 const FVElementGeometry& fvGeometry)
91 priVars_.resize(Detail::LocalDofs::numLocalDofs(fvGeometry));
92 for (
const auto& localDof :
localDofs(fvGeometry))
93 priVars_[localDof.index()] = sol[localDof.dofIndex()];
98 {
return priVars_.size(); }
101 template<
typename IndexType>
103 {
return priVars_[i]; }
106 template<
typename IndexType>
108 {
return priVars_[i]; }
111 Dune::ReservedVector<PrimaryVariables, maxNumLocalDofs> priVars_;
115template<
class Element,
class SolutionVector,
class Gr
idGeometry>
116auto elementSolution(
const Element& element,
const SolutionVector& sol,
const GridGeometry& gg)
117-> std::enable_if_t<DiscretizationMethods::isCVFE<typename GridGeometry::DiscretizationMethod>,
118 CVFEElementSolution<
typename GridGeometry::LocalView,
119 std::decay_t<decltype(std::declval<SolutionVector>()[0])>>
122 using PrimaryVariables = std::decay_t<decltype(std::declval<SolutionVector>()[0])>;
123 return CVFEElementSolution<typename GridGeometry::LocalView, PrimaryVariables>(element, sol, gg);
127template<
class Element,
class ElementVolumeVariables,
class FVElementGeometry>
128auto elementSolution(
const Element& element,
const ElementVolumeVariables& elemVolVars,
const FVElementGeometry& gg)
129-> std::enable_if_t<DiscretizationMethods::isCVFE<typename FVElementGeometry::GridGeometry::DiscretizationMethod>,
130 CVFEElementSolution<FVElementGeometry,
131 typename ElementVolumeVariables::VolumeVariables::PrimaryVariables>>
133 using PrimaryVariables =
typename ElementVolumeVariables::VolumeVariables::PrimaryVariables;
134 return CVFEElementSolution<FVElementGeometry, PrimaryVariables>(element, elemVolVars, gg);
The element solution vector.
Definition: cvfe/elementsolution.hh:30
CVFEElementSolution(const Element &element, const ElementVariables &elemVars, const FVElementGeometry &fvGeometry)
Constructor with element and elemVolVars and fvGeometry.
Definition: cvfe/elementsolution.hh:57
const PrimaryVariables & operator[](IndexType i) const
bracket operator const access
Definition: cvfe/elementsolution.hh:102
PV PrimaryVariables
export the primary variables type
Definition: cvfe/elementsolution.hh:42
CVFEElementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gridGeometry)
Constructor with element and solution and grid geometry.
Definition: cvfe/elementsolution.hh:49
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:88
std::size_t size() const
return the size of the element solution
Definition: cvfe/elementsolution.hh:97
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:67
CVFEElementSolution()=default
Default constructor.
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.
auto localDofs(const FVElementGeometry &fvGeometry)
range over local dofs
Definition: localdof.hh:50