Loading [MathJax]/extensions/tex2jax.js
3.1-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
test/freeflow/navierstokes/channel/2d/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_CHANNEL_TEST_PROBLEM_HH
26#define DUMUX_CHANNEL_TEST_PROBLEM_HH
27
28#include <dune/grid/yaspgrid.hh>
29
33
37
38namespace Dumux {
39template <class TypeTag>
40class ChannelTestProblem;
41
42namespace Properties {
43// Create new type tags
44namespace TTag {
45#if !NONISOTHERMAL
46struct ChannelTest { using InheritsFrom = std::tuple<NavierStokes, StaggeredFreeFlowModel>; };
47#else
48struct ChannelTest { using InheritsFrom = std::tuple<NavierStokesNI, StaggeredFreeFlowModel>; };
49#endif
50} // end namespace TTag
51
52// the fluid system
53template<class TypeTag>
54struct FluidSystem<TypeTag, TTag::ChannelTest>
55{
57#if NONISOTHERMAL
59#else
61#endif
62};
63
64// Set the grid type
65template<class TypeTag>
66struct Grid<TypeTag, TTag::ChannelTest> { using type = Dune::YaspGrid<2>; };
67
68// Set the problem property
69template<class TypeTag>
70struct Problem<TypeTag, TTag::ChannelTest> { using type = Dumux::ChannelTestProblem<TypeTag> ; };
71
72template<class TypeTag>
73struct EnableGridGeometryCache<TypeTag, TTag::ChannelTest> { static constexpr bool value = true; };
74
75template<class TypeTag>
76struct EnableGridFluxVariablesCache<TypeTag, TTag::ChannelTest> { static constexpr bool value = true; };
77template<class TypeTag>
78struct EnableGridVolumeVariablesCache<TypeTag, TTag::ChannelTest> { static constexpr bool value = true; };
79} // end namespace Properties
80
92template <class TypeTag>
94{
95 using ParentType = NavierStokesProblem<TypeTag>;
96
99 using FVElementGeometry = typename GridGeometry::LocalView;
100 using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace;
105
106 using Element = typename GridGeometry::GridView::template Codim<0>::Entity;
107 using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
108
109 using TimeLoopPtr = std::shared_ptr<CheckPointTimeLoop<Scalar>>;
110
111 // the types of outlet boundary conditions
112 enum class OutletCondition
113 {
114 outflow, doNothing, neumannXdirichletY, neumannXneumannY
115 };
116
117public:
118 ChannelTestProblem(std::shared_ptr<const GridGeometry> gridGeometry)
119 : ParentType(gridGeometry), eps_(1e-6)
120 {
121 inletVelocity_ = getParam<Scalar>("Problem.InletVelocity");
122 const auto tmp = getParam<std::string>("Problem.OutletCondition", "Outflow");
123 if (tmp == "Outflow")
124 outletCondition_ = OutletCondition::outflow;
125 else if (tmp == "DoNothing")
126 outletCondition_ = OutletCondition::doNothing;
127 else if (tmp == "NeumannX_DirichletY")
128 outletCondition_ = OutletCondition::neumannXdirichletY;
129 else if (tmp == "NeumannX_NeumannY")
130 outletCondition_ = OutletCondition::neumannXneumannY;
131 else
132 DUNE_THROW(Dune::InvalidStateException, tmp + " is not a valid outlet boundary condition");
133
134 useVelocityProfile_ = getParam<bool>("Problem.UseVelocityProfile", false);
135 outletPressure_ = getParam<Scalar>("Problem.OutletPressure", 1.1e5);
136 }
137
141 // \{
142
148 Scalar temperature() const
149 { return 273.15 + 10; } // 10C
150
156 NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
157 {
158 return NumEqVector(0.0);
159 }
160 // \}
164 // \{
165
172 BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
173 {
174 BoundaryTypes values;
175
176 if(isInlet_(globalPos))
177 {
178 values.setDirichlet(Indices::velocityXIdx);
179 values.setDirichlet(Indices::velocityYIdx);
180#if NONISOTHERMAL
181 values.setDirichlet(Indices::temperatureIdx);
182#endif
183 }
184 else if(isOutlet_(globalPos))
185 {
186 if (outletCondition_ == OutletCondition::outflow)
187 values.setDirichlet(Indices::pressureIdx);
188 else if (outletCondition_ == OutletCondition::doNothing ||
189 outletCondition_ == OutletCondition::neumannXneumannY)
190 {
191 values.setNeumann(Indices::momentumXBalanceIdx);
192 values.setNeumann(Indices::momentumYBalanceIdx);
193 }
194 else // (outletCondition_ == OutletCondition::neumannXdirichletY)
195 {
196 values.setDirichlet(Indices::velocityYIdx);
197 values.setNeumann(Indices::momentumXBalanceIdx);
198 }
199#if NONISOTHERMAL
200 values.setOutflow(Indices::energyEqIdx);
201#endif
202 }
203 else
204 {
205 values.setDirichlet(Indices::velocityXIdx);
206 values.setDirichlet(Indices::velocityYIdx);
207#if NONISOTHERMAL
208 values.setNeumann(Indices::energyEqIdx);
209#endif
210 }
211
212 return values;
213 }
214
220 PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
221 {
222 PrimaryVariables values = initialAtPos(globalPos);
223
224 if(isInlet_(globalPos))
225 {
226#if NONISOTHERMAL
227 // give the system some time so that the pressure can equilibrate, then start the injection of the hot liquid
228 if(time() >= 200.0)
229 values[Indices::temperatureIdx] = 293.15;
230#endif
231 }
232 else
233 values[Indices::velocityXIdx] = 0.0;
234
235 return values;
236 }
237
247 template<class ElementVolumeVariables, class ElementFaceVariables>
248 NumEqVector neumann(const Element& element,
249 const FVElementGeometry& fvGeometry,
250 const ElementVolumeVariables& elemVolVars,
251 const ElementFaceVariables& elemFaceVars,
252 const SubControlVolumeFace& scvf) const
253 {
254 NumEqVector values(0.0);
255
256 values[scvf.directionIndex()] = initialAtPos(scvf.center())[Indices::pressureIdx];
257
258 // make sure to normalize the pressure if the property is set true
259 if (getPropValue<TypeTag, Properties::NormalizePressure>())
260 values[scvf.directionIndex()] -= initialAtPos(scvf.center())[Indices::pressureIdx];
261
262 if (outletCondition_ != OutletCondition::doNothing)
263 values[1] = -dudy(scvf.center()[1], inletVelocity_) * elemVolVars[scvf.insideScvIdx()].viscosity();
264
265 return values;
266 }
267
274 Scalar parabolicProfile(const Scalar y, const Scalar vMax) const
275 {
276 const Scalar yMin = this->gridGeometry().bBoxMin()[1];
277 const Scalar yMax = this->gridGeometry().bBoxMax()[1];
278 return vMax * (y - yMin)*(yMax - y) / (0.25*(yMax - yMin)*(yMax - yMin));
279 }
280
288 Scalar dudy(const Scalar y, const Scalar vMax) const
289 {
290 const Scalar yMin = this->gridGeometry().bBoxMin()[1];
291 const Scalar yMax = this->gridGeometry().bBoxMax()[1];
292 return vMax * (4.0*yMin + 4*yMax - 8.0*y) / ((yMin-yMax)*(yMin-yMax));
293 }
294
295 // \}
296
300 // \{
301
307 PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
308 {
309 PrimaryVariables values;
310 values[Indices::pressureIdx] = outletPressure_;
311 values[Indices::velocityYIdx] = 0.0;
312
313#if NONISOTHERMAL
314 values[Indices::temperatureIdx] = 283.15;
315#endif
316
317 if (useVelocityProfile_)
318 values[Indices::velocityXIdx] = parabolicProfile(globalPos[1], inletVelocity_);
319 else
320 values[Indices::velocityXIdx] = inletVelocity_;
321
322 return values;
323 }
324
325 // \}
326 void setTimeLoop(TimeLoopPtr timeLoop)
327 {
328 timeLoop_ = timeLoop;
329 if(inletVelocity_ > eps_)
330 timeLoop_->setCheckPoint({200.0, 210.0});
331 }
332
333 Scalar time() const
334 {
335 return timeLoop_->time();
336 }
337
338private:
339
340 bool isInlet_(const GlobalPosition& globalPos) const
341 {
342 return globalPos[0] < eps_;
343 }
344
345 bool isOutlet_(const GlobalPosition& globalPos) const
346 {
347 return globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_;
348 }
349
350 Scalar eps_;
351 Scalar inletVelocity_;
352 Scalar outletPressure_;
353 OutletCondition outletCondition_;
354 bool useVelocityProfile_;
355 TimeLoopPtr timeLoop_;
356};
357} // end namespace Dumux
358
359#endif
A liquid phase consisting of a single component.
A much simpler (and thus potentially less buggy) version of pure water.
Setting constant fluid properties via the input file.
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 one-phase (Navier-) Stokes problem in a channel.
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:94
Scalar dudy(const Scalar y, const Scalar vMax) const
The partial dervivative of the horizontal velocity (following a parabolic profile for Stokes flow) w....
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:288
NumEqVector neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFaceVariables &elemFaceVars, const SubControlVolumeFace &scvf) const
Evaluates the boundary conditions for a Neumann control volume.
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:248
Scalar parabolicProfile(const Scalar y, const Scalar vMax) const
A parabolic velocity profile.
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:274
void setTimeLoop(TimeLoopPtr timeLoop)
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:326
ChannelTestProblem(std::shared_ptr< const GridGeometry > gridGeometry)
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:118
Scalar time() const
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:333
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluates the initial value for a control volume.
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:307
NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
Returns the sources within the domain.
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:156
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/channel/2d/problem.hh:172
Scalar temperature() const
Returns the temperature within the domain in [K].
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:148
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluates the boundary conditions for a Dirichlet control volume.
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:220
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:46
std::tuple< NavierStokes, StaggeredFreeFlowModel > InheritsFrom
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:46
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:56
Dune::YaspGrid< 2 > type
Definition: test/freeflow/navierstokes/channel/2d/problem.hh:66
A single-phase, isothermal Navier-Stokes model.
Defines a type tag and some properties for ree-flow models using the staggered scheme....