From 45873409d594b1d259b7eff2c2259f605334587c Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de> Date: Mon, 18 Dec 2017 17:15:51 +0100 Subject: [PATCH] [stokes][test] Make test_donea stationary --- test/freeflow/staggered/CMakeLists.txt | 2 +- test/freeflow/staggered/doneatestproblem.hh | 2 - test/freeflow/staggered/test_donea.cc | 79 ++++--------------- .../staggered/test_stokes_donea.input | 4 - 4 files changed, 15 insertions(+), 72 deletions(-) diff --git a/test/freeflow/staggered/CMakeLists.txt b/test/freeflow/staggered/CMakeLists.txt index e59bd2a8c4..2ebe3a3c9f 100644 --- a/test/freeflow/staggered/CMakeLists.txt +++ b/test/freeflow/staggered/CMakeLists.txt @@ -68,7 +68,7 @@ dune_add_test(NAME test_stokes_donea COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py CMD_ARGS --script fuzzy --files ${CMAKE_SOURCE_DIR}/test/references/stokes-donea-reference.vtu - ${CMAKE_CURRENT_BINARY_DIR}/test_donea-00002.vtu + ${CMAKE_CURRENT_BINARY_DIR}/test_donea-00001.vtu --command "${CMAKE_CURRENT_BINARY_DIR}/test_stokes_donea") dune_add_test(NAME test_navierstokes_kovasznay diff --git a/test/freeflow/staggered/doneatestproblem.hh b/test/freeflow/staggered/doneatestproblem.hh index 55b62eefea..27a9db66ee 100644 --- a/test/freeflow/staggered/doneatestproblem.hh +++ b/test/freeflow/staggered/doneatestproblem.hh @@ -400,9 +400,7 @@ private: analyticalPressure_[ccDofIdx] = analyticalSolutionAtCc[pressureIdx]; for(int dirIdx = 0; dirIdx < dim; ++dirIdx) - { analyticalVelocity_[ccDofIdx][dirIdx] = analyticalSolutionAtCc[Indices::velocity(dirIdx)]; - } } } } diff --git a/test/freeflow/staggered/test_donea.cc b/test/freeflow/staggered/test_donea.cc index 173b09a2c3..4ef7f924d9 100644 --- a/test/freeflow/staggered/test_donea.cc +++ b/test/freeflow/staggered/test_donea.cc @@ -120,7 +120,7 @@ int main(int argc, char** argv) try auto fvGridGeometry = std::make_shared<FVGridGeometry>(leafGridView); fvGridGeometry->update(); - // the problem (initial and boundary conditions) + // the problem (boundary conditions) using Problem = typename GET_PROP_TYPE(TypeTag, Problem); auto problem = std::make_shared<Problem>(fvGridGeometry); @@ -134,25 +134,11 @@ int main(int argc, char** argv) try SolutionVector x; x[cellCenterIdx].resize(numDofsCellCenter); x[faceIdx].resize(numDofsFace); - problem->applyInitialSolution(x); - auto xOld = x; // the grid variables using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); - gridVariables->init(x, xOld); - - // get some time loop parameters - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - const auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); - const auto maxDivisions = getParam<int>("TimeLoop.MaxTimeStepDivisions"); - const auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); - auto dt = getParam<Scalar>("TimeLoop.DtInitial"); - - // check if we are about to restart a previously interrupted simulation - Scalar restartTime = 0; - if (Parameters::getTree().hasKey("Restart") || Parameters::getTree().hasKey("TimeLoop.Restart")) - restartTime = getParam<Scalar>("TimeLoop.Restart"); + gridVariables->init(x); // intialize the vtk output module using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); @@ -163,13 +149,9 @@ int main(int argc, char** argv) try vtkWriter.addFaceField(problem->getAnalyticalVelocitySolutionOnFace(), "faceVelocityExact"); vtkWriter.write(0.0); - // instantiate time loop - auto timeLoop = std::make_shared<TimeLoop<Scalar>>(restartTime, dt, tEnd); - timeLoop->setMaxTimeStepSize(maxDt); - // the assembler with time loop for instationary problem using Assembler = StaggeredFVAssembler<TypeTag, DiffMethod::numeric>; - auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop); + auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables); // the linear solver using LinearSolver = Dumux::UMFPackBackend<TypeTag>; @@ -178,55 +160,22 @@ int main(int argc, char** argv) try // the non-linear solver using NewtonController = StaggeredNewtonController<TypeTag>; using NewtonMethod = Dumux::NewtonMethod<NewtonController, Assembler, LinearSolver>; - auto newtonController = std::make_shared<NewtonController>(leafGridView.comm(), timeLoop); + auto newtonController = std::make_shared<NewtonController>(leafGridView.comm()); NewtonMethod nonLinearSolver(newtonController, assembler, linearSolver); - // time loop - timeLoop->start(); do - { - // set previous solution for storage evaluations - assembler->setPreviousSolution(xOld); - - // try solving the non-linear system - for (int i = 0; i < maxDivisions; ++i) - { - // linearize & solve - auto converged = nonLinearSolver.solve(x); - - if (converged) - break; - - if (!converged && i == maxDivisions-1) - DUNE_THROW(Dune::MathError, - "Newton solver didn't converge after " - << maxDivisions - << " time-step divisions. dt=" - << timeLoop->timeStepSize() - << ".\nThe solutions of the current and the previous time steps " - << "have been saved to restart files."); - } - - // make the new solution the old solution - xOld = x; - gridVariables->advanceTimeStep(); - - // advance to the time loop to the next step - timeLoop->advanceTimeStep(); - - problem->postTimeStep(x); - - // write vtk output - vtkWriter.write(timeLoop->time()); - - // report statistics of this time step - timeLoop->reportTimeStep(); + // linearize & solve + Dune::Timer timer; + nonLinearSolver.solve(x); - // set new dt as suggested by newton controller - timeLoop->setTimeStepSize(newtonController->suggestTimeStepSize(timeLoop->timeStepSize())); + // write vtk output + vtkWriter.write(1.0); - } while (!timeLoop->finished()); + timer.stop(); - timeLoop->finalize(leafGridView.comm()); + const auto& comm = Dune::MPIHelper::getCollectiveCommunication(); + std::cout << "Simulation took " << timer.elapsed() << " seconds on " + << comm.size() << " processes.\n" + << "The cumulative CPU time was " << timer.elapsed()*comm.size() << " seconds.\n"; //////////////////////////////////////////////////////////// // finalize, print dumux message to say goodbye diff --git a/test/freeflow/staggered/test_stokes_donea.input b/test/freeflow/staggered/test_stokes_donea.input index d58cec3d52..b394c975db 100644 --- a/test/freeflow/staggered/test_stokes_donea.input +++ b/test/freeflow/staggered/test_stokes_donea.input @@ -1,7 +1,3 @@ -[TimeLoop] -DtInitial = 1 # [s] -TEnd = 2 # [s] - [Grid] UpperRight = 1 1 Cells = 40 40 -- GitLab