Skip to content
Snippets Groups Projects
exercise-mainfile.patch 40.8 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
diff -ruN exercises/exercise-mainfile/1pproblem.hh exercises/solution/exercise-mainfile/1pproblem.hh
--- exercises/exercise-mainfile/1pproblem.hh	2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-mainfile/1pproblem.hh	2023-04-26 14:37:49.797150837 +0200
@@ -24,9 +24,9 @@
 #ifndef DUMUX_EX_MAINFILE_ONEP_TEST_PROBLEM_HH
 #define DUMUX_EX_MAINFILE_ONEP_TEST_PROBLEM_HH
 
+#include <dumux/porousmediumflow/problem.hh>
 #include <dumux/common/properties.hh>
 #include <dumux/common/boundarytypes.hh>
-#include <dumux/porousmediumflow/problem.hh>
 
 namespace Dumux {
 
@@ -55,7 +55,7 @@
     OnePTestProblem(std::shared_ptr<const GridGeometry> gridGeometry)
     : ParentType(gridGeometry)
     {
-        FluidSystem::Component::init(/*tempMin=*/273.15,
+        FluidSystem::Component::init(/*tempMin=*/272.15,
                                      /*tempMax=*/294.15,
                                      /*numTemp=*/10,
                                      /*pMin=*/1.0e4,
@@ -104,7 +104,6 @@
     {
         return PrimaryVariables(1.0e5);
     }
-
 };
 
 } // end namespace Dumux
diff -ruN exercises/exercise-mainfile/CMakeLists.txt exercises/solution/exercise-mainfile/CMakeLists.txt
--- exercises/exercise-mainfile/CMakeLists.txt	2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-mainfile/CMakeLists.txt	2023-04-26 14:37:49.797150837 +0200
@@ -1,12 +1,9 @@
 # the one-phase simulation program
-dumux_add_test(NAME exercise_mainfile_a
-               SOURCES exercise1pamain.cc)
+dumux_add_test(NAME exercise_mainfile_a_solution
+               SOURCES exercise1pa_solution_main.cc
+               COMPILE_DEFINITIONS TYPETAG=OnePIncompressible)
 
-dumux_add_test(NAME exercise_mainfile_b
-               SOURCES exercise1pbmain.cc)
-
-dumux_add_test(NAME exercise_mainfile_c
-               SOURCES exercise1pcmain.cc)
+# here, add the two-phase non-isothermal simulation program
 
 # add a symlink for each input file
 add_input_file_links()
diff -ruN exercises/exercise-mainfile/exercise1pamain.cc exercises/solution/exercise-mainfile/exercise1pamain.cc
--- exercises/exercise-mainfile/exercise1pamain.cc	2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-mainfile/exercise1pamain.cc	1970-01-01 01:00:00.000000000 +0100
@@ -1,142 +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 test for the one-phase CC model
- */
-#include <config.h>
-
-#include "properties.hh"
-
-#include <iostream>
-
-#include <dune/common/timer.hh>
-
-#include <dumux/common/initialize.hh>
-#include <dumux/common/properties.hh>
-#include <dumux/common/parameters.hh>
-
-#include <dumux/linear/istlsolvers.hh>
-#include <dumux/linear/linearalgebratraits.hh>
-#include <dumux/linear/linearsolvertraits.hh>
-
-#include <dumux/assembly/fvassembler.hh>
-
-#include <dumux/io/vtkoutputmodule.hh>
-#include <dumux/io/grid/gridmanager_yasp.hh>
-
-int main(int argc, char** argv)
-{
-    using namespace Dumux;
-
-    // define the type tag for this problem
-    using TypeTag = Properties::TTag::OnePIncompressible;
-
-    ////////////////////////////////////////////////////////////
-    ////////////////////////////////////////////////////////////
-
-    // initialize MPI+x, finalize is done automatically on exit
-    Dumux::initialize(argc, argv);
-
-    // initialize parameter tree
-    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 stationary 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(gridGeometry->numDofs());
-
-    // 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
-    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 3
-    // Change the differentiation method to analytic by changing from DiffMethod::numeric to DiffMethod::analytic
-
-    // the assembler for stationary problems
-    using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>;
-    auto assembler = std::make_shared<Assembler>(problem, gridGeometry, gridVariables);
-
-    // the linear solver
-    using LinearSolver = ILUBiCGSTABIstlSolver<LinearSolverTraits<GridGeometry>, LinearAlgebraTraitsFromAssembler<Assembler>>;
-    auto linearSolver = std::make_shared<LinearSolver>(gridGeometry->gridView(), gridGeometry->dofMapper());
-
-    // the discretization matrices for stationary linear problems
-    using JacobianMatrix = GetPropType<TypeTag, Properties::JacobianMatrix>;
-    auto A = std::make_shared<JacobianMatrix>();
-    auto r = std::make_shared<SolutionVector>();
-    assembler->setLinearSystem(A, r);
-    assembler->assembleJacobianAndResidual(x);
-
-    // we solve Ax = -r to save update and copy
-    (*r) *= -1.0;
-    linearSolver->solve(*A, x, *r);
-
-    // the grid variables need to be up to date for subsequent output
-    gridVariables->update(x);
-
-    // write vtk output
-    vtkWriter.write(1.0);
-
-    timer.stop();
-
-    const auto& comm = leafGridView.comm();
-    std::cout << "Simulation took " << timer.elapsed() << " seconds on "
-              << comm.size() << " processes.\n"
-              << "The cumulative CPU time was " << timer.elapsed()*comm.size() << " seconds.\n";
-
-    if (leafGridView.comm().rank() == 0)
-        Parameters::print();
-
-    return 0;
-
-}// end main
diff -ruN exercises/exercise-mainfile/exercise1pa_solution_main.cc exercises/solution/exercise-mainfile/exercise1pa_solution_main.cc
--- exercises/exercise-mainfile/exercise1pa_solution_main.cc	1970-01-01 01:00:00.000000000 +0100
+++ exercises/solution/exercise-mainfile/exercise1pa_solution_main.cc	2023-04-26 14:37:49.797150837 +0200
@@ -0,0 +1,143 @@
+// -*- 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 test for the one-phase CC model
+ */
+#include <config.h>
+
+#include "1pproblem.hh"
+#include "properties.hh"
+
+#include <iostream>
+
+#include <dune/common/timer.hh>
+
+#include <dumux/common/initialize.hh>
+#include <dumux/common/properties.hh>
+#include <dumux/common/parameters.hh>
+
+#include <dumux/linear/istlsolvers.hh>
+#include <dumux/linear/linearalgebratraits.hh>
+#include <dumux/linear/linearsolvertraits.hh>
+
+#include <dumux/assembly/fvassembler.hh>
+
+#include <dumux/io/vtkoutputmodule.hh>
+#include <dumux/io/grid/gridmanager_yasp.hh>
+
+int main(int argc, char** argv)
+{
+    using namespace Dumux;
+
+    // define the type tag for this problem
+    using TypeTag = Properties::TTag::OnePIncompressible;
+
+    ////////////////////////////////////////////////////////////
+    ////////////////////////////////////////////////////////////
+
+    // initialize MPI+x, finalize is done automatically on exit
+    Dumux::initialize(argc, argv);
+
+    // initialize parameter tree
+    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 stationary 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(gridGeometry->numDofs());
+
+    // 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
+    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
+    // change the differentiation method to analytic by changing from DiffMethod::numeric to DiffMethod::analytic
+
+    // the assembler for stationary problems
+    using Assembler = FVAssembler<TypeTag, DiffMethod::analytic>;
+    auto assembler = std::make_shared<Assembler>(problem, gridGeometry, gridVariables);
+
+    // the linear solver
+    using LinearSolver = ILUBiCGSTABIstlSolver<LinearSolverTraits<GridGeometry>, LinearAlgebraTraitsFromAssembler<Assembler>>;
+    auto linearSolver = std::make_shared<LinearSolver>(gridGeometry->gridView(), gridGeometry->dofMapper());
+
+    // the discretization matrices for stationary linear problems
+    using JacobianMatrix = GetPropType<TypeTag, Properties::JacobianMatrix>;
+    auto A = std::make_shared<JacobianMatrix>();
+    auto r = std::make_shared<SolutionVector>();
+    assembler->setLinearSystem(A, r);
+    assembler->assembleJacobianAndResidual(x);
+
+    // we solve Ax = -r to save update and copy
+    (*r) *= -1.0;
+    linearSolver->solve(*A, x, *r);
+
+    // the grid variables need to be up to date for subsequent output
+    gridVariables->update(x);
+
+    // write vtk output
+    vtkWriter.write(1.0);
+
+    timer.stop();
+
+    const auto& comm = leafGridView.comm();
+    std::cout << "Simulation took " << timer.elapsed() << " seconds on "
+              << comm.size() << " processes.\n"
+              << "The cumulative CPU time was " << timer.elapsed()*comm.size() << " seconds.\n";
+
+    if (leafGridView.comm().rank() == 0)
+        Parameters::print();
+
+    return 0;
+
+}// end main
diff -ruN exercises/exercise-mainfile/exercise1pbmain.cc exercises/solution/exercise-mainfile/exercise1pbmain.cc
--- exercises/exercise-mainfile/exercise1pbmain.cc	2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-mainfile/exercise1pbmain.cc	1970-01-01 01:00:00.000000000 +0100
@@ -1,132 +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 test for the one-phase CC model
- */
-#include <config.h>
-
-#include "properties.hh"
-
-#include <iostream>
-
-#include <dune/common/timer.hh>
-
-#include <dumux/common/initialize.hh>
-#include <dumux/common/properties.hh>
-#include <dumux/common/parameters.hh>
-
-#include <dumux/linear/istlsolvers.hh>
-#include <dumux/linear/linearalgebratraits.hh>
-#include <dumux/linear/linearsolvertraits.hh>
-#include <dumux/nonlinear/newtonsolver.hh>
-
-#include <dumux/assembly/fvassembler.hh>
-
-#include <dumux/io/vtkoutputmodule.hh>
-#include <dumux/io/grid/gridmanager_yasp.hh>
-
-int main(int argc, char** argv)
-{
-    using namespace Dumux;
-
-    // define the type tag for this problem
-    using TypeTag = Properties::TTag::OnePCompressible;
-
-    ////////////////////////////////////////////////////////////
-    ////////////////////////////////////////////////////////////
-
-    // initialize MPI+x, finalize is done automatically on exit
-    Dumux::initialize(argc, argv);
-
-    // initialize parameter tree
-    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 stationary 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(gridGeometry->numDofs());
-
-    // 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
-    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;
-    // the assembler for stationary problems
-    using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>;
-    auto assembler = std::make_shared<Assembler>(problem, gridGeometry, gridVariables);
-
-    // the linear solver
-    using LinearSolver = ILUBiCGSTABIstlSolver<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);
-
-    // linearize & solve
-    nonLinearSolver.solve(x);
-
-    // write vtk output
-    vtkWriter.write(1.0);
-
-    timer.stop();
-
-    const auto& comm = leafGridView.comm();
-    std::cout << "Simulation took " << timer.elapsed() << " seconds on "
-              << comm.size() << " processes.\n"
-              << "The cumulative CPU time was " << timer.elapsed()*comm.size() << " seconds.\n";
-
-    if (leafGridView.comm().rank() == 0)
-        Parameters::print();
-
-    return 0;
-
-}// end main
diff -ruN exercises/exercise-mainfile/exercise1pcmain.cc exercises/solution/exercise-mainfile/exercise1pcmain.cc
--- exercises/exercise-mainfile/exercise1pcmain.cc	2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-mainfile/exercise1pcmain.cc	1970-01-01 01:00:00.000000000 +0100
@@ -1,158 +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 test for the one-phase CC model
- */
-#include <config.h>
-
-#include "properties.hh"
-
-#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/linearalgebratraits.hh>
-#include <dumux/linear/linearsolvertraits.hh>
-#include <dumux/nonlinear/newtonsolver.hh>
-
-#include <dumux/assembly/fvassembler.hh>
-
-#include <dumux/io/vtkoutputmodule.hh>
-#include <dumux/io/grid/gridmanager_yasp.hh>
-
-int main(int argc, char** argv)
-{
-    using namespace Dumux;
-
-    // define the type tag for this problem
-    using TypeTag = Properties::TTag::OnePCompressible;
-
-    ////////////////////////////////////////////////////////////
-    ////////////////////////////////////////////////////////////
-
-    // initialize MPI+x, finalize is done automatically on exit
-    Dumux::initialize(argc, argv);
-
-    // initialize parameter tree
-    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(gridGeometry->numDofs());
-    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
-    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 = GetPropType<TypeTag, Properties::Scalar>;
-    auto tEnd = getParam<Scalar>("TimeLoop.TEnd");
-    auto dt = getParam<Scalar>("TimeLoop.DtInitial");
-    auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
-
-    // instantiate time loop
-    auto timeLoop = std::make_shared<CheckPointTimeLoop<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 = ILUBiCGSTABIstlSolver<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);
-
-    // set some check points for the time loop
-    timeLoop->setPeriodicCheckPoint(tEnd/10.0);
-
-    // time loop
-    timeLoop->start(); do
-    {
-        // linearize & solve
-        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();
-
-        // write vtk output
-        if (timeLoop->isCheckPoint())
-            vtkWriter.write(timeLoop->time());
-
-        // report statistics of this time step
-        timeLoop->reportTimeStep();
-
-        // set new dt as suggested by the newton solver
-        timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize()));
-
-    } while (!timeLoop->finished());
-
-    timeLoop->finalize(leafGridView.comm());
-
-    if (leafGridView.comm().rank() == 0)
-        Parameters::print();
-
-    return 0;
-
-}// end main
diff -ruN exercises/exercise-mainfile/exercise_mainfile_a.input exercises/solution/exercise-mainfile/exercise_mainfile_a.input
--- exercises/exercise-mainfile/exercise_mainfile_a.input	2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-mainfile/exercise_mainfile_a.input	1970-01-01 01:00:00.000000000 +0100
@@ -1,18 +0,0 @@
-[Grid]
-LowerLeft = 0 0
-UpperRight = 1 1
-Cells = 20 20
-
-[Problem]
-Name = 1p_incompressible_stationary
-
-[SpatialParams]
-LensLowerLeft = 0.2 0.2
-LensUpperRight = 0.8 0.8
-
-Permeability = 1e-10 # [m^2]
-PermeabilityLens = 1e-12 # [m^2]
-
-[Assembly.NumericDifference]
-PriVarMagnitude = 1e5
-BaseEpsilon = 1e-10
diff -ruN exercises/exercise-mainfile/exercise_mainfile_a_solution.input exercises/solution/exercise-mainfile/exercise_mainfile_a_solution.input
--- exercises/exercise-mainfile/exercise_mainfile_a_solution.input	1970-01-01 01:00:00.000000000 +0100
+++ exercises/solution/exercise-mainfile/exercise_mainfile_a_solution.input	2023-04-26 14:37:49.797150837 +0200
@@ -0,0 +1,17 @@
+[Grid]
+LowerLeft = 0 0
+UpperRight = 1 1
+Cells = 20 20
+
+[Problem]
+Name = 1p_incompressible_stationary
+
+[SpatialParams]
+LensLowerLeft = 0.2 0.2
+LensUpperRight = 0.8 0.8
+
+Permeability = 1e-10 # [m^2]
+PermeabilityLens = 1e-12 # [m^2]
+
+[Assembly.NumericDifference]
+PriVarMagnitude = 1e5
diff -ruN exercises/exercise-mainfile/exercise_mainfile_b.input exercises/solution/exercise-mainfile/exercise_mainfile_b.input
--- exercises/exercise-mainfile/exercise_mainfile_b.input	2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-mainfile/exercise_mainfile_b.input	1970-01-01 01:00:00.000000000 +0100
@@ -1,17 +0,0 @@
-[Grid]
-LowerLeft = 0 0
-UpperRight = 1 1
-Cells = 20 20
-
-[Problem]
-Name = 1p_compressible_stationary
-
-[SpatialParams]
-LensLowerLeft = 0.2 0.2
-LensUpperRight = 0.8 0.8
-
-Permeability = 1e-10 # [m^2]
-PermeabilityLens = 1e-12 # [m^2]
-
-[Assembly.NumericDifference]
-PriVarMagnitude = 1e5
diff -ruN exercises/exercise-mainfile/exercise_mainfile_c.input exercises/solution/exercise-mainfile/exercise_mainfile_c.input
--- exercises/exercise-mainfile/exercise_mainfile_c.input	2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-mainfile/exercise_mainfile_c.input	1970-01-01 01:00:00.000000000 +0100
@@ -1,21 +0,0 @@
-[TimeLoop]
-TEnd = 0.1
-DtInitial = 0.01
-
-[Grid]
-LowerLeft = 0 0
-UpperRight = 1 1
-Cells = 20 20
-
-[Problem]
-Name = 1p_compressible_instationary
-
-[SpatialParams]
-LensLowerLeft = 0.2 0.2
-LensUpperRight = 0.8 0.8
-
-Permeability = 1e-10 # [m^2]
-PermeabilityLens = 1e-12 # [m^2]
-
-[Assembly.NumericDifference]
-PriVarMagnitude = 1e5
\ No newline at end of file
diff -ruN exercises/exercise-mainfile/properties.hh exercises/solution/exercise-mainfile/properties.hh
--- exercises/exercise-mainfile/properties.hh	2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-mainfile/properties.hh	2023-04-26 15:09:50.146538947 +0200
@@ -35,20 +35,19 @@
 #include <dumux/discretization/ccmpfa.hh>
 #include <dumux/discretization/box.hh>
 
-
 #include <dumux/porousmediumflow/1p/model.hh>
-// TODO: dumux-course-task 3
-// uncomment the incompressiblelocalresidual which is a specialization of the standard immiscible localresidual for one phase incompressible cases and provides an analytic jacobian.
-// #include <dumux/porousmediumflow/1p/incompressiblelocalresidual.hh>
+// 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 "1pspatialparams.hh"
 #include "1pproblem.hh"
 
 namespace Dumux::Properties {
 
-// Create the new type tag nodes:
+// Create the new 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
+// The incompressible uses a different fluidsystem than the compressible.
 namespace TTag {
 struct OnePBase { using InheritsFrom = std::tuple<OneP>; };
 struct OnePIncompressible { using InheritsFrom = std::tuple<OnePBase, CCTpfaModel>; };
@@ -79,10 +78,10 @@
     using type = FluidSystems::OnePLiquid<Scalar, Components::SimpleH2O<Scalar> >;
 };
 
-// TODO: dumux-course-task 3
+// 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:
-// template<class TypeTag>
-// struct LocalResidual<TypeTag, TTag::OnePIncompressible> { using type = OnePIncompressibleLocalResidual<TypeTag>; };
+template<class TypeTag>
+struct LocalResidual<TypeTag, TTag::OnePIncompressible> { using type = OnePIncompressibleLocalResidual<TypeTag>; };
 
 
 // the fluid system for compressible tests
diff -ruN exercises/exercise-mainfile/README.md exercises/solution/exercise-mainfile/README.md
--- exercises/exercise-mainfile/README.md	2023-06-01 14:31:33.153063018 +0200
+++ exercises/solution/exercise-mainfile/README.md	1970-01-01 01:00:00.000000000 +0100
@@ -1,203 +0,0 @@
-# Exercise Mainfiles (DuMuX course)
-<br>
-
-## Problem set-up
-
-This exercise will make you familiar with the program sequence in DuMu<sup>X</sup> and how different levels of complexity can be realized in the main file according to the complexity of your physical problem.
-
-In order to do so, there are three examples of one phase flow problems. Two examples (a and b) are stationary problems and the third example (c) is an instationary problem.
-
-The stationary examples differ in the `FluidSystem` they are using, which means they differ in the fluid properties (e.g. density, thermal conductivity etc). The first problem (a) uses an incompressible fluid, i.e. the density does not change when pressure changes. This makes it possible to solve the system linearly. The second problem uses a compressible fluid, that means the density is a function of pressure and we need to use a nonlinear solver.
-
-To summarize, the problems differ in:
-* exercise mainfile a: a one-phase incompressible, stationary problem
-* exercise mainfile b: a one-phase compressible, stationary problem
-* exercise mainfile c: a one-phase compressible, instationary problem
-
-The problem set-up for all three examples is always the same: It is a two dimensional problem and the domain is $1 m$ by $1 m$. It is a heterogeneous set-up with a lens in the middle of the domain which has a lower permeability ($1\cdot 10^{-12} m^2$ compared to  $1\cdot 10^{-10} m^2$ in the rest of the domain).
-
-<img src="https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/raw/master/exercises/extradoc/exercise1_1p_setup.png" width="1000">
-
-In the beginning, there is a uniform pressure of $1\cdot 10^5 Pa$ in the whole domain. On the top and the bottom border, dirichlet boundary conditions are set with a pressure of  $1\cdot 10^5 Pa$ on top and  $2 \cdot 10^5 Pa$ on the bottom. At the sides, there is no in- or outflow and there are no source terms.
-
-## Preparing the exercise
-
-* Navigate to the directory `dumux-course/exercises/exercise-mainfile`
-
-<br><br>
-### Task 1: Getting familiar with the code
-<hr>
-
-Locate all the files you will need for this exercise
-* The __main file__ for the __incompressible, stationary__ problem : `exercise1pamain.cc`
-* The __main file__ for the __compressible, stationary__ problem : `exercise1pbmain.cc`
-* The __main file__ for the __compressible, instationary__ problem : `exercise1pcmain.cc`
-* The shared __problem file__: `1pproblem.hh`
-* The shared __properties file__: `properties.hh`
-* The shared __spatial parameters file__: `1pspatialparams.hh`
-* The __input file__ for the __incompressible, stationary__ problem: `exercise_mainfile_a.input`
-* The __input file__ for the __compressible, stationary__ problem: `exercise_mainfile_b.input`
-* The __input file__ for the __compressible, instationary__ problem: `exercise_mainfile_c.input`
-
-Please pay special attention to the similarities and differences in the three main files.
-The first main file is solved linearly and does not need a newton solver or any other nonlinear solver method.
-The second problem is a nonlinear problem and uses newton's method to solve the system.
-The third problem is nonlinear and additionally instationary.
-Therefore, a time loop needs to be included in the main file.
-
-The general structure of any main file in DuMuX is:
-
-* the specific problem `TypeTag` is defined for the problem. This example shows the `TypeTag` for the `CompressibleProblem`:
-
-```c++
-// define the type tag for this problem
-using TypeTag = Properties::TTag::OnePCompressible;
-```
-The `TypeTag` is created in the `properties.hh`. There, you can see that it inherits from the __OneP__ and additionally from the __CCTpfaModel__.
-The latter defines the discretization method, which is in this case the cell-centered tpfa method.
-
-* A gridmanager tries to create the grid either from a grid file or the input file:
-
-```c++
-GridManager<GetPropType<TypeTag, Properties::Grid>> gridManager;
-gridManager.init();
-```
-* We create the finite volume grid geometry, the problem, solution vector and the grid variables and initialize them.
-Additionally, we initialize the vtk output. Each model has a predefined model specific output with relevant parameters for that model:
-
-```c++
-// 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>(fvGridGeometry);
-
-// the solution vector
-using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
-SolutionVector x(fvGridGeometry->numDofs());
-
-// the grid variables
-using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
-auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry);
-gridVariables->init(x);
-
-// initialize 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);
-```
-
-* Then, we need to assemble and solve the system. Depending on the problem, this can be done with a linear solver or a nonlinear solver.
-If the problem is time dependent, we additionally need a time loop. An example for that is given in `exercise1pcmain.cc`:
-
-```c++
-// get some time loop parameters
-using Scalar = GetPropType<TypeTag, Properties::Scalar>;
-auto tEnd = getParam<Scalar>("TimeLoop.TEnd");
-auto dt = getParam<Scalar>("TimeLoop.DtInitial");
-auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
-
-// instantiate time loop
-auto timeLoop = std::make_shared<CheckPointTimeLoop<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, fvGridGeometry, gridVariables, timeLoop);
-
-// the linear solver
-using LinearSolver = ILUBiCGSTABIstlSolver<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);
-
-// set some check points for the time loop
-timeLoop->setPeriodicCheckPoint(tEnd/10.0);
-
-// time loop
-timeLoop->start(); do
-{
-    // linearize & solve
-    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();
-
-    // write vtk output
-    if (timeLoop->isCheckPoint())
-        vtkWriter.write(timeLoop->time());
-
-    // report statistics of this time step
-    timeLoop->reportTimeStep();
-
-    // set new dt as suggested by the newton solver
-    timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize()));
-
-} while (!timeLoop->finished());
-
-timeLoop->finalize(leafGridView.comm());
-```
-
-<br><br><br>
-### Task 2: Compiling and running an executable
-<hr>
-
-* Change to the build-directory
-
-```bash
-cd ../../build-cmake/exercises/exercise-mainfile
-```
-
-* Compile all three executables `exercise_mainfile_a` and `exercise_mainfile_b` and `exercise_mainfile_c`
-
-```bash
-make exercise_mainfile_a exercise_mainfile_b exercise_mainfile_c
-```
-
-* Execute the three problems and inspect the result
-
-```bash
-./exercise_mainfile_a
-./exercise_mainfile_b
-./exercise_mainfile_c
-```
-
-* You can look at the results (e.g. for the first example) with paraview:
-
-```bash
-paraview 1p_incompressible_stationary.pvd
-```
-
-<br><br><br>
-### Task 3: Analytical differentiation
-<hr>
-
-In the input file `exercise_mainfile_a.input`, you will see that there is a variable `BaseEpsilon`.
-This defines the base value for the epsilon used in the numeric differentiation.
-If that value is too small, you will see that the solution of the numeric differentiation is not correct.
-Change that value to $1 \cdot 10^{-15}$ and have a look at the solution.
-
-For the incompressible one phase problem, it is also possible to have an analytic solution method.
-In this case, the epsilon does not play a role anymore, since the derivatives are calculated analytically.
-To implement that, follow the tips in the `exercise1pamain.cc` and the `properties.hh` marked by:
-
-```c++
-// TODO: dumux-course-task 3
-```
-For the analytic solution of your immiscible problem, you need analytic solutions for the derivatives of the jacobian.
-For that, we have a special local residual, the `OnePIncompressibleLocalResidual` which provides that.
-You just need to include `incompressiblelocalresidual.hh` in your `properties.hh`
-and use that instead of the `immisciblelocalresidual.hh` which is used as a default for all immiscible models.
-
-Additionally, you need to set the differentiation method in the main file `exercise1pamain.cc` to analytic.