Skip to content
Snippets Groups Projects
exercise-basic.patch 57.7 KiB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000
diff -ruN exercises/exercise-basic/2p2cmain.cc exercises/solution/exercise-basic/2p2cmain.cc
--- exercises/exercise-basic/2p2cmain.cc	2023-06-01 14:31:33.149062999 +0200
+++ exercises/solution/exercise-basic/2p2cmain.cc	1970-01-01 01:00:00.000000000 +0100
@@ -1,154 +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 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
- * \brief The main file for the 2p2c porousmediumflow problem in exercise-basic
- */
-#include <config.h>
-
-#include <iostream>
-
-#include <dumux/common/initialize.hh>
-#include <dumux/common/properties.hh>
-#include <dumux/common/parameters.hh>
-
-#include <dumux/linear/istlsolvers.hh>
-#include <dumux/linear/linearsolvertraits.hh>
-#include <dumux/linear/linearalgebratraits.hh>
-#include <dumux/nonlinear/newtonsolver.hh>
-
-#include <dumux/assembly/fvassembler.hh>
-#include <dumux/assembly/diffmethod.hh>
-
-#include <dumux/io/vtkoutputmodule.hh>
-#include <dumux/io/grid/gridmanager_yasp.hh>
-
-// The properties file, where the compile time options are defined
-#include "properties2p2c.hh"
-
-////////////////////////
-// the main function
-////////////////////////
-int main(int argc, char** argv)
-{
-    using namespace Dumux;
-
-    // define the type tag for this problem
-    using TypeTag = Properties::TTag::Injection2p2cCC;
-
-    // initialize MPI+X, finalize is done automatically on exit
-    Dumux::initialize(argc, argv);
-
-    // parse command line arguments and input file
-    Parameters::init(argc, argv);
-
-    // try to create a grid (from the given grid file or the input file)
-    GridManager<GetPropType<TypeTag, Properties::Grid>> gridManager;
-    gridManager.init();
-
-    ////////////////////////////////////////////////////////////
-    // run instationary non-linear problem on this grid
-    ////////////////////////////////////////////////////////////
-
-    // we compute on the leaf grid view
-    const auto& leafGridView = gridManager.grid().leafGridView();
-
-    // create the finite volume grid geometry
-    using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
-    auto gridGeometry = std::make_shared<GridGeometry>(leafGridView);
-
-    // the problem (initial and boundary conditions)
-    using Problem = GetPropType<TypeTag, Properties::Problem>;
-    auto problem = std::make_shared<Problem>(gridGeometry);
-
-    // the solution vector
-    using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
-    SolutionVector x;
-    problem->applyInitialSolution(x);
-    auto xOld = x;
-
-    // the grid variables
-    using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
-    auto gridVariables = std::make_shared<GridVariables>(problem, gridGeometry);
-    gridVariables->init(x);
-
-    // initialize the vtk output module
-    using IOFields = GetPropType<TypeTag, Properties::IOFields>;
-    VtkOutputModule<GridVariables, SolutionVector> vtkWriter(*gridVariables, x, problem->name());
-    using VelocityOutput = GetPropType<TypeTag, Properties::VelocityOutput>;
-    vtkWriter.addVelocityOutput(std::make_shared<VelocityOutput>(*gridVariables));
-    IOFields::initOutputModule(vtkWriter); //!< Add model specific output fields
-    vtkWriter.write(0.0);
-
-    // instantiate time loop
-    using Scalar = GetPropType<TypeTag, Properties::Scalar>;
-    const auto tEnd = getParam<Scalar>("TimeLoop.TEnd");
-    const auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
-    const auto dt = getParam<Scalar>("TimeLoop.DtInitial");
-    auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0, dt, tEnd);
-    timeLoop->setMaxTimeStepSize(maxDt);
-
-    // the assembler with time loop for instationary problem
-    using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>;
-    auto assembler = std::make_shared<Assembler>(problem, gridGeometry, gridVariables, timeLoop, xOld);
-
-    // the linear solver
-    using LinearSolver = AMGBiCGSTABIstlSolver<LinearSolverTraits<GridGeometry>, LinearAlgebraTraitsFromAssembler<Assembler>>;
-    auto linearSolver = std::make_shared<LinearSolver>(gridGeometry->gridView(), gridGeometry->dofMapper());
-
-    // the non-linear solver
-//     using PrimaryVariableSwitch = GetPropType<TypeTag, Properties::PrimaryVariableSwitch>;
-    using NewtonSolver = NewtonSolver<Assembler, LinearSolver>;
-    NewtonSolver nonLinearSolver(assembler, linearSolver);
-
-    // time loop
-    timeLoop->start();
-    while (!timeLoop->finished())
-    {
-        //set time in problem (is used in time-dependent Neumann boundary condition)
-        problem->setTime(timeLoop->time()+timeLoop->timeStepSize());
-
-        // solve the non-linear system with time step control
-        nonLinearSolver.solve(x, *timeLoop);
-
-        // make the new solution the old solution
-        xOld = x;
-        gridVariables->advanceTimeStep();
-
-        // advance to the time loop to the next step
-        timeLoop->advanceTimeStep();
-
-        // report statistics of this time step
-        timeLoop->reportTimeStep();
-
-        // set new dt as suggested by the newton solver
-        timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize()));
-
-        // output to vtk
-        vtkWriter.write(timeLoop->time());
-    }
-
-    timeLoop->finalize(leafGridView.comm());
-
-    // print parameter report
-    if (leafGridView.comm().rank() == 0)
-        Parameters::print();
-
-    return 0;
-} // end main
diff -ruN exercises/exercise-basic/2pmain.cc exercises/solution/exercise-basic/2pmain.cc
--- exercises/exercise-basic/2pmain.cc	2023-06-01 14:31:33.149062999 +0200
+++ exercises/solution/exercise-basic/2pmain.cc	1970-01-01 01:00:00.000000000 +0100
@@ -1,157 +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 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
- * \brief The main file for the two-phase porousmediumflow problem of exercise-basic
- */
-#include <config.h>
-
-#include <iostream>
-
-#include <dumux/common/initialize.hh>
-#include <dumux/common/properties.hh>
-#include <dumux/common/parameters.hh>
-
-#include <dumux/linear/istlsolvers.hh>
-#include <dumux/linear/linearsolvertraits.hh>
-#include <dumux/linear/linearalgebratraits.hh>
-#include <dumux/nonlinear/newtonsolver.hh>
-
-#include <dumux/assembly/fvassembler.hh>
-#include <dumux/assembly/diffmethod.hh>
-
-#include <dumux/io/vtkoutputmodule.hh>
-#include <dumux/io/grid/gridmanager_yasp.hh>
-
-// The properties file, where the compile time options are defined
-#include "properties2p.hh"
-
-////////////////////////
-// the main function
-////////////////////////
-int main(int argc, char** argv)
-{
-    using namespace Dumux;
-
-    // define the type tag for this problem
-    using TypeTag = Properties::TTag::Injection2pCC;
-
-    /// initialize MPI+X, finalize is done automatically on exit
-    Dumux::initialize(argc, argv);
-
-    // parse command line arguments and input file
-    Parameters::init(argc, argv);
-
-    // try to create a grid (from the given grid file or the input file)
-    GridManager<GetPropType<TypeTag, Properties::Grid>> gridManager;
-    gridManager.init();
-
-    ////////////////////////////////////////////////////////////
-    // run instationary non-linear problem on this grid
-    ////////////////////////////////////////////////////////////
-
-    // we compute on the leaf grid view
-    const auto& leafGridView = gridManager.grid().leafGridView();
-
-    // create the finite volume grid geometry
-    using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
-    auto gridGeometry = std::make_shared<GridGeometry>(leafGridView);
-
-    // the problem (initial and boundary conditions)
-    using Problem = GetPropType<TypeTag, Properties::Problem>;
-    auto problem = std::make_shared<Problem>(gridGeometry);
-
-    // the solution vector
-    using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
-    SolutionVector x;
-    problem->applyInitialSolution(x);
-    auto xOld = x;
-
-    // the grid variables
-    using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
-    auto gridVariables = std::make_shared<GridVariables>(problem, gridGeometry);
-    gridVariables->init(x);
-
-    // initialize the vtk output module
-    using IOFields = GetPropType<TypeTag, Properties::IOFields>;
-
-    // use non-conforming output for the test with interface solver
-    const auto ncOutput = getParam<bool>("Problem.UseNonConformingOutput", false);
-    VtkOutputModule<GridVariables, SolutionVector> vtkWriter(*gridVariables, x, problem->name(), "",
-                                                             ncOutput ? Dune::VTK::nonconforming : Dune::VTK::conforming);
-    using VelocityOutput = GetPropType<TypeTag, Properties::VelocityOutput>;
-    vtkWriter.addVelocityOutput(std::make_shared<VelocityOutput>(*gridVariables));
-    IOFields::initOutputModule(vtkWriter); //!< Add model specific output fields
-    vtkWriter.write(0.0);
-
-    // instantiate time loop
-    using Scalar = GetPropType<TypeTag, Properties::Scalar>;
-    const auto tEnd = getParam<Scalar>("TimeLoop.TEnd");
-    const auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
-    const auto dt = getParam<Scalar>("TimeLoop.DtInitial");
-    auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0, dt, tEnd);
-    timeLoop->setMaxTimeStepSize(maxDt);
-
-    // the assembler with time loop for instationary problem
-    using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>;
-    auto assembler = std::make_shared<Assembler>(problem, gridGeometry, gridVariables, timeLoop, xOld);
-
-    // the linear solver
-    using LinearSolver = AMGBiCGSTABIstlSolver<LinearSolverTraits<GridGeometry>, LinearAlgebraTraitsFromAssembler<Assembler>>;
-    auto linearSolver = std::make_shared<LinearSolver>(gridGeometry->gridView(), gridGeometry->dofMapper());
-
-    // the non-linear solver
-    using NewtonSolver = Dumux::NewtonSolver<Assembler, LinearSolver>;
-    NewtonSolver nonLinearSolver(assembler, linearSolver);
-
-    // time loop
-    timeLoop->start();
-    while (!timeLoop->finished())
-    {
-        //set time in problem (is used in time-dependent Neumann boundary condition)
-        problem->setTime(timeLoop->time()+timeLoop->timeStepSize());
-
-        // solve the non-linear system with time step control
-        nonLinearSolver.solve(x, *timeLoop);
-
-        // make the new solution the old solution
-        xOld = x;
-        gridVariables->advanceTimeStep();
-
-        // advance to the time loop to the next step
-        timeLoop->advanceTimeStep();
-
-        // report statistics of this time step
-        timeLoop->reportTimeStep();
-
-        // set new dt as suggested by the newton solver
-        timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize()));
-
-        // output to vtk
-        vtkWriter.write(timeLoop->time());
-    }
-
-    timeLoop->finalize(leafGridView.comm());
-
-    // print parameter report
-    if (leafGridView.comm().rank() == 0)
-        Parameters::print();
-
-    return 0;
-} // end main
diff -ruN exercises/exercise-basic/2pnimain.cc exercises/solution/exercise-basic/2pnimain.cc
--- exercises/exercise-basic/2pnimain.cc	1970-01-01 01:00:00.000000000 +0100
+++ exercises/solution/exercise-basic/2pnimain.cc	2023-04-26 14:37:49.789150797 +0200
@@ -0,0 +1,150 @@
+// -*- 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
+ * \brief The solution main file for the two-phase porousmediumflow problem of exercise-basic
+ */
+#include <config.h>
+
+#include <iostream>
+
+#include <dumux/common/initialize.hh>
+#include <dumux/common/properties.hh>
+#include <dumux/common/parameters.hh>
+
+#include <dumux/linear/istlsolvers.hh>
+#include <dumux/linear/linearsolvertraits.hh>
+#include <dumux/linear/linearalgebratraits.hh>
+#include <dumux/nonlinear/newtonsolver.hh>
+
+#include <dumux/assembly/fvassembler.hh>
+#include <dumux/assembly/diffmethod.hh>
+
+#include <dumux/io/vtkoutputmodule.hh>
+#include <dumux/io/grid/gridmanager_yasp.hh>
+
+// The properties file, where the compile time options are defined
+#include "properties2pni.hh"
+
+int main(int argc, char** argv)
+{
+    using namespace Dumux;
+
+    // define the type tag for this problem
+    using TypeTag = Properties::TTag::Injection2pNICC;
+
+    // initialize MPI+X, finalize is done automatically on exit
+    Dumux::initialize(argc, argv);
+
+    // parse command line arguments and input file
+    Parameters::init(argc, argv);
+
+    // try to create a grid (from the given grid file or the input file)
+    GridManager<GetPropType<TypeTag, Properties::Grid>> gridManager;
+    gridManager.init();
+
+    ////////////////////////////////////////////////////////////
+    // run instationary non-linear problem on this grid
+    ////////////////////////////////////////////////////////////
+
+    // we compute on the leaf grid view
+    const auto& leafGridView = gridManager.grid().leafGridView();
+
+    // create the finite volume grid geometry
+    using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
+    auto gridGeometry = std::make_shared<GridGeometry>(leafGridView);
+
+    // the problem (initial and boundary conditions)
+    using Problem = GetPropType<TypeTag, Properties::Problem>;
+    auto problem = std::make_shared<Problem>(gridGeometry);
+
+    // the solution vector
+    using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
+    SolutionVector x;
+    problem->applyInitialSolution(x);
+    auto xOld = x;
+
+    // the grid variables
+    using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
+    auto gridVariables = std::make_shared<GridVariables>(problem, gridGeometry);
+    gridVariables->init(x);
+
+    // initialize the vtk output module
+    using IOFields = GetPropType<TypeTag, Properties::IOFields>;
+    VtkOutputModule<GridVariables, SolutionVector> vtkWriter(*gridVariables, x, problem->name());
+    using VelocityOutput = GetPropType<TypeTag, Properties::VelocityOutput>;
+    vtkWriter.addVelocityOutput(std::make_shared<VelocityOutput>(*gridVariables));
+    IOFields::initOutputModule(vtkWriter); //!< Add model specific output fields
+    vtkWriter.write(0.0);
+
+    // instantiate time loop
+    using Scalar = GetPropType<TypeTag, Properties::Scalar>;
+    const auto tEnd = getParam<Scalar>("TimeLoop.TEnd");
+    const auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
+    const auto dt = getParam<Scalar>("TimeLoop.DtInitial");
+    auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0, dt, tEnd);
+    timeLoop->setMaxTimeStepSize(maxDt);
+
+    // the assembler with time loop for instationary problem
+    using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>;
+    auto assembler = std::make_shared<Assembler>(problem, gridGeometry, gridVariables, timeLoop, xOld);
+
+    // the linear solver
+    using LinearSolver = AMGBiCGSTABIstlSolver<LinearSolverTraits<GridGeometry>, LinearAlgebraTraitsFromAssembler<Assembler>>;
+    auto linearSolver = std::make_shared<LinearSolver>(gridGeometry->gridView(), gridGeometry->dofMapper());
+
+    // the non-linear solver
+    using NewtonSolver = Dumux::NewtonSolver<Assembler, LinearSolver>;
+    NewtonSolver nonLinearSolver(assembler, linearSolver);
+
+    // time loop
+    timeLoop->start();
+    while (!timeLoop->finished())
+    {
+        //set time in problem (is used in time-dependent Neumann boundary condition)
+        problem->setTime(timeLoop->time()+timeLoop->timeStepSize());
+
+        // solve the non-linear system with time step control
+        nonLinearSolver.solve(x, *timeLoop);
+
+        // make the new solution the old solution
+        xOld = x;
+        gridVariables->advanceTimeStep();
+
+        // advance to the time loop to the next step
+        timeLoop->advanceTimeStep();
+
+        // report statistics of this time step
+        timeLoop->reportTimeStep();
+
+        // set new dt as suggested by the newton solver
+        timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize()));
+
+        // output to vtk
+        vtkWriter.write(timeLoop->time());
+    }
+
+    timeLoop->finalize(leafGridView.comm());
+
+    // print parameter report
+    if (leafGridView.comm().rank() == 0)
+        Parameters::print();
+
+    return 0;
+} // end main
diff -ruN exercises/exercise-basic/CMakeLists.txt exercises/solution/exercise-basic/CMakeLists.txt
--- exercises/exercise-basic/CMakeLists.txt	2023-06-01 14:31:33.149062999 +0200
+++ exercises/solution/exercise-basic/CMakeLists.txt	2023-04-26 14:37:49.789150797 +0200
@@ -1,13 +1,6 @@
-# the immiscible two-phase simulation program
-dumux_add_test(NAME exercise_basic_2p
-               SOURCES 2pmain.cc)
-
-# the compositional two-phase two-component simulation program
-dumux_add_test(NAME exercise_basic_2p2c
-               SOURCES 2p2cmain.cc)
-
-# here, add the two-phase non-isothermal simulation program
-
+# the two-phase non-isothermal simulation program
+dumux_add_test(NAME exercise_basic_2pni_solution
+               SOURCES 2pnimain.cc)
 
 # add a symlink for each input file
 add_input_file_links()
diff -ruN exercises/exercise-basic/injection2p2cproblem.hh exercises/solution/exercise-basic/injection2p2cproblem.hh
--- exercises/exercise-basic/injection2p2cproblem.hh	2023-06-01 14:31:33.149062999 +0200
+++ exercises/solution/exercise-basic/injection2p2cproblem.hh	1970-01-01 01:00:00.000000000 +0100
@@ -1,229 +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 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
- *
- * \brief The two-phase porousmediumflow problem for exercise-basic
- */
-
-#ifndef DUMUX_EX_BASIC_PROBLEM_2P2C_HH
-#define DUMUX_EX_BASIC_PROBLEM_2P2C_HH
-
-#include <dumux/common/properties.hh>
-#include <dumux/common/boundarytypes.hh>
-#include <dumux/common/numeqvector.hh>
-#include <dumux/porousmediumflow/problem.hh>
-#include <dumux/material/binarycoefficients/h2o_n2.hh>
-
-namespace Dumux {
-
-/*!
- * \ingroup TwoPTwoCModel
- * \ingroup ImplicitTestProblems
- * \brief Gas injection problem where a gas (here  nitrogen) is injected into a fully
- *        water saturated medium. During buoyancy driven upward migration the gas
- *        passes a high temperature area.
- *
- * The domain is sized 60 m times 40 m.
- *
- * For the mass conservation equation Neumann boundary conditions are used on
- * the top, on the bottom and on the right of the domain, while Dirichlet conditions
- * apply on the left boundary.
- *
- * Gas is injected at the right boundary from 7 m to 15 m at a rate of
- * 0.001 kg/(s m), the remaining Neumann boundaries are no-flow
- * boundaries.
- *
- * At the Dirichlet boundaries a hydrostatic pressure and a gas saturation of zero a
- *
- * This problem uses the \ref TwoPModel model.
- */
-template<class TypeTag>
-class Injection2p2cProblem : public PorousMediumFlowProblem<TypeTag>
-{
-    using ParentType = PorousMediumFlowProblem<TypeTag>;
-    using Scalar = GetPropType<TypeTag, Properties::Scalar>;
-    using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
-    using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
-    using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
-    using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
-    using FVElementGeometry = typename GridGeometry::LocalView;
-    using GridView = typename GridGeometry::GridView;
-    using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
-    using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
-
-    static constexpr int dimWorld = GridView::dimensionworld;
-    using Element = typename GridView::template Codim<0>::Entity;
-    using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
-
-public:
-    Injection2p2cProblem(std::shared_ptr<const GridGeometry> gridGeometry)
-    : ParentType(gridGeometry)
-    {
-        // initialize the tables of the fluid system
-        FluidSystem::init(/*tempMin=*/273.15,
-                /*tempMax=*/423.15,
-                /*numTemp=*/50,
-                /*pMin=*/0.0,
-                /*pMax=*/30e6,
-                /*numP=*/300);
-
-        // name of the problem and output file
-        // getParam<TYPE>("GROUPNAME.PARAMNAME") reads and sets parameter PARAMNAME
-        // of type TYPE given in the group GROUPNAME from the input file
-        name_ = getParam<std::string>("Problem.Name");
-        // depth of the aquifer, units: m
-        aquiferDepth_ = getParam<Scalar>("Problem.AquiferDepth");
-        // the duration of the injection, units: second
-        injectionDuration_ = getParam<Scalar>("Problem.InjectionDuration");
-    }
-
-    /*!
-     * \brief Returns the problem name
-     *
-     * This is used as a prefix for files generated by the simulation.
-     */
-    std::string name() const
-    { return name_+"-2p2c"; }
-
-    /*!
-     * \brief Specifies which kind of boundary condition should be
-     *        used for which equation on a given boundary segment.
-     *
-     * \param globalPos The position for which the bc type should be evaluated
-     */
-    BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
-    {
-         BoundaryTypes bcTypes;
-        if (globalPos[0] < eps_)
-            bcTypes.setAllDirichlet();
-        else
-            bcTypes.setAllNeumann();
-
-        return bcTypes;
-    }
-
-    /*!
-     * \brief Evaluates the boundary conditions for a Dirichlet
-     *        boundary segment
-     *
-     * \param globalPos The global position
-     */
-    PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
-    {
-        return initialAtPos(globalPos);
-    }
-
-    /*!
-     * \brief Evaluate the boundary conditions for a Neumann
-     *        boundary segment.
-     *
-     * \param globalPos The position of the integration point of the boundary segment.
-     */
-    NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
-    {
-        // initialize values to zero, i.e. no-flow Neumann boundary conditions
-        NumEqVector values(0.0);
-
-        // if we are inside the injection zone set inflow Neumann boundary conditions
-        if (injectionActive() && onInjectionBoundary(globalPos))
-        {
-            // TODO: dumux-course-task
-            //instead of setting -1e-4 here directly use totalAreaSpecificInflow_ in the computation
-
-            // inject nitrogen. negative values mean injection
-            // convert from units kg/(s*m^2) to mole/(s*m^2)
-            values[Indices::conti0EqIdx + FluidSystem::N2Idx] = -1e-4/FluidSystem::molarMass(FluidSystem::N2Idx);
-            values[Indices::conti0EqIdx + FluidSystem::H2OIdx] = 0.0;
-        }
-
-        return values;
-    }
-
-    /*!
-     * \brief Evaluate the source term for all phases within a given
-     *        sub-control-volume.
-     *
-     * \param globalPos The position for which the source term should be evaluated
-     */
-    NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
-    {
-        return NumEqVector(0.0);
-    }
-
-    /*!
-     * \brief Evaluate the initial value for a control volume.
-     *
-     * \param globalPos The position for which the initial condition should be evaluated
-     */
-    PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
-    {
-        PrimaryVariables values(0.0);
-        values.setState(Indices::firstPhaseOnly);
-        // get the water density at atmospheric conditions
-        const Scalar densityW = FluidSystem::H2O::liquidDensity(this->spatialParams().temperatureAtPos(globalPos), 1.0e5);
-
-        // assume an initially hydrostatic liquid pressure profile
-        // note: we subtract rho_w*g*h because g is defined negative
-        const Scalar pw = 1.0e5 - densityW*this->spatialParams().gravity(globalPos)[dimWorld-1]*(aquiferDepth_ - globalPos[dimWorld-1]);
-
-        // initially we have some nitrogen dissolved
-        // saturation mole fraction would be
-        // moleFracLiquidN2 = (pw + pc + p_vap^sat)/henry;
-        const Scalar moleFracLiquidN2 = pw*0.95/BinaryCoeff::H2O_N2::henry(this->spatialParams().temperatureAtPos(globalPos));
-
-        // note that because we start with a single phase system the primary variables
-        // are pl and x^w_N2. This will switch as soon after we start injecting to a two
-        // phase system so the primary variables will be pl and Sn (nonwetting saturation).
-        values[Indices::pressureIdx] = pw;
-        values[Indices::switchIdx] = moleFracLiquidN2;
-
-        return values;
-    }
-
-    //! set the time for the time dependent boundary conditions (called from main)
-    void setTime(Scalar time)
-    { time_ = time; }
-
-    //! Return true if the injection is currently active
-    bool injectionActive() const
-    { return time_ < injectionDuration_; }
-
-    //! Return true if the given position is in the injection boundary region
-    bool onInjectionBoundary(const GlobalPosition& globalPos) const
-    {
-        return globalPos[1] < 15. + eps_
-            && globalPos[1] > 7. - eps_
-            && globalPos[0] > this->gridGeometry().bBoxMax()[0] - eps_;
-    }
-
-private:
-    static constexpr Scalar eps_ = 1e-6;
-    std::string name_; //! Problem name
-    Scalar aquiferDepth_; //! Depth of the aquifer in m
-    Scalar injectionDuration_; //! Duration of the injection in seconds
-    Scalar time_;
-    //TODO: dumux-course-task
-    //define the Scalar totalAreaSpecificInflow_ here
-
-};
-
-} //end namespace Dumux
-
-#endif
diff -ruN exercises/exercise-basic/injection2pniproblem.hh exercises/solution/exercise-basic/injection2pniproblem.hh
--- exercises/exercise-basic/injection2pniproblem.hh	2023-06-01 14:31:33.149062999 +0200
+++ exercises/solution/exercise-basic/injection2pniproblem.hh	2023-04-26 14:37:49.789150797 +0200
@@ -19,7 +19,7 @@
 /*!
  * \file
  *
- * \brief The two-phase nonisothermal porousmediumflow problem for exercise-basic
+ * \brief The solution of the two-phase nonisothermal porousmediumflow problem for exercise-basic
  */
 
 #ifndef DUMUX_EX_BASIC_PROBLEM_2PNI_HH
@@ -31,7 +31,6 @@
 #include <dumux/porousmediumflow/problem.hh>
 
 namespace Dumux {
-
 /*!
  * \ingroup TwoPModel
  * \ingroup ImplicitTestProblems
@@ -46,7 +45,7 @@
  * apply on the left boundary.
  *
  * Gas is injected at the right boundary from 7 m to 15 m at a rate of
- * 0.0001 kg/(s m), the remaining Neumann boundaries are no-flow
+ * 0.001 kg/(s m), the remaining Neumann boundaries are no-flow
  * boundaries.
  *
  * At the Dirichlet boundaries a hydrostatic pressure and a gas saturation of zero a
@@ -57,13 +56,13 @@
 class Injection2PNIProblem : public PorousMediumFlowProblem<TypeTag>
 {
     using ParentType = PorousMediumFlowProblem<TypeTag>;
+    using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
     using Scalar = GetPropType<TypeTag, Properties::Scalar>;
     using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
     using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
     using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
     using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
-    using FVElementGeometry = typename GridGeometry::LocalView;
-    using GridView = typename GridGeometry::GridView;
+    using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
     using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
     using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
 
@@ -115,14 +114,6 @@
         else
             bcTypes.setAllNeumann();
 
-         /*!
-          * TODO:dumux-course-task:
-          * dumux-course-task:
-          * set Dirichlet conditions for the energy equation on the left boundary
-          * and Neumann everywhere else
-          * think about: is there anything necessary to do here?
-          */
-
         return bcTypes;
     }
 
@@ -135,13 +126,6 @@
     PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
     {
         return initialAtPos(globalPos);
-
-         /*!
-          * TODO:dumux-course-task:
-          * dumux-course-task:
-          * set Dirichlet conditions for the energy equation on the left boundary
-          * think about: is there anything necessary to do here?
-          */
     }
 
     /*!
@@ -156,19 +140,14 @@
         NumEqVector values(0.0);
 
         // if we are inside the injection zone set inflow Neumann boundary conditions
-        if (injectionActive() && onInjectionBoundary(globalPos))
+         if (injectionActive() && onInjectionBoundary(globalPos))
         {
+        
             // inject nitrogen. negative values mean injection
             // units kg/(s*m^2)
             values[Indices::conti0EqIdx + FluidSystem::N2Idx] = -1e-4;
             values[Indices::conti0EqIdx + FluidSystem::H2OIdx] = 0.0;
-
-         /*!
-          * TODO:dumux-course-task:
-          * dumux-course-task:
-          * set Neumann noflow conditions for the energy equation everywhere else except the left boundary
-          * hint: use Indices::energyEqIdx) for that (if required)
-          */
+            values[Indices::energyEqIdx] = 0.0;
         }
 
         return values;
@@ -204,20 +183,17 @@
         values[Indices::pressureIdx] = pw;
         values[Indices::saturationIdx] = 0.0;
 
-        /*!
-        *  TODO:dumux-course-task:
-        * set a temperature gradient of 0.03 K per m beginning at 283 K here.
-        * Hint: you can use aquiferDepth_ and the globalPos similar to the pressure gradient
-        * use globalPos[0] and globalPos[1] to implement the high temperature lens with 380 K
-        * Hint : use Indices::temperatureIdx to address the initial values for temperature
-        */
+        values[Indices::temperatureIdx] = 283.0 + (aquiferDepth_ - globalPos[1])*0.03;
+        if (globalPos[0] > 20 - eps_ && globalPos[0] < 30 + eps_ && globalPos[1] > 5 - eps_ && globalPos[1] < 35 + eps_)
+            values[Indices::temperatureIdx] = 380;
+
         return values;
     }
 
     //! set the time for the time dependent boundary conditions (called from main)
     void setTime(Scalar time)
     { time_ = time; }
-
+    
     //! Return true if the injection is currently active
     bool injectionActive() const
     { return time_ < injectionDuration_; }
diff -ruN exercises/exercise-basic/injection2pproblem.hh exercises/solution/exercise-basic/injection2pproblem.hh
--- exercises/exercise-basic/injection2pproblem.hh	2023-06-01 14:31:33.149062999 +0200
+++ exercises/solution/exercise-basic/injection2pproblem.hh	1970-01-01 01:00:00.000000000 +0100
@@ -1,223 +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 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
- *
- * \brief The two-phase porousmediumflow problem for exercise-basic
- */
-
-#ifndef DUMUX_EX_BASIC_PROBLEM_2P_HH
-#define DUMUX_EX_BASIC_PROBLEM_2P_HH
-
-#include <dumux/common/properties.hh>
-#include <dumux/common/boundarytypes.hh>
-#include <dumux/common/numeqvector.hh>
-#include <dumux/porousmediumflow/problem.hh>
-
-namespace Dumux {
-
-/*!
- * \ingroup TwoPModel
- * \ingroup ImplicitTestProblems
- * \brief Gas injection problem where a gas (here  nitrogen) is injected into a fully
- *        water saturated medium. During buoyancy driven upward migration the gas
- *        passes a high temperature area.
- *
- * The domain is sized 60 m times 40 m.
- *
- * For the mass conservation equation neumann boundary conditions are used on
- * the top, on the bottom and on the right of the domain, while dirichlet conditions
- * apply on the left boundary.
- *
- * Gas is injected at the right boundary from 7 m to 15 m at a rate of
- * 0.001 kg/(s m), the remaining neumann boundaries are no-flow
- * boundaries.
- *
- * At the dirichlet boundaries a hydrostatic pressure and a gas saturation of zero a
- *
- * This problem uses the \ref TwoPModel model.
- */
-template<class TypeTag>
-class Injection2PProblem : public PorousMediumFlowProblem<TypeTag>
-{
-    using ParentType = PorousMediumFlowProblem<TypeTag>;
-    using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView;
-    using Scalar = GetPropType<TypeTag, Properties::Scalar>;
-    using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
-    using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
-    using BoundaryTypes = Dumux::BoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
-    using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
-    using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView;
-    using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
-    using NumEqVector = Dumux::NumEqVector<PrimaryVariables>;
-
-    static constexpr int dimWorld = GridView::dimensionworld;
-    using Element = typename GridView::template Codim<0>::Entity;
-    using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
-
-public:
-    Injection2PProblem(std::shared_ptr<const GridGeometry> gridGeometry)
-    : ParentType(gridGeometry)
-    {
-        // initialize the tables of the fluid system
-        FluidSystem::init(/*tempMin=*/273.15,
-                /*tempMax=*/423.15,
-                /*numTemp=*/50,
-                /*pMin=*/0.0,
-                /*pMax=*/30e6,
-                /*numP=*/300);
-
-        // name of the problem and output file
-        // getParam<TYPE>("GROUPNAME.PARAMNAME") reads and sets parameter PARAMNAME
-        // of type TYPE given in the group GROUPNAME from the input file
-        name_ = getParam<std::string>("Problem.Name");
-        // depth of the aquifer, units: m
-        aquiferDepth_ = getParam<Scalar>("Problem.AquiferDepth");
-        // the duration of the injection, units: second
-        injectionDuration_ = getParam<Scalar>("Problem.InjectionDuration");
-    }
-
-
-    /*!
-     * \brief Returns the problem name
-     *
-     * This is used as a prefix for files generated by the simulation.
-     */
-    std::string name() const
-    { return name_+"-2p"; }
-
-
-    /*!
-     * \brief Specifies which kind of boundary condition should be
-     *        used for which equation on a given boundary segment.
-     *
-     * \param globalPos The position for which the bc type should be evaluated
-     */
-    BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
-    {
-        BoundaryTypes bcTypes;
-        // set the left of the domain (with the global position in "0 = x" direction as a Dirichlet boundary
-        if (globalPos[0] < eps_)
-            bcTypes.setAllDirichlet();
-        // set all other as Neumann boundaries
-        else
-            bcTypes.setAllNeumann();
-
-        return bcTypes;
-    }
-
-    /*!
-     * \brief Evaluates the boundary conditions for a Dirichlet
-     *        boundary segment
-     *
-     * \param globalPos The global position
-     */
-    PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
-    {
-        return initialAtPos(globalPos);
-    }
-
-    /*!
-     * \brief Evaluate the boundary conditions for a neumann
-     *        boundary segment.
-     *
-     * \param globalPos The position of the integration point of the boundary segment.
-     */
-    NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
-    {
-        // initialize values to zero, i.e. no-flow Neumann boundary conditions
-        NumEqVector values(0.0);
-
-        // if we are inside the injection zone set inflow Neumann boundary conditions