3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
test/freeflow/navierstokes/sincos/problem.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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
25#ifndef DUMUX_SINCOS_TEST_PROBLEM_HH
26#define DUMUX_SINCOS_TEST_PROBLEM_HH
27
28#include <dune/grid/yaspgrid.hh>
29
32
36#include "../l2error.hh"
37
38namespace Dumux {
39template <class TypeTag>
40class SincosTestProblem;
41
42namespace Properties {
43// Create new type tags
44namespace TTag {
45struct SincosTest { using InheritsFrom = std::tuple<NavierStokes, StaggeredFreeFlowModel>; };
46} // end namespace TTag
47
48// the fluid system
49template<class TypeTag>
50struct FluidSystem<TypeTag, TTag::SincosTest>
51{
52private:
54public:
56};
57
58// Set the grid type
59template<class TypeTag>
60struct Grid<TypeTag, TTag::SincosTest> { using type = Dune::YaspGrid<2, Dune::EquidistantOffsetCoordinates<GetPropType<TypeTag, Properties::Scalar>, 2> >; };
61
62// Set the problem property
63template<class TypeTag>
64struct Problem<TypeTag, TTag::SincosTest> { using type = Dumux::SincosTestProblem<TypeTag> ; };
65
66template<class TypeTag>
67struct EnableGridGeometryCache<TypeTag, TTag::SincosTest> { static constexpr bool value = true; };
68template<class TypeTag>
69struct EnableGridFluxVariablesCache<TypeTag, TTag::SincosTest> { static constexpr bool value = true; };
70template<class TypeTag>
71struct EnableGridVolumeVariablesCache<TypeTag, TTag::SincosTest> { static constexpr bool value = true; };
72} // end namespace Properties
73
83template <class TypeTag>
85{
86 using ParentType = NavierStokesProblem<TypeTag>;
87
94 using TimeLoopPtr = std::shared_ptr<TimeLoop<Scalar>>;
95 using SubControlVolume = typename GridGeometry::SubControlVolume;
96 using FVElementGeometry = typename GridGeometry::LocalView;
97
99 using Element = typename GridGeometry::GridView::template Codim<0>::Entity;
100 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
101 using VelocityVector = Dune::FieldVector<Scalar, dimWorld>;
102
103public:
106
107 SincosTestProblem(std::shared_ptr<const GridGeometry> gridGeometry)
108 : ParentType(gridGeometry), time_(0.0), timeStepSize_(0.0)
109 {
110 isStationary_ = getParam<bool>("Problem.IsStationary");
111 enableInertiaTerms_ = getParam<bool>("Problem.EnableInertiaTerms");
112 kinematicViscosity_ = getParam<Scalar>("Component.LiquidKinematicViscosity", 1.0);
113 }
114
120 Scalar temperature() const
121 { return 298.0; }
122
128 NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
129 {
130 NumEqVector source(0.0);
131 const Scalar x = globalPos[0];
132 const Scalar y = globalPos[1];
133 const Scalar t = time_ + timeStepSize_;
134
135 using std::cos;
136 using std::sin;
137
138 if (isStationary_)
139 {
140 source[Indices::momentumXBalanceIdx] = -2.0 * kinematicViscosity_ * cos(x) * sin(y);
141 source[Indices::momentumYBalanceIdx] = 2.0 * kinematicViscosity_ * cos(y) * sin(x);
142
143 if (!enableInertiaTerms_)
144 {
145 source[Indices::momentumXBalanceIdx] += 0.5 * sin(2.0 * x);
146 source[Indices::momentumYBalanceIdx] += 0.5 * sin(2.0 * y);
147 }
148 }
149 else
150 {
151 source[Indices::momentumXBalanceIdx] = -2.0 * cos(x) * sin(y) * (cos(2.0 * t) + sin(2.0 * t) * kinematicViscosity_);
152 source[Indices::momentumYBalanceIdx] = 2.0 * sin(x) * cos(y) * (cos(2.0 * t) + sin(2.0 * t) * kinematicViscosity_);
153 }
154
155 return source;
156 }
157
158 // \}
162 // \{
163
170 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
171 {
172 BoundaryTypes values;
173
174 // set Dirichlet values for the velocity everywhere
175 values.setDirichlet(Indices::velocityXIdx);
176 values.setDirichlet(Indices::velocityYIdx);
177
178 return values;
179 }
180
189 bool isDirichletCell(const Element& element,
190 const FVElementGeometry& fvGeometry,
191 const SubControlVolume& scv,
192 int pvIdx) const
193 {
194 // set fixed pressure in one cell
195 return (scv.dofIndex() == 0) && pvIdx == Indices::pressureIdx;
196 }
197
203 PrimaryVariables dirichletAtPos(const GlobalPosition & globalPos) const
204 {
205 // use the values of the analytical solution
206 return analyticalSolution(globalPos, time_+timeStepSize_);
207 }
208
215 PrimaryVariables analyticalSolution(const GlobalPosition& globalPos, const Scalar time) const
216 {
217 const Scalar x = globalPos[0];
218 const Scalar y = globalPos[1];
219
220 const Scalar t = time;
221
222 PrimaryVariables values;
223
224 using std::sin;
225 using std::cos;
226
227 values[Indices::pressureIdx] = -0.25 * (cos(2.0 * x) + cos(2.0 * y));
228 values[Indices::velocityXIdx] = -1.0 * cos(x) * sin(y);
229 values[Indices::velocityYIdx] = sin(x) * cos(y);
230
231 if (!isStationary_)
232 {
233 values[Indices::pressureIdx] *= sin(2.0 * t) * sin(2.0 * t);
234 values[Indices::velocityXIdx] *= sin(2.0 * t);
235 values[Indices::velocityYIdx] *= sin(2.0 * t);
236 }
237
238 return values;
239 }
240
241 // \}
242
246 // \{
247
253 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
254 {
255 if (isStationary_)
256 {
257 PrimaryVariables values;
258 values[Indices::pressureIdx] = 0.0;
259 values[Indices::velocityXIdx] = 0.0;
260 values[Indices::velocityYIdx] = 0.0;
261
262 return values;
263 }
264 else
265 {
266 return analyticalSolution(globalPos, 0.0);
267 }
268 }
269
273 void updateTime(const Scalar time)
274 {
275 time_ = time;
276 }
277
281 void updateTimeStepSize(const Scalar timeStepSize)
282 {
283 timeStepSize_ = timeStepSize;
284 }
285
286private:
287 static constexpr Scalar eps_ = 1e-6;
288
289 Scalar kinematicViscosity_;
290 bool enableInertiaTerms_;
291 Scalar time_;
292 Scalar timeStepSize_;
293
294 bool isStationary_;
295};
296
297} // end namespace Dumux
298
299#endif // DUMUX_SINCOS_TEST_PROBLEM_HH
Setting constant fluid properties via the input file.
A liquid phase consisting of a single component.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
The DUNE grid type.
Definition: common/properties.hh:57
Property to specify the type of a problem which has to be solved.
Definition: common/properties.hh:69
Definition: common/properties.hh:169
If disabled, the volume variables are not stored (reduces memory, but is slower)
Definition: common/properties.hh:178
specifies if data on flux vars should be saved (faster, but more memory consuming)
Definition: common/properties.hh:188
The type of the fluid system to use.
Definition: common/properties.hh:223
Navier-Stokes problem base class.
Definition: dumux/freeflow/navierstokes/problem.hh:63
A liquid phase consisting of a single component.
Definition: 1pliquid.hh:46
Test problem for the staggered grid.
Definition: test/freeflow/navierstokes/sincos/problem.hh:85
NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
Return the sources within the domain.
Definition: test/freeflow/navierstokes/sincos/problem.hh:128
PrimaryVariables analyticalSolution(const GlobalPosition &globalPos, const Scalar time) const
Returns the analytical solution of the problem at a given position.
Definition: test/freeflow/navierstokes/sincos/problem.hh:215
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary cont...
Definition: test/freeflow/navierstokes/sincos/problem.hh:170
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Returns Dirichlet boundary values at a given position.
Definition: test/freeflow/navierstokes/sincos/problem.hh:203
SincosTestProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/freeflow/navierstokes/sincos/problem.hh:107
bool isDirichletCell(const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolume &scv, int pvIdx) const
Returns whether a fixed Dirichlet value shall be used at a given cell.
Definition: test/freeflow/navierstokes/sincos/problem.hh:189
void updateTimeStepSize(const Scalar timeStepSize)
Updates the time step size.
Definition: test/freeflow/navierstokes/sincos/problem.hh:281
Scalar temperature() const
Returns the temperature within the domain in [K].
Definition: test/freeflow/navierstokes/sincos/problem.hh:120
void updateTime(const Scalar time)
Updates the time.
Definition: test/freeflow/navierstokes/sincos/problem.hh:273
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/freeflow/navierstokes/sincos/problem.hh:253
GetPropType< TypeTag, Properties::ModelTraits > ModelTraits
Definition: test/freeflow/navierstokes/sincos/problem.hh:104
Definition: test/freeflow/navierstokes/sincos/problem.hh:45
std::tuple< NavierStokes, StaggeredFreeFlowModel > InheritsFrom
Definition: test/freeflow/navierstokes/sincos/problem.hh:45
Dune::YaspGrid< 2, Dune::EquidistantOffsetCoordinates< GetPropType< TypeTag, Properties::Scalar >, 2 > > type
Definition: test/freeflow/navierstokes/sincos/problem.hh:60
Defines a type tag and some properties for ree-flow models using the staggered scheme....
A single-phase, isothermal Navier-Stokes model.