Commit e7431e64 authored by Felix Weinhardt's avatar Felix Weinhardt
Browse files

[exercise-mainfile]

update code main file and problem file
parent c2330116
......@@ -38,7 +38,7 @@
// 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/1p/incompressiblelocalresidual.hh>
#include <dumux/porousmediumflow/problem.hh>
#include <dumux/porousmediumflow/1p/model.hh>
......@@ -53,46 +53,58 @@ 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
NEW_TYPE_TAG(OnePBase, INHERITS_FROM(OneP));
NEW_TYPE_TAG(OnePIncompressible, INHERITS_FROM(CCTpfaModel, OnePBase));
NEW_TYPE_TAG(OnePCompressible, INHERITS_FROM(CCTpfaModel, OnePBase));
// 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
SET_TYPE_PROP(OnePBase, Grid, Dune::YaspGrid<2>);
template<class TypeTag>
struct Grid<TypeTag, TTag::OnePBase> { using type = Dune::YaspGrid<2>; };
// Set the problem type
SET_TYPE_PROP(OnePBase, Problem, OnePTestProblem<TypeTag>);
template<class TypeTag>
struct Problem<TypeTag, TTag::OnePBase> { using type = OnePTestProblem<TypeTag>; };
// set the spatial params
SET_TYPE_PROP(OnePBase, SpatialParams, OnePTestSpatialParams<TypeTag>);
template<class TypeTag>
struct SpatialParams<TypeTag, TTag::OnePBase> { using type = OnePTestSpatialParams<TypeTag>; };
// the fluid system for incompressible tests
SET_PROP(OnePIncompressible, FluidSystem)
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::OnePIncompressible>
{
private:
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
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:
//SET_TYPE_PROP(OnePIncompressible, LocalResidual, OnePIncompressibleLocalResidual<TypeTag>);
template<class TypeTag>
struct LocalResidual<TypeTag, TTag::OnePIncompressible> { using type = OnePIncompressibleLocalResidual<TypeTag>; };
// the fluid system for compressible tests
SET_PROP(OnePCompressible, FluidSystem)
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::OnePCompressible>
{
private:
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::OnePLiquid<Scalar, Components::TabulatedComponent<Components::H2O<Scalar>>>;
};
// Disable caching (for testing purposes)
SET_BOOL_PROP(OnePBase, EnableGridVolumeVariablesCache, false);
SET_BOOL_PROP(OnePBase, EnableGridFluxVariablesCache, false);
SET_BOOL_PROP(OnePBase, EnableFVGridGeometryCache, false);
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 EnableFVGridGeometryCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
} // end namespace Properties
/*!
......@@ -106,15 +118,15 @@ template<class TypeTag>
class OnePTestProblem : public PorousMediumFlowProblem<TypeTag>
{
using ParentType = PorousMediumFlowProblem<TypeTag>;
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using GridView = GetPropType<TypeTag, Properties::GridView>;
using Element = typename GridView::template Codim<0>::Entity;
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables);
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes);
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>;
using BoundaryTypes = GetPropType<TypeTag, Properties::BoundaryTypes>;
static constexpr int dimWorld = GridView::dimensionworld;
using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
public:
OnePTestProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry)
......
......@@ -51,7 +51,7 @@ int main(int argc, char** argv) try
using namespace Dumux;
// define the type tag for this problem
using TypeTag = TTAG(OnePIncompressible);
using TypeTag = Properties::TTag::OnePIncompressible;
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
......@@ -70,7 +70,7 @@ int main(int argc, char** argv) try
// try to create a grid (from the given grid file or the input file)
/////////////////////////////////////////////////////////////////////
GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager;
GridManager<GetPropType<TypeTag, Properties::Grid>> gridManager;
gridManager.init();
////////////////////////////////////////////////////////////
......@@ -81,27 +81,29 @@ int main(int argc, char** argv) try
const auto& leafGridView = gridManager.grid().leafGridView();
// create the finite volume grid geometry
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>;
auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView);
fvGridGeometry->update();
// the problem (initial and boundary conditions)
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using Problem = GetPropType<TypeTag, Properties::Problem>;
auto problem = std::make_shared<Problem>(fvGridGeometry);
// the solution vector
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
SolutionVector x(fvGridGeometry->numDofs());
// the grid variables
using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables);
using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry);
gridVariables->init(x);
// initialize the vtk output module
using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields);
VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
VtkOutputFields::init(vtkWriter); //!< Add model specific output fields
// intialize the vtk output module
VtkOutputModule<GridVariables, SolutionVector> vtkWriter(*gridVariables, x, problem->name());
using VelocityOutput = GetPropType<TypeTag, Properties::VelocityOutput>;
vtkWriter.addVelocityOutput(std::make_shared<VelocityOutput>(*gridVariables));
using IOFields = GetPropType<TypeTag, Properties::IOFields>;
IOFields::initOutputModule(vtkWriter); //!< Add model specific output fields
vtkWriter.write(0.0);
Dune::Timer timer;
......@@ -118,7 +120,7 @@ int main(int argc, char** argv) try
auto linearSolver = std::make_shared<LinearSolver>();
// the discretization matrices for stationary linear problems
using JacobianMatrix = typename GET_PROP_TYPE(TypeTag, JacobianMatrix);
using JacobianMatrix = GetPropType<TypeTag, Properties::JacobianMatrix>;
auto A = std::make_shared<JacobianMatrix>();
auto r = std::make_shared<SolutionVector>();
assembler->setLinearSystem(A, r);
......
......@@ -52,7 +52,7 @@ int main(int argc, char** argv) try
using namespace Dumux;
// define the type tag for this problem
using TypeTag = TTAG(OnePCompressible);
using TypeTag = Properties::TTag::OnePCompressible;
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
......@@ -71,7 +71,7 @@ int main(int argc, char** argv) try
// try to create a grid (from the given grid file or the input file)
/////////////////////////////////////////////////////////////////////
GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager;
GridManager<GetPropType<TypeTag, Properties::Grid>> gridManager;
gridManager.init();
////////////////////////////////////////////////////////////
......@@ -82,27 +82,29 @@ int main(int argc, char** argv) try
const auto& leafGridView = gridManager.grid().leafGridView();
// create the finite volume grid geometry
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>;
auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView);
fvGridGeometry->update();
// the problem (initial and boundary conditions)
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using Problem = GetPropType<TypeTag, Properties::Problem>;
auto problem = std::make_shared<Problem>(fvGridGeometry);
// the solution vector
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
SolutionVector x(fvGridGeometry->numDofs());
// the grid variables
using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables);
using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry);
gridVariables->init(x);
// initialize the vtk output module
using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields);
VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
VtkOutputFields::init(vtkWriter); //!< Add model specific output fields
// intialize the vtk output module
VtkOutputModule<GridVariables, SolutionVector> vtkWriter(*gridVariables, x, problem->name());
using VelocityOutput = GetPropType<TypeTag, Properties::VelocityOutput>;
vtkWriter.addVelocityOutput(std::make_shared<VelocityOutput>(*gridVariables));
using IOFields = GetPropType<TypeTag, Properties::IOFields>;
IOFields::initOutputModule(vtkWriter); //!< Add model specific output fields
vtkWriter.write(0.0);
Dune::Timer timer;
......
......@@ -52,7 +52,7 @@ int main(int argc, char** argv) try
using namespace Dumux;
// define the type tag for this problem
using TypeTag = TTAG(OnePCompressible);
using TypeTag = Properties::TTag::OnePCompressible;
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
......@@ -71,7 +71,7 @@ int main(int argc, char** argv) try
// try to create a grid (from the given grid file or the input file)
/////////////////////////////////////////////////////////////////////
GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager;
GridManager<GetPropType<TypeTag, Properties::Grid>> gridManager;
gridManager.init();
////////////////////////////////////////////////////////////
......@@ -82,33 +82,35 @@ int main(int argc, char** argv) try
const auto& leafGridView = gridManager.grid().leafGridView();
// create the finite volume grid geometry
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>;
auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView);
fvGridGeometry->update();
// the problem (initial and boundary conditions)
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using Problem = GetPropType<TypeTag, Properties::Problem>;
auto problem = std::make_shared<Problem>(fvGridGeometry);
// the solution vector
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
SolutionVector x(fvGridGeometry->numDofs());
problem->applyInitialSolution(x);
auto xOld = x;
// the grid variables
using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables);
using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry);
gridVariables->init(x, xOld);
// initialize the vtk output module
using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields);
VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
VtkOutputFields::init(vtkWriter); //!< Add model specific output fields
// intialize the vtk output module
VtkOutputModule<GridVariables, SolutionVector> vtkWriter(*gridVariables, x, problem->name());
using VelocityOutput = GetPropType<TypeTag, Properties::VelocityOutput>;
vtkWriter.addVelocityOutput(std::make_shared<VelocityOutput>(*gridVariables));
using IOFields = GetPropType<TypeTag, Properties::IOFields>;
IOFields::initOutputModule(vtkWriter); //!< Add model specific output fields
vtkWriter.write(0.0);
// get some time loop parameters
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
auto tEnd = getParam<Scalar>("TimeLoop.TEnd");
auto dt = getParam<Scalar>("TimeLoop.DtInitial");
auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
......
......@@ -53,46 +53,58 @@ 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
NEW_TYPE_TAG(OnePBase, INHERITS_FROM(OneP));
NEW_TYPE_TAG(OnePIncompressible, INHERITS_FROM(CCTpfaModel, OnePBase));
NEW_TYPE_TAG(OnePCompressible, INHERITS_FROM(CCTpfaModel, OnePBase));
// 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
SET_TYPE_PROP(OnePBase, Grid, Dune::YaspGrid<2>);
template<class TypeTag>
struct Grid<TypeTag, TTag::OnePBase> { using type = Dune::YaspGrid<2>; };
// Set the problem type
SET_TYPE_PROP(OnePBase, Problem, OnePTestProblem<TypeTag>);
template<class TypeTag>
struct Problem<TypeTag, TTag::OnePBase> { using type = OnePTestProblem<TypeTag>; };
// set the spatial params
SET_TYPE_PROP(OnePBase, SpatialParams, OnePTestSpatialParams<TypeTag>);
template<class TypeTag>
struct SpatialParams<TypeTag, TTag::OnePBase> { using type = OnePTestSpatialParams<TypeTag>; };
// the fluid system for incompressible tests
SET_PROP(OnePIncompressible, FluidSystem)
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::OnePIncompressible>
{
private:
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
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:
SET_TYPE_PROP(OnePIncompressible, LocalResidual, OnePIncompressibleLocalResidual<TypeTag>);
template<class TypeTag>
struct LocalResidual<TypeTag, TTag::OnePIncompressible> { using type = OnePIncompressibleLocalResidual<TypeTag>; };
// the fluid system for compressible tests
SET_PROP(OnePCompressible, FluidSystem)
template<class TypeTag>
struct FluidSystem<TypeTag, TTag::OnePCompressible>
{
private:
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
public:
using type = FluidSystems::OnePLiquid<Scalar, Components::TabulatedComponent<Components::H2O<Scalar>>>;
};
// Disable caching (for testing purposes)
SET_BOOL_PROP(OnePBase, EnableGridVolumeVariablesCache, false);
SET_BOOL_PROP(OnePBase, EnableGridFluxVariablesCache, false);
SET_BOOL_PROP(OnePBase, EnableFVGridGeometryCache, false);
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 EnableFVGridGeometryCache<TypeTag, TTag::OnePBase> { static constexpr bool value = false; };
} // end namespace Properties
/*!
......@@ -106,15 +118,15 @@ template<class TypeTag>
class OnePTestProblem : public PorousMediumFlowProblem<TypeTag>
{
using ParentType = PorousMediumFlowProblem<TypeTag>;
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using GridView = GetPropType<TypeTag, Properties::GridView>;
using Element = typename GridView::template Codim<0>::Entity;
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using PrimaryVariables = typename GET_PROP_TYPE(TypeTag, PrimaryVariables);
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes);
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>;
using BoundaryTypes = GetPropType<TypeTag, Properties::BoundaryTypes>;
static constexpr int dimWorld = GridView::dimensionworld;
using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
public:
OnePTestProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry)
......
......@@ -51,7 +51,7 @@ int main(int argc, char** argv) try
using namespace Dumux;
// define the type tag for this problem
using TypeTag = TTAG(TYPETAG);
using TypeTag = Properties::TTag::TYPETAG;
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
......@@ -70,7 +70,7 @@ int main(int argc, char** argv) try
// try to create a grid (from the given grid file or the input file)
/////////////////////////////////////////////////////////////////////
GridManager<typename GET_PROP_TYPE(TypeTag, Grid)> gridManager;
GridManager<GetPropType<TypeTag, Properties::Grid>> gridManager;
gridManager.init();
////////////////////////////////////////////////////////////
......@@ -81,29 +81,31 @@ int main(int argc, char** argv) try
const auto& leafGridView = gridManager.grid().leafGridView();
// create the finite volume grid geometry
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>;
auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView);
fvGridGeometry->update();
// the problem (initial and boundary conditions)
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using Problem = GetPropType<TypeTag, Properties::Problem>;
auto problem = std::make_shared<Problem>(fvGridGeometry);
// the solution vector
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
SolutionVector x(fvGridGeometry->numDofs());
// the grid variables
using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables);
using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry);
gridVariables->init(x);
// intialize the vtk output module
using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields);
VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
VtkOutputFields::init(vtkWriter); //!< Add model specific output fields
VtkOutputModule<GridVariables, SolutionVector> vtkWriter(*gridVariables, x, problem->name());
using VelocityOutput = GetPropType<TypeTag, Properties::VelocityOutput>;
vtkWriter.addVelocityOutput(std::make_shared<VelocityOutput>(*gridVariables));
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
......@@ -118,7 +120,7 @@ int main(int argc, char** argv) try
auto linearSolver = std::make_shared<LinearSolver>();
// the discretization matrices for stationary linear problems
using JacobianMatrix = typename GET_PROP_TYPE(TypeTag, JacobianMatrix);
using JacobianMatrix = GetPropType<TypeTag, Properties::JacobianMatrix>;
auto A = std::make_shared<JacobianMatrix>();
auto r = std::make_shared<SolutionVector>();
assembler->setLinearSystem(A, r);
......
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