Commit f4fccb84 authored by Gabi Seitz's avatar Gabi Seitz
Browse files

Merge branch 'feature/propertiesheader_ex-mainfile' into 'master'

Mainfile Exercise with separate properties header

See merge request !91
parents d314c12b f28cf7e2
Pipeline #1822 passed with stage
in 40 seconds
......@@ -24,91 +24,11 @@
#ifndef DUMUX_EX_MAINFILE_ONEP_TEST_PROBLEM_HH
#define DUMUX_EX_MAINFILE_ONEP_TEST_PROBLEM_HH
#include <dune/grid/yaspgrid.hh>
#include <dumux/material/components/simpleh2o.hh>
#include <dumux/material/components/h2o.hh>
#include <dumux/material/components/tabulatedcomponent.hh>
#include <dumux/material/fluidsystems/1pliquid.hh>
#include <dumux/discretization/cctpfa.hh>
#include <dumux/discretization/ccmpfa.hh>
#include <dumux/discretization/box.hh>
// TODO: dumux-course-task 3
// uncomment the incompressiblelocalresidual which is a specialization of the standard immisible localresidual for one phase incompressible cases and provides an analytic jacobian.
// #include <dumux/porousmediumflow/1p/incompressiblelocalresidual.hh>
#include <dumux/common/properties.hh>
#include <dumux/porousmediumflow/problem.hh>
#include <dumux/porousmediumflow/1p/model.hh>
#include "1pspatialparams.hh"
namespace Dumux
{
// forward declarations
template<class TypeTag> class OnePTestProblem;
namespace Properties
{
// create the type tag nodes. Here we define the incompressible type tag as well as the compressible type tag. The incompressible uses a different fluidsystem than the compressible
// Create new type tags
namespace TTag {
struct OnePBase { using InheritsFrom = std::tuple<OneP>; };
struct OnePIncompressible { using InheritsFrom = std::tuple<OnePBase, CCTpfaModel>; };
struct OnePCompressible { using InheritsFrom = std::tuple<OnePBase, CCTpfaModel>; };
} // end namespace TTag
// Set the grid type
template<class TypeTag>
struct Grid<TypeTag, TTag::OnePBase> { using type = Dune::YaspGrid<2>; };
// Set the problem type
template<class TypeTag>
struct Problem<TypeTag, TTag::OnePBase> { using type = OnePTestProblem<TypeTag>; };
// set the spatial params
template<class TypeTag>
struct SpatialParams<TypeTag, TTag::OnePBase> {
using type = OnePTestSpatialParams<GetPropType<TypeTag, GridGeometry>, GetPropType<TypeTag, Scalar>>;
};
// the fluid system for incompressible tests
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::OnePIncompressible>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::OnePLiquid<Scalar, Components::SimpleH2O<Scalar> >;
};
// TODO: dumux-course-task 3
// set the OneP Incompressible local residual for the OnePIncompressible type tag. This provides an analytic jacobian to be used for the analytic solution. Change that by setting:
// template<class TypeTag>
// struct LocalResidual<TypeTag, TTag::OnePIncompressible> { using type = OnePIncompressibleLocalResidual<TypeTag>; };
// the fluid system for compressible tests
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::OnePCompressible>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::OnePLiquid<Scalar, Components::TabulatedComponent<Components::H2O<Scalar>>>;
};
// Disable caching (for testing purposes)
template<class TypeTag>
struct EnableGridVolumeVariablesCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
template<class TypeTag>
struct EnableGridFluxVariablesCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
template<class TypeTag>
struct EnableGridGeometryCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
namespace Dumux {
} // end namespace Properties
/*!
* \ingroup OnePTests
* \brief Test problem for the compressible one-phase model:
......
......@@ -33,12 +33,17 @@ Locate all the files you will need for this exercise
* The __main file__ for the __compressible, stationary__ problem : `exercise1pbmain.cc`
* The __main file__ for the __compressible, instationary__ problem : `exercise1pcmain.cc`
* The shared __problem file__: `1pproblem.hh`
* The shared __properties file__: `properties.hh`
* The shared __spatial parameters file__: `1pspatialparams.hh`
* The __input file__ for the __incompressible, stationary__ problem: `exercise_mainfile_a.input`
* The __input file__ for the __compressible, stationary__ problem: `exercise_mainfile_b.input`
* The __input file__ for the __compressible, instationary__ problem: `exercise_mainfile_c.input`
Please pay special attention to the similarities and differences in the three main files. The first main file is solved linearly and does not need a newton solver or any other nonlinear solver method. The second problem is a nonlinear problem and uses newton's method to solve the system. The third problem is nonlinear and additionally instationary. Therefore, a time loop needs to be included in the main file.
Please pay special attention to the similarities and differences in the three main files.
The first main file is solved linearly and does not need a newton solver or any other nonlinear solver method.
The second problem is a nonlinear problem and uses newton's method to solve the system.
The third problem is nonlinear and additionally instationary.
Therefore, a time loop needs to be included in the main file.
The general structure of any main file in DuMuX is:
......@@ -48,7 +53,8 @@ The general structure of any main file in DuMuX is:
// define the type tag for this problem
using TypeTag = Properties::TTag::OnePCompressible;
```
The `TypeTag` is created in the `1pproblem.hh`. There, you can see that it inherits from the __OneP__ and additionally from the __CCTpfaModel__. The latter defines the discretization method, which is in this case the cell-centered tpfa method.
The `TypeTag` is created in the `properties.hh`. There, you can see that it inherits from the __OneP__ and additionally from the __CCTpfaModel__.
The latter defines the discretization method, which is in this case the cell-centered tpfa method.
* A gridmanager tries to create the grid either from a grid file or the input file:
......@@ -56,7 +62,8 @@ The `TypeTag` is created in the `1pproblem.hh`. There, you can see that it inher
GridManager<GetPropType<TypeTag, Properties::Grid>> gridManager;
gridManager.init();
```
* We create the finite volume grid geometry, the problem, solution vector and the grid variables and initialize them. Additionally, we initialize the vtk output. Each model has a predefined model specific output with relevant parameters for that model:
* We create the finite volume grid geometry, the problem, solution vector and the grid variables and initialize them.
Additionally, we initialize the vtk output. Each model has a predefined model specific output with relevant parameters for that model:
```c++
// create the finite volume grid geometry
......@@ -86,7 +93,8 @@ IOFields::initOutputModule(vtkWriter); //!< Add model specific output fields
vtkWriter.write(0.0);
```
* Then, we need to assemble and solve the system. Depending on the problem, this can be done with a linear solver or a nonlinear solver. If the problem is time dependent, we additionally need a time loop. An example for that is given in `exercise1pcmain.cc`:
* Then, we need to assemble and solve the system. Depending on the problem, this can be done with a linear solver or a nonlinear solver.
If the problem is time dependent, we additionally need a time loop. An example for that is given in `exercise1pcmain.cc`:
```c++
// get some time loop parameters
......@@ -179,13 +187,21 @@ paraview 1p_incompressible_stationary.pvd
### Task 3: Analytical differentiation
<hr>
In the input file `exercise_1p_a.input`, you will see that there is a variable `BaseEpsilon`. This defines the base for the epsilon used in the numeric differentiation. If that value is too small, you will see that the solution of the numeric differentiation is not correct. Change that value to $`1 \cdot 10^{-15}`$ and have a look at the solution.
In the input file `exercise_1p_a.input`, you will see that there is a variable `BaseEpsilon`.
This defines the base for the epsilon used in the numeric differentiation.
If that value is too small, you will see that the solution of the numeric differentiation is not correct.
Change that value to $`1 \cdot 10^{-15}`$ and have a look at the solution.
For the incompressible one phase problem, it is also possible to have an analytic solution method. In this case, the epsilon does not play a role anymore, since the derivatives are calculated analytically. To implement that, follow the tips in the `exercise1pamain.cc` and the `1pproblem.hh` marked by:
For the incompressible one phase problem, it is also possible to have an analytic solution method.
In this case, the epsilon does not play a role anymore, since the derivatives are calculated analytically.
To implement that, follow the tips in the `exercise1pamain.cc` and the `properties.hh` marked by:
```c++
// TODO: dumux-course-task 3
```
For the analytic solution of your immiscible problem, you need analytic solutions for the derivatives of the jacobian. For that, we have a special local residual, the `OnePIncompressibleLocalResidual` which provides that. You just need to include `incompressiblelocalresidual.hh` in your `1pproblem.hh` and use that instead of the `immisciblelocalresidual.hh` which is used as a default for all immiscible models.
For the analytic solution of your immiscible problem, you need analytic solutions for the derivatives of the jacobian.
For that, we have a special local residual, the `OnePIncompressibleLocalResidual` which provides that.
You just need to include `incompressiblelocalresidual.hh` in your `properties.hh`
and use that instead of the `immisciblelocalresidual.hh` which is used as a default for all immiscible models.
Additionally, you need to set the differentiation method in the main file `exercise1pamain.cc` to analytic.
......@@ -23,7 +23,7 @@
*/
#include <config.h>
#include "1pproblem.hh"
#include "properties.hh"
#include <ctime>
#include <iostream>
......
......@@ -23,7 +23,7 @@
*/
#include <config.h>
#include "1pproblem.hh"
#include "properties.hh"
#include <ctime>
#include <iostream>
......
......@@ -23,7 +23,7 @@
*/
#include <config.h>
#include "1pproblem.hh"
#include "properties.hh"
#include <ctime>
#include <iostream>
......
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \brief The one-phase porousmediumflow problem for exercise mainfile
*/
#ifndef DUMUX_EX_MAINFILE_PROPERTIES_HH
#define DUMUX_EX_MAINFILE_PROPERTIES_HH
#include <dune/grid/yaspgrid.hh>
#include <dumux/material/components/simpleh2o.hh>
#include <dumux/material/components/h2o.hh>
#include <dumux/material/components/tabulatedcomponent.hh>
#include <dumux/material/fluidsystems/1pliquid.hh>
#include <dumux/discretization/cctpfa.hh>
#include <dumux/discretization/ccmpfa.hh>
#include <dumux/discretization/box.hh>
#include <dumux/porousmediumflow/1p/model.hh>
// TODO: dumux-course-task 3
// uncomment the incompressiblelocalresidual which is a specialization of the standard immisible localresidual for one phase incompressible cases and provides an analytic jacobian.
// #include <dumux/porousmediumflow/1p/incompressiblelocalresidual.hh>
#include "1pspatialparams.hh"
#include "1pproblem.hh"
namespace Dumux::Properties {
// Create the new type tag nodes:
// Here we define the incompressible type tag as well as the compressible type tag.
// The incompressible uses a different fluidsystem than the compressible
namespace TTag {
struct OnePBase { using InheritsFrom = std::tuple<OneP>; };
struct OnePIncompressible { using InheritsFrom = std::tuple<OnePBase, CCTpfaModel>; };
struct OnePCompressible { using InheritsFrom = std::tuple<OnePBase, CCTpfaModel>; };
} // end namespace TTag
// Set the grid type
template<class TypeTag>
struct Grid<TypeTag, TTag::OnePBase> { using type = Dune::YaspGrid<2>; };
// Set the problem type
template<class TypeTag>
struct Problem<TypeTag, TTag::OnePBase> { using type = OnePTestProblem<TypeTag>; };
// set the spatial params
template<class TypeTag>
struct SpatialParams<TypeTag, TTag::OnePBase> {
using type = OnePTestSpatialParams<GetPropType<TypeTag, GridGeometry>, GetPropType<TypeTag, Scalar>>;
};
// the fluid system for incompressible tests
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::OnePIncompressible>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::OnePLiquid<Scalar, Components::SimpleH2O<Scalar> >;
};
// TODO: dumux-course-task 3
// set the OneP Incompressible local residual for the OnePIncompressible type tag. This provides an analytic jacobian to be used for the analytic solution. Change that by setting:
// template<class TypeTag>
// struct LocalResidual<TypeTag, TTag::OnePIncompressible> { using type = OnePIncompressibleLocalResidual<TypeTag>; };
// the fluid system for compressible tests
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::OnePCompressible>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::OnePLiquid<Scalar, Components::TabulatedComponent<Components::H2O<Scalar>>>;
};
// Disable caching (for testing purposes)
template<class TypeTag>
struct EnableGridVolumeVariablesCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
template<class TypeTag>
struct EnableGridFluxVariablesCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
template<class TypeTag>
struct EnableGridGeometryCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
} // end namespace Dumux::Properties
#endif
......@@ -24,91 +24,11 @@
#ifndef DUMUX_EX_MAINFILE_ONEP_TEST_PROBLEM_HH
#define DUMUX_EX_MAINFILE_ONEP_TEST_PROBLEM_HH
#include <dune/grid/yaspgrid.hh>
#include <dumux/material/components/simpleh2o.hh>
#include <dumux/material/components/h2o.hh>
#include <dumux/material/components/tabulatedcomponent.hh>
#include <dumux/material/fluidsystems/1pliquid.hh>
#include <dumux/discretization/cctpfa.hh>
#include <dumux/discretization/ccmpfa.hh>
#include <dumux/discretization/box.hh>
// TODO: dumux-course-task
// uncomment the incompressiblelocalresidual which is a specialization of the standard immisible localresidual for one phase incompressible cases and provides an analytic jacobian.
#include <dumux/porousmediumflow/1p/incompressiblelocalresidual.hh>
#include <dumux/porousmediumflow/problem.hh>
#include <dumux/porousmediumflow/1p/model.hh>
#include "1pspatialparams.hh"
namespace Dumux
{
// forward declarations
template<class TypeTag> class OnePTestProblem;
namespace Properties
{
// create the type tag nodes. Here we define the incompressible type tag as well as the compressible type tag. The incompressible uses a different fluidsystem than the compressible
// Create new type tags
namespace TTag {
struct OnePBase { using InheritsFrom = std::tuple<OneP>; };
struct OnePIncompressible { using InheritsFrom = std::tuple<OnePBase, CCTpfaModel>; };
struct OnePCompressible { using InheritsFrom = std::tuple<OnePBase, CCTpfaModel>; };
} // end namespace TTag
// Set the grid type
template<class TypeTag>
struct Grid<TypeTag, TTag::OnePBase> { using type = Dune::YaspGrid<2>; };
// Set the problem type
template<class TypeTag>
struct Problem<TypeTag, TTag::OnePBase> { using type = OnePTestProblem<TypeTag>; };
#include <dumux/common/properties.hh>
// set the spatial params
template<class TypeTag>
struct SpatialParams<TypeTag, TTag::OnePBase> {
using type = OnePTestSpatialParams<GetPropType<TypeTag, GridGeometry>, GetPropType<TypeTag, Scalar>>;
};
// the fluid system for incompressible tests
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::OnePIncompressible>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::OnePLiquid<Scalar, Components::SimpleH2O<Scalar> >;
};
// TODO: dumux-course-task
// set the OneP Incompressible local residual for the OnePIncompressible type tag. This provides an analytic jacobian to be used for the analytic solution. Change that by setting:
template<class TypeTag>
struct LocalResidual<TypeTag, TTag::OnePIncompressible> { using type = OnePIncompressibleLocalResidual<TypeTag>; };
// the fluid system for compressible tests
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::OnePCompressible>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::OnePLiquid<Scalar, Components::TabulatedComponent<Components::H2O<Scalar>>>;
};
// Disable caching (for testing purposes)
template<class TypeTag>
struct EnableGridVolumeVariablesCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
template<class TypeTag>
struct EnableGridFluxVariablesCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
template<class TypeTag>
struct EnableGridGeometryCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
namespace Dumux {
} // end namespace Properties
/*!
* \ingroup OnePTests
* \brief Test problem for the compressible one-phase model:
......
......@@ -46,6 +46,8 @@
#include <dumux/io/vtkoutputmodule.hh>
#include <dumux/io/grid/gridmanager.hh>
#include "properties.hh"
int main(int argc, char** argv) try
{
using namespace Dumux;
......@@ -105,7 +107,7 @@ int main(int argc, char** argv) try
using IOFields = GetPropType<TypeTag, Properties::IOFields>;
IOFields::initOutputModule(vtkWriter); //!< Add model specific output fields
vtkWriter.write(0.0);
Dune::Timer timer;
// TODO: dumux-course-task
......
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
*
* \brief The one-phase porousmediumflow problem for exercise mainfile
*/
#ifndef DUMUX_EX_MAINFILE_PROPERTIES_HH
#define DUMUX_EX_MAINFILE_PROPERTIES_HH
#include <dune/grid/yaspgrid.hh>
#include <dumux/material/components/simpleh2o.hh>
#include <dumux/material/components/h2o.hh>
#include <dumux/material/components/tabulatedcomponent.hh>
#include <dumux/material/fluidsystems/1pliquid.hh>
#include <dumux/discretization/cctpfa.hh>
#include <dumux/discretization/ccmpfa.hh>
#include <dumux/discretization/box.hh>
#include <dumux/porousmediumflow/1p/model.hh>
// TODO: dumux-course-task
// uncomment the incompressiblelocalresidual which is a specialization of the standard immisible localresidual for one phase incompressible cases and provides an analytic jacobian.
#include <dumux/porousmediumflow/1p/incompressiblelocalresidual.hh>
#include "1pspatialparams.hh"
#include "1pproblem.hh"
namespace Dumux::Properties {
// Create the new type tag nodes.
// Here we define the incompressible type tag as well as the compressible type tag.
// The incompressible uses a different fluidsystem than the compressible.
namespace TTag {
struct OnePBase { using InheritsFrom = std::tuple<OneP>; };
struct OnePIncompressible { using InheritsFrom = std::tuple<OnePBase, CCTpfaModel>; };
struct OnePCompressible { using InheritsFrom = std::tuple<OnePBase, CCTpfaModel>; };
} // end namespace TTag
// Set the grid type
template<class TypeTag>
struct Grid<TypeTag, TTag::OnePBase> { using type = Dune::YaspGrid<2>; };
// Set the problem type
template<class TypeTag>
struct Problem<TypeTag, TTag::OnePBase> { using type = OnePTestProblem<TypeTag>; };
// set the spatial params
template<class TypeTag>
struct SpatialParams<TypeTag, TTag::OnePBase> {
using type = OnePTestSpatialParams<GetPropType<TypeTag, GridGeometry>, GetPropType<TypeTag, Scalar>>;
};
// the fluid system for incompressible tests
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::OnePIncompressible>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::OnePLiquid<Scalar, Components::SimpleH2O<Scalar> >;
};
// TODO: dumux-course-task
// set the OneP Incompressible local residual for the OnePIncompressible type tag. This provides an analytic jacobian to be used for the analytic solution. Change that by setting:
template<class TypeTag>
struct LocalResidual<TypeTag, TTag::OnePIncompressible> { using type = OnePIncompressibleLocalResidual<TypeTag>; };
// the fluid system for compressible tests
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::OnePCompressible>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::OnePLiquid<Scalar, Components::TabulatedComponent<Components::H2O<Scalar>>>;
};
// Disable caching (for testing purposes)
template<class TypeTag>
struct EnableGridVolumeVariablesCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
template<class TypeTag>
struct EnableGridFluxVariablesCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
template<class TypeTag>
struct EnableGridGeometryCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
} // end namespace Dumux::Properties
#endif
Supports Markdown
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