version 3.8
cellcentered/elementsolution.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-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_CC_ELEMENT_SOLUTION_HH
13#define DUMUX_CC_ELEMENT_SOLUTION_HH
14
15#include <cassert>
16#include <utility>
17#include <type_traits>
19
20namespace Dumux {
21
26template<class FVElementGeometry, class PV>
28{
29 using GridGeometry = typename FVElementGeometry::GridGeometry;
30 using GridView = typename GridGeometry::GridView;
31 using Element = typename GridView::template Codim<0>::Entity;
32
33public:
35 using PrimaryVariables = PV;
36
38 CCElementSolution() = default;
39
41 template<class SolutionVector>
42 CCElementSolution(const Element& element, const SolutionVector& sol,
43 const GridGeometry& gridGeometry)
44 : CCElementSolution(sol[gridGeometry.elementMapper().index(element)])
45 {}
46
48 template<class ElementVolumeVariables>
49 CCElementSolution(const Element& element, const ElementVolumeVariables& elemVolVars,
50 const FVElementGeometry& fvGeometry)
51 {
52 for (const auto& scv : scvs(fvGeometry))
53 priVars_ = elemVolVars[scv].priVars();
54 }
55
58 : priVars_(std::move(priVars)) {}
59
62 : priVars_(priVars) {}
63
65 template<class SolutionVector>
66 void update(const Element& element, const SolutionVector& sol,
67 const GridGeometry& gridGeometry)
68 {
69 priVars_ = sol[gridGeometry.elementMapper().index(element)];
70 }
71
73 constexpr std::size_t size() const
74 { return 1; }
75
77 template<typename IndexType>
78 const PrimaryVariables& operator [](IndexType i) const
79 {
80 assert(i == 0 && "Index exceeds valid range!");
81 return priVars_;
82 }
83
85 template<typename IndexType>
87 {
88 assert(i == 0 && "Index exceeds valid range!");
89 return priVars_;
90 }
91
92private:
93 PrimaryVariables priVars_;
94};
95
100template<class Element, class SolutionVector, class GridGeometry>
101auto elementSolution(const Element& element, const SolutionVector& sol, const GridGeometry& gg)
102-> std::enable_if_t<GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
103 GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
104 CCElementSolution<typename GridGeometry::LocalView,
105 std::decay_t<decltype(std::declval<SolutionVector>()[0])>>
106 >
107{
108 using PrimaryVariables = std::decay_t<decltype(std::declval<SolutionVector>()[0])>;
110}
111
116template<class Element, class ElementVolumeVariables, class FVElementGeometry>
117auto elementSolution(const Element& element, const ElementVolumeVariables& elemVolVars, const FVElementGeometry& gg)
118-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
119 FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
121{
122 using PrimaryVariables = typename ElementVolumeVariables::VolumeVariables::PrimaryVariables;
123 return CCElementSolution<FVElementGeometry, PrimaryVariables>(element, elemVolVars, gg);
124}
125
131template<class FVElementGeometry, class PrimaryVariables>
132auto elementSolution(PrimaryVariables&& priVars)
133-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
134 FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
136{
138}
139
145template<class FVElementGeometry, class PrimaryVariables>
146auto elementSolution(const PrimaryVariables& priVars)
147-> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::cctpfa ||
148 FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::ccmpfa,
150{
152}
153
154} // end namespace Dumux
155
156#endif
The element solution vector.
Definition: cellcentered/elementsolution.hh:28
CCElementSolution(PrimaryVariables &&priVars)
Constructor with a primary variable object.
Definition: cellcentered/elementsolution.hh:57
const PrimaryVariables & operator[](IndexType i) const
bracket operator const access
Definition: cellcentered/elementsolution.hh:78
CCElementSolution(const Element &element, const SolutionVector &sol, const GridGeometry &gridGeometry)
Constructor with element, solution vector and grid geometry.
Definition: cellcentered/elementsolution.hh:42
constexpr std::size_t size() const
return the size of the element solution
Definition: cellcentered/elementsolution.hh:73
void update(const Element &element, const SolutionVector &sol, const GridGeometry &gridGeometry)
extract the element solution from the solution vector using a mapper
Definition: cellcentered/elementsolution.hh:66
CCElementSolution(const Element &element, const ElementVolumeVariables &elemVolVars, const FVElementGeometry &fvGeometry)
Constructor with element, element volume variables and fv element geometry.
Definition: cellcentered/elementsolution.hh:49
PV PrimaryVariables
export the primary variables type
Definition: cellcentered/elementsolution.hh:35
CCElementSolution(const PrimaryVariables &priVars)
Constructor with a primary variable object.
Definition: cellcentered/elementsolution.hh:61
CCElementSolution()=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
The available discretization methods in Dumux.
constexpr CCMpfa ccmpfa
Definition: method.hh:146
constexpr CCTpfa cctpfa
Definition: method.hh:145
Definition: adapt.hh:17