Commit 515ceee0 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[test][1p][compressible][box] use new time integration

parent 1ef2642a
......@@ -31,13 +31,13 @@ dumux_add_test(NAME test_1p_compressible_instationary_box
${CMAKE_CURRENT_BINARY_DIR}/test_1p_compressible_instationary_box-00010.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_1p_compressible_instationary_box params.input -Problem.Name test_1p_compressible_instationary_box")
dumux_add_test(NAME test_1p_compressible_instationary_tpfa_experimental
dumux_add_test(NAME test_1p_compressible_instationary_box_experimental
LABELS porousmediumflow 1p experimental
SOURCES main_experimental.cc
COMPILE_DEFINITIONS TYPETAG=OnePCompressibleTpfa
COMPILE_DEFINITIONS TYPETAG=OnePCompressibleBox
COMPILE_DEFINITIONS EXPERIMENTAL=1
COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
CMD_ARGS --script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/test_1p_cc-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/test_1p_compressible_instationary_tpfa_experimental-00010.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_1p_compressible_instationary_tpfa_experimental params.input -Problem.Name test_1p_compressible_instationary_tpfa_experimental")
--files ${CMAKE_SOURCE_DIR}/test/references/test_1p_box-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/test_1p_compressible_instationary_box_experimental-00010.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_1p_compressible_instationary_box_experimental params.input -Problem.Name test_1p_compressible_instationary_box_experimental")
// -*- 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 3 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
* \ingroup OnePTests
* \brief Dummy assembler that fulfills the new experimental assembly interface.
*/
#ifndef DUMUX_COMPRESSIBLE_ONEP_TEST_ASSEMBLER_HH
#define DUMUX_COMPRESSIBLE_ONEP_TEST_ASSEMBLER_HH
namespace Dumux::OnePCompressibleTest {
// Custom assembler to test assembly with grid variables,
// fulfilling the foreseen required interface
template<class Assembler>
class GridVarsAssembler : public Assembler
{
public:
using Assembler::Assembler;
using typename Assembler::GridVariables;
using typename Assembler::ResidualType;
using Variables = GridVariables;
void assembleJacobianAndResidual(const GridVariables& gridVars)
{ Assembler::assembleJacobianAndResidual(gridVars.dofs()); }
void assembleResidual(const GridVariables& gridVars)
{ Assembler::assembleResidual(gridVars.dofs()); }
//! Remove residualNorm once this is fixed in the solvers !2113
auto residualNorm(const GridVariables& gridVars)
{ return Assembler::residualNorm(gridVars.dofs()); }
};
} // end namespace Dumux::OnePCompressibleTest
#endif
// -*- 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 3 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
* \ingroup OnePTests
* \brief Wrapper around the current FVGridVariables to fulfill the layout
* of the new grid variables to test grid variables-based assembly.
*/
#ifndef DUMUX_COMPRESSIBLE_ONEP_TEST_GRID_VARIABLES_HH
#define DUMUX_COMPRESSIBLE_ONEP_TEST_GRID_VARIABLES_HH
#include <dumux/discretization/gridvariables.hh>
namespace Dumux::OnePCompressibleTest {
template<class GG, class BaseGridVariables, class SolutionVector>
class TestGridVariables
: public BaseGridVariables
, public Dumux::Experimental::GridVariables<GG, SolutionVector>
{
using ExperimentalBase = Dumux::Experimental::GridVariables<GG, SolutionVector>;
public:
// export some types to avoid ambiguity
using GridGeometry = GG;
using Scalar = typename BaseGridVariables::Scalar;
template<class Problem>
TestGridVariables(std::shared_ptr<Problem> problem,
std::shared_ptr<const GridGeometry> gridGeometry,
const SolutionVector& x)
: BaseGridVariables(problem, gridGeometry)
, ExperimentalBase(gridGeometry, x)
{
BaseGridVariables::init(x);
}
// update to a new solution
void update(const SolutionVector& x)
{
BaseGridVariables::update(x);
ExperimentalBase::update(x);
}
// overload some functions to avoid ambiguity
decltype(auto) gridGeometry() const
{ return ExperimentalBase::gridGeometry(); }
};
} // end namespace Dumux::OnePCompressibleTest
#endif
......@@ -19,7 +19,7 @@
/*!
* \file
* \ingroup OnePTests
* \brief Test for the one-phase CC model
* \brief Test for the one-phase model
*/
#include <config.h>
#include <ctime>
......@@ -31,6 +31,7 @@
#include <dune/istl/io.hh>
#include <dumux/discretization/method.hh>
#include <dumux/discretization/localcontext.hh>
#include <dumux/common/properties.hh>
#include <dumux/common/parameters.hh>
......@@ -39,13 +40,17 @@
#include <dumux/nonlinear/newtonsolver.hh>
#include <dumux/linear/seqsolverbackend.hh>
#include <dumux/assembly/fvassembler.hh>
#include <dumux/porousmediumflow/immiscible/operators.hh>
#include <dumux/timestepping/multistagemethods.hh>
#include <dumux/assembly/fv/localoperator.hh>
#include <dumux/assembly/fv/boxlocalassembler.hh>
#include <dumux/assembly/assembler.hh>
#include <dumux/io/vtkoutputmodule.hh>
#include <dumux/io/grid/gridmanager.hh>
#include "properties.hh"
#include "assembler.hh"
int main(int argc, char** argv)
{
......@@ -94,7 +99,6 @@ int main(int argc, char** argv)
using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
SolutionVector x(gridGeometry->numDofs());
problem->applyInitialSolution(x);
auto xOld = x;
// the grid variables
using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
......@@ -118,10 +122,19 @@ int main(int argc, char** argv)
auto timeLoop = std::make_shared<CheckPointTimeLoop<Scalar>>(0.0, dt, tEnd);
timeLoop->setMaxTimeStepSize(maxDt);
// the assembler with time loop for instationary problem
using BaseAssembler = FVAssembler<TypeTag, DiffMethod::numeric>;
using Assembler = Dumux::OnePCompressibleTest::GridVarsAssembler<BaseAssembler>;
auto assembler = std::make_shared<Assembler>(problem, gridGeometry, gridVariables, timeLoop, xOld);
// use implicit Euler for time integration
auto timeMethod = std::make_shared<MultiStage::ImplicitEuler<Scalar>>();
// the assembler (we use the immiscible operators to define the system of equations)
using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>;
using LocalContext = Experimental::LocalContext<typename GridVariables::LocalView>;
using Operators = Experimental::FVImmiscibleOperators<ModelTraits, FluxVariables, LocalContext>;
using LocalOperator = Experimental::FVLocalOperator<Operators>;
using LocalAssembler = Experimental::BoxLocalAssembler<LocalOperator>;
using Assembler = Experimental::Assembler<LocalAssembler>;
auto assembler = std::make_shared<Assembler>(gridGeometry, *timeMethod, DiffMethod::numeric);
// the linear solver
using LinearSolver = ILU0BiCGSTABBackend;
......@@ -129,7 +142,11 @@ int main(int argc, char** argv)
// the non-linear solver
using NewtonSolver = Dumux::NewtonSolver<Assembler, LinearSolver>;
NewtonSolver nonLinearSolver(assembler, linearSolver);
auto nonLinearSolver = std::make_shared<NewtonSolver>(assembler, linearSolver);
// the time stepper for time integration
using TimeStepper = MultiStageTimeStepper<NewtonSolver>;
TimeStepper timeStepper(nonLinearSolver, timeMethod);
// set some check points for the time loop
timeLoop->setPeriodicCheckPoint(tEnd/10.0);
......@@ -137,11 +154,8 @@ int main(int argc, char** argv)
// time loop
timeLoop->start(); do
{
// linearize & solve
nonLinearSolver.solve(*gridVariables, *timeLoop);
// make the new solution the old solution
xOld = gridVariables->dofs();
// do time integraiton
timeStepper.step(*gridVariables, timeLoop->time(), timeLoop->timeStepSize());
// advance to the time loop to the next step
timeLoop->advanceTimeStep();
......@@ -154,7 +168,7 @@ int main(int argc, char** argv)
timeLoop->reportTimeStep();
// set new dt as suggested by the newton solver
timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize()));
timeLoop->setTimeStepSize(nonLinearSolver->suggestTimeStepSize(timeLoop->timeStepSize()));
} while (!timeLoop->finished());
......
......@@ -38,7 +38,6 @@
#include "problem.hh"
#include "spatialparams.hh"
#include "gridvariables.hh"
#ifndef EXPERIMENTAL
#define EXPERIMENTAL 0
......@@ -88,14 +87,12 @@ template<class TypeTag>
struct GridVariables<TypeTag, TTag::OnePCompressible>
{
private:
using GG = GetPropType<TypeTag, Properties::GridGeometry>;
using GVV = GetPropType<TypeTag, Properties::GridVolumeVariables>;
using GFC = GetPropType<TypeTag, Properties::GridFluxVariablesCache>;
using Base = Dumux::FVGridVariables<GG, GVV, GFC>;
using X = GetPropType<TypeTag, Properties::SolutionVector>;
public:
using type = Dumux::OnePCompressibleTest::TestGridVariables<GG, Base, X>;
using type = Dumux::Experimental::FVGridVariables<GVV, GFC, X>;
};
#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