Commit 82d86e26 authored by Timo Koch's avatar Timo Koch
Browse files

[examples][freeflowchannel] Move properties to main.cc

parent 8c86813e
......@@ -24,81 +24,18 @@ In the following, we take a close look at the files containing the set-up: At fi
## The file `problem.hh`
Before we enter the problem class containing initial and boundary conditions, we include necessary files and introduce properties.
### Include files
The dune grid interface from YASP grid is included, which is a structured, conforming grid, which can also be used for parallel simulations.
Next, the properties of the staggered grid (marker-and-cell) discretization scheme are included, which is the spatial discretization used for free-flow simulations in dumux and is summarized in [here](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/-/blob/master/slides/dumux-course-intro.pdf).
The single-phase, isothermal Navier-Stokes model and Navier-Stokes problem class that this class is derived from are also included.
We will simulate the flow of fluid composed of one liquid phase (`1pliquid.hh`), which will have constant fluid properties (density, viscosity,...) (`constant.hh`).
<details>
<summary>Toggle to expand code (file includes):</summary>
```cpp
#include <dune/grid/yaspgrid.hh>
### The problem class
We enter the problem class where all necessary initial and boundary conditions are set for our simulation.
#include <dumux/discretization/staggered/freeflow/properties.hh>
As this is a Stokes problem, we inherit from the basic <code>NavierStokesProblem</code>.
<details><summary>Toggle to expand code:</summary>
```cpp
#include <dumux/freeflow/navierstokes/model.hh>
#include <dumux/freeflow/navierstokes/problem.hh>
#include <dumux/material/fluidsystems/1pliquid.hh>
#include <dumux/material/components/constant.hh>
```
</details>
### Setup basic properties for our simulation
We setup the DuMux properties for our simulation (click [here](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/blob/master/slides/dumux-course-properties.pdf) for DuMux course slides on the property system) within the namespace Properties, which is a sub-namespace of Dumux.
1. For every test problem, a new `TypeTag` has to be created, which is done within the namespace `TTag` (subnamespace of `Properties`). It inherits from the Navier-Stokes flow model and the staggered-grid discretization scheme.
2. The grid is chosen to be a two-dimensional YASP grid.
3. We set the `FluidSystem` to be a one-phase liquid with a single component. The class `Component::Constant` refers to a component with constant fluid properties (density, viscosity, ...) that can be set via the input file in the group `[0.Component]` where the number is the identifier given as template argument to the class template `Component::Constant`.
4. The problem class `ChannelExampleProblem`, which is forward declared before we enter `namespace Dumux` and defined later in this file, is defined to be the problem used in this test problem (charaterized by the TypeTag `ChannelExample`). The fluid system, which contains information about the properties such as density, viscosity or diffusion coefficient of the fluid we're simulating, is set to a constant one phase liquid.
5. We enable caching for the following classes (which stores values that were already calculated for later usage and thus results in higher memory usage but improved CPU speed): the grid volume variables, the grid flux variables, the finite volume grid geometry.
<details><summary>Toggle to expand code (property definitions):</summary>
```cpp
namespace Dumux {
template <class TypeTag>
class ChannelExampleProblem;
namespace Properties {
namespace TTag {
struct ChannelExample { using InheritsFrom = std::tuple<NavierStokes, StaggeredFreeFlowModel>; };
}
template<class TypeTag>
struct Grid<TypeTag, TTag::ChannelExample> { using type = Dune::YaspGrid<2>; };
template<class TypeTag>
struct Problem<TypeTag, TTag::ChannelExample> { using type = Dumux::ChannelExampleProblem<TypeTag> ; };
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::ChannelExample>
{
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using type = FluidSystems::OnePLiquid<Scalar, Components::Constant<1, Scalar> >;
};
template<class TypeTag>
struct EnableGridVolumeVariablesCache<TypeTag, TTag::ChannelExample> { static constexpr bool value = true; };
template<class TypeTag>
struct EnableGridFluxVariablesCache<TypeTag, TTag::ChannelExample> { static constexpr bool value = true; };
template<class TypeTag>
struct EnableGridGeometryCache<TypeTag, TTag::ChannelExample> { static constexpr bool value = true; };
}
```
</details>
### The problem class
We enter the problem class where all necessary initial and boundary conditions are set for our simulation.
As this is a Stokes problem, we inherit from the basic `NavierStokesProblem`.
<details><summary>Toggle to expand code:</summary>
```cpp
template <class TypeTag>
class ChannelExampleProblem : public NavierStokesProblem<TypeTag>
{
......@@ -155,7 +92,7 @@ if isInlet_ is true, Dirichlet boundaries for pressure on the right of our domai
if isOutlet_ is true and specify Dirichlet boundaries for velocity on the top and bottom
of our domain else.
<details>
<summary>Toggle to expand code (`boundaryTypesAtPos`)</summary>
<summary>Toggle to expand code (<code>boundaryTypesAtPos</code>)</summary>
```cpp
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
......@@ -186,7 +123,7 @@ Second, we specify the values for the Dirichlet boundaries. We need to fix the v
To ensure a no-slip boundary condition at the top and bottom of the channel, the Dirichlet velocity
in x-direction is set to zero if not at the inlet.
<details>
<summary>Toggle to expand code (`dirichletAtPos`)</summary>
<summary>Toggle to expand code (<code>dirichletAtPos</code>)</summary>
```cpp
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
......@@ -206,7 +143,7 @@ in x-direction is set to zero if not at the inlet.
We specify the values for the initial conditions.
We assign constant values for pressure and velocity components.
<details>
<summary>Toggle to expand code (`initialAtPos`)</summary>
<summary>Toggle to expand code (<code>initialAtPos</code>)</summary>
```cpp
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
......@@ -225,7 +162,7 @@ We assign constant values for pressure and velocity components.
We need to specify a constant temperature for our isothermal problem.
We set it to 10°C.
<details>
<summary>Toggle to expand code (`temperature`)</summary>
<summary>Toggle to expand code (<code>temperature</code>)</summary>
```cpp
Scalar temperature() const
......@@ -236,7 +173,7 @@ private:
The inlet is at the left side of the physical domain.
<details>
<summary>Toggle to expand code (`isInlet_`)</summary>
<summary>Toggle to expand code (<code>isInlet_</code>)</summary>
```cpp
bool isInlet_(const GlobalPosition& globalPos) const
......@@ -248,7 +185,7 @@ The inlet is at the left side of the physical domain.
The outlet is at the right side of the physical domain.
<details>
<summary>Toggle to expand code (`isOutlet_`)</summary>
<summary>Toggle to expand code (<code>isOutlet_</code>)</summary>
```cpp
bool isOutlet_(const GlobalPosition& globalPos) const
......@@ -283,7 +220,7 @@ Necessary files are included.
<details>
<summary>Toggle to expand details</summary>
First, the configuration file is include, then the problem, followed by the standard header file for C++ to get time and date information
First, the Dune configuration file is include, the standard header file for C++ to get time and date information
and another standard header for in- and output.
<details>
......@@ -292,8 +229,6 @@ and another standard header for in- and output.
```cpp
#include <config.h>
#include "problem.hh"
#include <ctime>
#include <iostream>
```
......@@ -346,11 +281,60 @@ The following class contains functionality for additional flux output to the con
#include <dumux/io/staggeredvtkoutputmodule.hh>
#include <dumux/io/grid/gridmanager.hh>
#include <dumux/discretization/staggered/freeflow/properties.hh>
#include <dumux/freeflow/navierstokes/staggered/fluxoversurface.hh>
#include <dumux/freeflow/navierstokes/model.hh>
#include <dumux/material/fluidsystems/1pliquid.hh>
#include <dumux/material/components/constant.hh>
#include "problem.hh"
```
</details>
</details>
```cpp
```
### Setup basic properties for our simulation
We setup the DuMux properties for our simulation (click [here](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/blob/master/slides/dumux-course-properties.pdf) for DuMux course slides on the property system) within the namespace Properties, which is a sub-namespace of Dumux.
1. For every test problem, a new `TypeTag` has to be created, which is done within the namespace `TTag` (subnamespace of `Properties`). It inherits from the Navier-Stokes flow model and the staggered-grid discretization scheme.
2. The grid is chosen to be a two-dimensional YASP grid.
3. We set the `FluidSystem` to be a one-phase liquid with a single component. The class `Component::Constant` refers to a component with constant fluid properties (density, viscosity, ...) that can be set via the input file in the group `[0.Component]` where the number is the identifier given as template argument to the class template `Component::Constant`.
4. The problem class `ChannelExampleProblem`, which is forward declared before we enter `namespace Dumux` and defined later in this file, is defined to be the problem used in this test problem (charaterized by the TypeTag `ChannelExample`). The fluid system, which contains information about the properties such as density, viscosity or diffusion coefficient of the fluid we're simulating, is set to a constant one phase liquid.
5. We enable caching for the following classes (which stores values that were already calculated for later usage and thus results in higher memory usage but improved CPU speed): the grid volume variables, the grid flux variables, the finite volume grid geometry.
```cpp
namespace Dumux::Properties {
namespace TTag {
struct ChannelExample { using InheritsFrom = std::tuple<NavierStokes, StaggeredFreeFlowModel>; };
} // namespace TTag
template<class TypeTag>
struct Grid<TypeTag, TTag::ChannelExample> { using type = Dune::YaspGrid<2>; };
template<class TypeTag>
struct Problem<TypeTag, TTag::ChannelExample> { using type = Dumux::ChannelExampleProblem<TypeTag> ; };
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::ChannelExample>
{
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using type = FluidSystems::OnePLiquid<Scalar, Components::Constant<1, Scalar> >;
};
template<class TypeTag>
struct EnableGridVolumeVariablesCache<TypeTag, TTag::ChannelExample> { static constexpr bool value = true; };
template<class TypeTag>
struct EnableGridFluxVariablesCache<TypeTag, TTag::ChannelExample> { static constexpr bool value = true; };
template<class TypeTag>
struct EnableGridGeometryCache<TypeTag, TTag::ChannelExample> { static constexpr bool value = true; };
} // end namespace Dumux::Properties
```
### Beginning of the main function
We begin the main function by making the type tag `ChannelExample`, that we defined in `problem.hh` for this test problem available here.
......
......@@ -23,7 +23,7 @@
//<details>
// <summary>Toggle to expand details</summary>
//
// First, the configuration file is include, then the problem, followed by the standard header file for C++ to get time and date information
// First, the Dune configuration file is include, the standard header file for C++ to get time and date information
// and another standard header for in- and output.
//
//<details>
......@@ -31,8 +31,6 @@
//
#include <config.h>
#include "problem.hh"
#include <ctime>
#include <iostream>
// </details>
......@@ -81,10 +79,56 @@
#include <dumux/io/staggeredvtkoutputmodule.hh>
#include <dumux/io/grid/gridmanager.hh>
#include <dumux/discretization/staggered/freeflow/properties.hh>
#include <dumux/freeflow/navierstokes/staggered/fluxoversurface.hh>
#include <dumux/freeflow/navierstokes/model.hh>
#include <dumux/material/fluidsystems/1pliquid.hh>
#include <dumux/material/components/constant.hh>
#include "problem.hh"
// </details>
//
// </details>
//
// ### Setup basic properties for our simulation
// We setup the DuMux properties for our simulation (click [here](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/blob/master/slides/dumux-course-properties.pdf) for DuMux course slides on the property system) within the namespace Properties, which is a sub-namespace of Dumux.
// 1. For every test problem, a new `TypeTag` has to be created, which is done within the namespace `TTag` (subnamespace of `Properties`). It inherits from the Navier-Stokes flow model and the staggered-grid discretization scheme.
// 2. The grid is chosen to be a two-dimensional YASP grid.
// 3. We set the `FluidSystem` to be a one-phase liquid with a single component. The class `Component::Constant` refers to a component with constant fluid properties (density, viscosity, ...) that can be set via the input file in the group `[0.Component]` where the number is the identifier given as template argument to the class template `Component::Constant`.
// 4. The problem class `ChannelExampleProblem`, which is forward declared before we enter `namespace Dumux` and defined later in this file, is defined to be the problem used in this test problem (charaterized by the TypeTag `ChannelExample`). The fluid system, which contains information about the properties such as density, viscosity or diffusion coefficient of the fluid we're simulating, is set to a constant one phase liquid.
// 5. We enable caching for the following classes (which stores values that were already calculated for later usage and thus results in higher memory usage but improved CPU speed): the grid volume variables, the grid flux variables, the finite volume grid geometry.
//
namespace Dumux::Properties {
namespace TTag {
struct ChannelExample { using InheritsFrom = std::tuple<NavierStokes, StaggeredFreeFlowModel>; };
} // namespace TTag
template<class TypeTag>
struct Grid<TypeTag, TTag::ChannelExample> { using type = Dune::YaspGrid<2>; };
template<class TypeTag>
struct Problem<TypeTag, TTag::ChannelExample> { using type = Dumux::ChannelExampleProblem<TypeTag> ; };
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::ChannelExample>
{
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using type = FluidSystems::OnePLiquid<Scalar, Components::Constant<1, Scalar> >;
};
template<class TypeTag>
struct EnableGridVolumeVariablesCache<TypeTag, TTag::ChannelExample> { static constexpr bool value = true; };
template<class TypeTag>
struct EnableGridFluxVariablesCache<TypeTag, TTag::ChannelExample> { static constexpr bool value = true; };
template<class TypeTag>
struct EnableGridGeometryCache<TypeTag, TTag::ChannelExample> { static constexpr bool value = true; };
} // end namespace Dumux::Properties
//
//
// ### Beginning of the main function
// We begin the main function by making the type tag `ChannelExample`, that we defined in `problem.hh` for this test problem available here.
......
......@@ -21,76 +21,17 @@
#ifndef DUMUX_CHANNEL_TEST_PROBLEM_HH
#define DUMUX_CHANNEL_TEST_PROBLEM_HH
//Before we enter the problem class containing initial and boundary conditions, we include necessary files and introduce properties.
// ### Include files
// The dune grid interface from YASP grid is included, which is a structured, conforming grid, which can also be used for parallel simulations.
// Next, the properties of the staggered grid (marker-and-cell) discretization scheme are included, which is the spatial discretization used for free-flow simulations in dumux and is summarized in [here](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/-/blob/master/slides/dumux-course-intro.pdf).
// The single-phase, isothermal Navier-Stokes model and Navier-Stokes problem class that this class is derived from are also included.
// We will simulate the flow of fluid composed of one liquid phase (`1pliquid.hh`), which will have constant fluid properties (density, viscosity,...) (`constant.hh`).
//<details>
// <summary>Toggle to expand code (file includes):</summary>
//
#include <dune/grid/yaspgrid.hh>
#include <dumux/discretization/staggered/freeflow/properties.hh>
// ### The problem class
// We enter the problem class where all necessary initial and boundary conditions are set for our simulation.
//
// As this is a Stokes problem, we inherit from the basic <code>NavierStokesProblem</code>.
// <details><summary>Toggle to expand code:</summary>
#include <dumux/freeflow/navierstokes/model.hh>
#include <dumux/freeflow/navierstokes/problem.hh>
#include <dumux/material/fluidsystems/1pliquid.hh>
#include <dumux/material/components/constant.hh>
// </details>
//
// ### Setup basic properties for our simulation
// We setup the DuMux properties for our simulation (click [here](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/blob/master/slides/dumux-course-properties.pdf) for DuMux course slides on the property system) within the namespace Properties, which is a sub-namespace of Dumux.
// 1. For every test problem, a new `TypeTag` has to be created, which is done within the namespace `TTag` (subnamespace of `Properties`). It inherits from the Navier-Stokes flow model and the staggered-grid discretization scheme.
// 2. The grid is chosen to be a two-dimensional YASP grid.
// 3. We set the `FluidSystem` to be a one-phase liquid with a single component. The class `Component::Constant` refers to a component with constant fluid properties (density, viscosity, ...) that can be set via the input file in the group `[0.Component]` where the number is the identifier given as template argument to the class template `Component::Constant`.
// 4. The problem class `ChannelExampleProblem`, which is forward declared before we enter `namespace Dumux` and defined later in this file, is defined to be the problem used in this test problem (charaterized by the TypeTag `ChannelExample`). The fluid system, which contains information about the properties such as density, viscosity or diffusion coefficient of the fluid we're simulating, is set to a constant one phase liquid.
// 5. We enable caching for the following classes (which stores values that were already calculated for later usage and thus results in higher memory usage but improved CPU speed): the grid volume variables, the grid flux variables, the finite volume grid geometry.
// <details><summary>Toggle to expand code (property definitions):</summary>
//
namespace Dumux {
template <class TypeTag>
class ChannelExampleProblem;
namespace Properties {
namespace TTag {
struct ChannelExample { using InheritsFrom = std::tuple<NavierStokes, StaggeredFreeFlowModel>; };
}
template<class TypeTag>
struct Grid<TypeTag, TTag::ChannelExample> { using type = Dune::YaspGrid<2>; };
template<class TypeTag>
struct Problem<TypeTag, TTag::ChannelExample> { using type = Dumux::ChannelExampleProblem<TypeTag> ; };
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::ChannelExample>
{
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using type = FluidSystems::OnePLiquid<Scalar, Components::Constant<1, Scalar> >;
};
template<class TypeTag>
struct EnableGridVolumeVariablesCache<TypeTag, TTag::ChannelExample> { static constexpr bool value = true; };
template<class TypeTag>
struct EnableGridFluxVariablesCache<TypeTag, TTag::ChannelExample> { static constexpr bool value = true; };
template<class TypeTag>
struct EnableGridGeometryCache<TypeTag, TTag::ChannelExample> { static constexpr bool value = true; };
}
// </details>
//
// ### The problem class
// We enter the problem class where all necessary initial and boundary conditions are set for our simulation.
//
// As this is a Stokes problem, we inherit from the basic `NavierStokesProblem`.
// <details><summary>Toggle to expand code:</summary>
//
template <class TypeTag>
class ChannelExampleProblem : public NavierStokesProblem<TypeTag>
{
......@@ -142,7 +83,7 @@ public:
// if isOutlet_ is true and specify Dirichlet boundaries for velocity on the top and bottom
// of our domain else.
//<details>
// <summary>Toggle to expand code (`boundaryTypesAtPos`)</summary>
// <summary>Toggle to expand code (<code>boundaryTypesAtPos</code>)</summary>
//
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
{
......@@ -171,7 +112,7 @@ public:
// To ensure a no-slip boundary condition at the top and bottom of the channel, the Dirichlet velocity
// in x-direction is set to zero if not at the inlet.
//<details>
// <summary>Toggle to expand code (`dirichletAtPos`)</summary>
// <summary>Toggle to expand code (<code>dirichletAtPos</code>)</summary>
//
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
{
......@@ -189,7 +130,7 @@ public:
// We specify the values for the initial conditions.
// We assign constant values for pressure and velocity components.
//<details>
// <summary>Toggle to expand code (`initialAtPos`)</summary>
// <summary>Toggle to expand code (<code>initialAtPos</code>)</summary>
//
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
{
......@@ -206,7 +147,7 @@ public:
// We need to specify a constant temperature for our isothermal problem.
// We set it to 10°C.
//<details>
// <summary>Toggle to expand code (`temperature`)</summary>
// <summary>Toggle to expand code (<code>temperature</code>)</summary>
//
Scalar temperature() const
{ return 273.15 + 10; }
......@@ -215,7 +156,7 @@ private:
//
// The inlet is at the left side of the physical domain.
//<details>
// <summary>Toggle to expand code (`isInlet_`)</summary>
// <summary>Toggle to expand code (<code>isInlet_</code>)</summary>
//
bool isInlet_(const GlobalPosition& globalPos) const
{
......@@ -225,7 +166,7 @@ private:
//
// The outlet is at the right side of the physical domain.
//<details>
// <summary>Toggle to expand code (`isOutlet_`)</summary>
// <summary>Toggle to expand code (<code>isOutlet_</code>)</summary>
//
bool isOutlet_(const GlobalPosition& globalPos) const
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment