From 3d3fc2ae9ad40b651a6da6f815730a919ac90250 Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Wed, 15 Nov 2017 17:34:13 +0100 Subject: [PATCH] [1p] Add vtu comparison for new incompr/compr tests --- .../1p/implicit/compressible/CMakeLists.txt | 40 +++- .../1p/implicit/compressible/test_1p.cc | 7 +- .../1p/implicit/compressible/test_1p.input | 5 +- .../compressible/test_1p_stationary.cc | 18 +- .../compressible/test_1p_stationary.input | 2 +- .../1p/implicit/incompressible/CMakeLists.txt | 25 ++- .../1p/implicit/incompressible/test_1p.input | 2 +- .../1p/implicit/incompressible/test_1p_box.cc | 172 ------------------ .../{test_1p_cc.cc => test_1pfv.cc} | 16 +- 9 files changed, 73 insertions(+), 214 deletions(-) delete mode 100644 test/porousmediumflow/1p/implicit/incompressible/test_1p_box.cc rename test/porousmediumflow/1p/implicit/incompressible/{test_1p_cc.cc => test_1pfv.cc} (93%) diff --git a/test/porousmediumflow/1p/implicit/compressible/CMakeLists.txt b/test/porousmediumflow/1p/implicit/compressible/CMakeLists.txt index 2c0f03e587..b41db2f129 100644 --- a/test/porousmediumflow/1p/implicit/compressible/CMakeLists.txt +++ b/test/porousmediumflow/1p/implicit/compressible/CMakeLists.txt @@ -1,35 +1,59 @@ dune_symlink_to_source_files(FILES "test_1p.input" "test_1p_stationary.input") -# compressible +# compressible instationary dune_add_test(NAME test_1p_compressible_tpfa SOURCES test_1p.cc COMPILE_DEFINITIONS TYPETAG=OnePCompressibleTpfa - CMD_ARGS test_1p.input -Problem.Name 1p_tpfa) + COMMAND python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/1ptestcc-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/1p_tpfa-00010.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_1p_compressible_tpfa test_1p.input -Problem.Name 1p_tpfa") dune_add_test(NAME test_1p_compressible_mpfa SOURCES test_1p.cc COMPILE_DEFINITIONS TYPETAG=OnePCompressibleMpfa - CMD_ARGS test_1p.input -Problem.Name 1p_mpfa) + COMMAND python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/1ptestcc-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/1p_mpfa-00010.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_1p_compressible_mpfa test_1p.input -Problem.Name 1p_mpfa") dune_add_test(NAME test_1p_compressible_box SOURCES test_1p.cc COMPILE_DEFINITIONS TYPETAG=OnePCompressibleBox - CMD_ARGS test_1p.input -Problem.Name 1p_box) + COMMAND python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/1ptestbox-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/1p_box-00010.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_1p_compressible_box test_1p.input -Problem.Name 1p_box") -# stationary +# compressible stationary dune_add_test(NAME test_1p_compressible_stationary_tpfa SOURCES test_1p_stationary.cc COMPILE_DEFINITIONS TYPETAG=OnePCompressibleTpfa - CMD_ARGS test_1p_stationary.input -Problem.Name 1p_stationary_tpfa) + COMMAND python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/1ptestcc-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/1p_stationary_tpfa-00001.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_1p_compressible_stationary_tpfa test_1p_stationary.input -Problem.Name 1p_stationary_tpfa") dune_add_test(NAME test_1p_compressible_stationary_mpfa SOURCES test_1p_stationary.cc COMPILE_DEFINITIONS TYPETAG=OnePCompressibleMpfa - CMD_ARGS test_1p_stationary.input -Problem.Name 1p_stationary_mpfa) + COMMAND python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/1ptestcc-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/1p_stationary_mpfa-00001.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_1p_compressible_stationary_mpfa test_1p_stationary.input -Problem.Name 1p_stationary_mpfa") dune_add_test(NAME test_1p_compressible_stationary_box SOURCES test_1p_stationary.cc COMPILE_DEFINITIONS TYPETAG=OnePCompressibleBox - CMD_ARGS test_1p_stationary.input -Problem.Name 1p_stationary_box) + COMMAND python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/1ptestbox-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/1p_stationary_box-00001.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_1p_compressible_stationary_box test_1p_stationary.input -Problem.Name 1p_stationary_box") set(CMAKE_BUILD_TYPE Release) diff --git a/test/porousmediumflow/1p/implicit/compressible/test_1p.cc b/test/porousmediumflow/1p/implicit/compressible/test_1p.cc index c8014ecbbd..2cce167e02 100644 --- a/test/porousmediumflow/1p/implicit/compressible/test_1p.cc +++ b/test/porousmediumflow/1p/implicit/compressible/test_1p.cc @@ -96,11 +96,8 @@ int main(int argc, char** argv) try auto problem = std::make_shared<Problem>(fvGridGeometry); // the solution vector - static constexpr bool isBox = GET_PROP_VALUE(TypeTag, DiscretizationMethod) == DiscretizationMethods::Box; - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - static constexpr int dofCodim = isBox ? GridView::dimension : 0; using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(leafGridView.size(dofCodim)); + SolutionVector x(fvGridGeometry->numDofs()); problem->applyInitialSolution(x); auto xOld = x; @@ -135,7 +132,7 @@ int main(int argc, char** argv) try auto linearSolver = std::make_shared<LinearSolver>(); // the non-linear solver - using NewtonController = NewtonController<TypeTag>; + using NewtonController = Dumux::NewtonController<TypeTag>; auto newtonController = std::make_shared<NewtonController>(leafGridView.comm(), timeLoop); NewtonMethod<NewtonController, Assembler, LinearSolver> nonLinearSolver(newtonController, assembler, linearSolver); diff --git a/test/porousmediumflow/1p/implicit/compressible/test_1p.input b/test/porousmediumflow/1p/implicit/compressible/test_1p.input index 17f8779d64..05d589ba34 100644 --- a/test/porousmediumflow/1p/implicit/compressible/test_1p.input +++ b/test/porousmediumflow/1p/implicit/compressible/test_1p.input @@ -1,12 +1,11 @@ [TimeLoop] -TEnd = 0.02 +TEnd = 0.1 DtInitial = 0.002 -#MaxTimeStepSize = 1.1e-6 #for explicit scheme [Grid] LowerLeft = 0 0 UpperRight = 1 1 -Cells = 100 100 +Cells = 10 10 [Problem] Name = 1p diff --git a/test/porousmediumflow/1p/implicit/compressible/test_1p_stationary.cc b/test/porousmediumflow/1p/implicit/compressible/test_1p_stationary.cc index 5ff4f03429..cf5ab4a23d 100644 --- a/test/porousmediumflow/1p/implicit/compressible/test_1p_stationary.cc +++ b/test/porousmediumflow/1p/implicit/compressible/test_1p_stationary.cc @@ -94,17 +94,20 @@ int main(int argc, char** argv) try auto problem = std::make_shared<Problem>(fvGridGeometry); // the solution vector - static constexpr bool isBox = GET_PROP_VALUE(TypeTag, DiscretizationMethod) == DiscretizationMethods::Box; - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - static constexpr int dofCodim = isBox ? GridView::dimension : 0; using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(leafGridView.size(dofCodim)); + SolutionVector x(fvGridGeometry->numDofs()); // the grid variables using GridVariables = typename GET_PROP_TYPE(TypeTag, 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 + vtkWriter.write(0.0); + // the assembler with time loop for instationary problem using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables); @@ -114,7 +117,7 @@ int main(int argc, char** argv) try auto linearSolver = std::make_shared<LinearSolver>(); // the non-linear solver - using NewtonController = NewtonController<TypeTag>; + using NewtonController = Dumux::NewtonController<TypeTag>; auto newtonController = std::make_shared<NewtonController>(leafGridView.comm()); NewtonMethod<NewtonController, Assembler, LinearSolver> nonLinearSolver(newtonController, assembler, linearSolver); @@ -123,10 +126,7 @@ int main(int argc, char** argv) try nonLinearSolver.solve(x); // write vtk output - Dune::VTKWriter<GridView> vtkwriter(leafGridView); - if (isBox) vtkwriter.addVertexData(x, "p"); - else vtkwriter.addCellData(x, "p"); - vtkwriter.write(problem->name()); + vtkWriter.write(1.0); timer.stop(); diff --git a/test/porousmediumflow/1p/implicit/compressible/test_1p_stationary.input b/test/porousmediumflow/1p/implicit/compressible/test_1p_stationary.input index 51ad61e9b6..a5c0dd2284 100644 --- a/test/porousmediumflow/1p/implicit/compressible/test_1p_stationary.input +++ b/test/porousmediumflow/1p/implicit/compressible/test_1p_stationary.input @@ -1,7 +1,7 @@ [Grid] LowerLeft = 0 0 UpperRight = 1 1 -Cells = 100 100 +Cells = 10 10 [Problem] Name = 1p diff --git a/test/porousmediumflow/1p/implicit/incompressible/CMakeLists.txt b/test/porousmediumflow/1p/implicit/incompressible/CMakeLists.txt index 4dd8c941f5..f5d8d0b7f6 100644 --- a/test/porousmediumflow/1p/implicit/incompressible/CMakeLists.txt +++ b/test/porousmediumflow/1p/implicit/incompressible/CMakeLists.txt @@ -2,19 +2,32 @@ dune_symlink_to_source_files(FILES "test_1p.input") # using tpfa dune_add_test(NAME test_1p_incompressible_tpfa - SOURCES test_1p_cc.cc + SOURCES test_1pfv.cc COMPILE_DEFINITIONS TYPETAG=OnePIncompressibleTpfa - CMD_ARGS test_1p.input) + COMMAND python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/1ptestcc-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/1ptestcctpfa-00001.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_1p_incompressible_tpfa test_1p.input -Problem.Name 1ptestcctpfa") # using mpfa dune_add_test(NAME test_1p_incompressible_mpfa - SOURCES test_1p_cc.cc + SOURCES test_1pfv.cc COMPILE_DEFINITIONS TYPETAG=OnePIncompressibleMpfa - CMD_ARGS test_1p.input) + COMMAND python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/1ptestcc-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/1ptestccmpfa-00001.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_1p_incompressible_mpfa test_1p.input -Problem.Name 1ptestccmpfa") # using box dune_add_test(NAME test_1p_incompressible_box - SOURCES test_1p_box.cc - CMD_ARGS test_1p.input) + SOURCES test_1pfv.cc + COMPILE_DEFINITIONS TYPETAG=OnePIncompressibleBox + COMMAND python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/1ptestbox-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/1ptestbox-00001.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_1p_incompressible_box test_1p.input -Problem.Name 1ptestbox") set(CMAKE_BUILD_TYPE Release) diff --git a/test/porousmediumflow/1p/implicit/incompressible/test_1p.input b/test/porousmediumflow/1p/implicit/incompressible/test_1p.input index 41b057a2a5..ebf9ad8f55 100644 --- a/test/porousmediumflow/1p/implicit/incompressible/test_1p.input +++ b/test/porousmediumflow/1p/implicit/incompressible/test_1p.input @@ -4,7 +4,7 @@ Name = incompressible [Grid] LowerLeft = 0 0 UpperRight = 1 1 -Cells = 100 100 +Cells = 10 10 [SpatialParams] LensLowerLeft = 0.2 0.2 diff --git a/test/porousmediumflow/1p/implicit/incompressible/test_1p_box.cc b/test/porousmediumflow/1p/implicit/incompressible/test_1p_box.cc deleted file mode 100644 index beb62a1ab8..0000000000 --- a/test/porousmediumflow/1p/implicit/incompressible/test_1p_box.cc +++ /dev/null @@ -1,172 +0,0 @@ -// -*- 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 test for the one-phase CC model - */ -#include <config.h> - -#include <ctime> -#include <iostream> - -#include <dune/common/parallel/mpihelper.hh> -#include <dune/common/timer.hh> -#include <dune/grid/io/file/dgfparser/dgfexception.hh> -#include <dune/grid/io/file/vtk.hh> - -#include <dumux/linear/seqsolverbackend.hh> - -#include <dumux/common/propertysystem.hh> -#include <dumux/nonlinear/newtonmethod.hh> -#include <dumux/common/parameters.hh> -#include <dumux/common/valgrind.hh> -#include <dumux/common/dumuxmessage.hh> -#include <dumux/common/defaultusagemessage.hh> - -#include <dumux/assembly/fvassembler.hh> - -#include "problem.hh" - -int main(int argc, char** argv) try -{ - using namespace Dumux; - - using TypeTag = TTAG(OnePIncompressibleBox); - - // initialize MPI, finalize is done automatically on exit - const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); - - // print dumux start message - if (mpiHelper.rank() == 0) - DumuxMessage::print(/*firstCall=*/true); - - //////////////////////////////////////////////////////////// - // parse the command line arguments and input file - //////////////////////////////////////////////////////////// - - // parse command line arguments - Parameters::init(argc, argv); - - ////////////////////////////////////////////////////////////////////// - // try to create a grid (from the given grid file or the input file) - ///////////////////////////////////////////////////////////////////// - - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); - - // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); - - // create the finite volume grid geometry - using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); - auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView); - fvGridGeometry->update(); - - // the problem (boundary conditions) - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - auto problem = std::make_shared<Problem>(fvGridGeometry); - - // the solution vector - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(fvGridGeometry->numDofs()); - - // the grid variables - using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); - auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); - gridVariables->init(x); - - // make assemble and attach linear system - using Assembler = FVAssembler<TypeTag, DiffMethod::analytic>; - auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables); - using JacobianMatrix = typename GET_PROP_TYPE(TypeTag, JacobianMatrix); - auto A = std::make_shared<JacobianMatrix>(); - auto r = std::make_shared<SolutionVector>(); - assembler->setLinearSystem(A, r); - - Dune::Timer timer; - // assemble the local jacobian and the residual - Dune::Timer assemblyTimer; - if (mpiHelper.rank() == 0) std::cout << "Assembling linear system ..." << std::flush; - assembler->assembleJacobianAndResidual(x); - assemblyTimer.stop(); - if (mpiHelper.rank() == 0) std::cout << " took " << assemblyTimer.elapsed() << " seconds." << std::endl; - - // we solve Ax = -r to save update and copy - (*r) *= -1.0; - - // // solve the linear system - Dune::Timer solverTimer; - using LinearSolver = SSORCGBackend<TypeTag>; - auto linearSolver = std::make_shared<LinearSolver>(); - - if (mpiHelper.rank() == 0) std::cout << "Solving linear system using " + linearSolver->name() + "..." << std::flush; - linearSolver->solve(*A, x, *r); - solverTimer.stop(); - if (mpiHelper.rank() == 0) std::cout << " took " << solverTimer.elapsed() << " seconds." << std::endl; - - // output result to vtk - Dune::Timer outputTimer; - if (mpiHelper.rank() == 0) std::cout << "Writing result to file "<< problem->name() <<" ..." << std::flush; - Dune::VTKWriter<GridView> vtkwriter(leafGridView); - vtkwriter.addVertexData(x, "p"); - vtkwriter.write(problem->name()); - outputTimer.stop(); - if (mpiHelper.rank() == 0) std::cout << " took " << outputTimer.elapsed() << " seconds." << std::endl; - - timer.stop(); - - const auto& comm = Dune::MPIHelper::getCollectiveCommunication(); - if (mpiHelper.rank() == 0) - std::cout << "Simulation took " << timer.elapsed() << " seconds on " - << comm.size() << " processes.\n" - << "The cumulative CPU time was " << timer.elapsed()*comm.size() << " seconds.\n"; - - if (mpiHelper.rank() == 0) - Parameters::print(); - - return 0; - -} -catch (Dumux::ParameterException &e) -{ - std::cerr << std::endl << e << " ---> Abort!" << std::endl; - return 1; -} -catch (Dune::DGFException & e) -{ - std::cerr << "DGF exception thrown (" << e << - "). Most likely, the DGF file name is wrong " - "or the DGF file is corrupted, " - "e.g. missing hash at end of file or wrong number (dimensions) of entries." - << " ---> Abort!" << std::endl; - return 2; -} -catch (Dune::Exception &e) -{ - std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl; - return 3; -} -catch (...) -{ - std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; - return 4; -} diff --git a/test/porousmediumflow/1p/implicit/incompressible/test_1p_cc.cc b/test/porousmediumflow/1p/implicit/incompressible/test_1pfv.cc similarity index 93% rename from test/porousmediumflow/1p/implicit/incompressible/test_1p_cc.cc rename to test/porousmediumflow/1p/implicit/incompressible/test_1pfv.cc index d3e6eb8119..28eec4a2bb 100644 --- a/test/porousmediumflow/1p/implicit/incompressible/test_1p_cc.cc +++ b/test/porousmediumflow/1p/implicit/incompressible/test_1pfv.cc @@ -93,6 +93,12 @@ int main(int argc, char** argv) try auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); gridVariables->init(x); + // intialize the vtk output module + VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); + using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); + VtkOutputFields::init(vtkWriter); //! Add model specific output fields + vtkWriter.write(0.0); + // make assemble and attach linear system using Assembler = FVAssembler<TypeTag, DiffMethod::analytic>; auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables); @@ -123,15 +129,7 @@ int main(int argc, char** argv) try if (mpiHelper.rank() == 0) std::cout << " took " << solverTimer.elapsed() << " seconds." << std::endl; // output result to vtk - Dune::Timer outputTimer; - if (mpiHelper.rank() == 0) std::cout << "Writing result to file "<< problem->name() <<" ..." << std::flush; - - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - Dune::VTKWriter<GridView> vtkwriter(leafGridView); - vtkwriter.addCellData(x, "p"); - vtkwriter.write(problem->name()); - outputTimer.stop(); - if (mpiHelper.rank() == 0) std::cout << " took " << outputTimer.elapsed() << " seconds." << std::endl; + vtkWriter.write(1.0); timer.stop(); -- GitLab