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

Merge branch 'feature/example-tracer-cleanup' into 'master'

Feature/example tracer cleanup

See merge request !2513
parents 1f2f20b7 884677ab
......@@ -3,7 +3,6 @@ dune_symlink_to_source_files(FILES "params.input")
dumux_add_test(NAME example_1ptracer
LABELS porousmediumflow tracer example
SOURCES main.cc
CMAKE_GUARD HAVE_UMFPACK
COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
CMD_ARGS --script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/test_1ptracer_transport-reference.vtu
......
......@@ -314,9 +314,15 @@ over the computational grid
In this example, we use a randomly generated and element-wise distributed
permeability field. For this, we use the random number generation facilities
provided by the C++ standard library.
Dumux additionally implements some simpler but
standard-library-implementation-independent random distributions
that are accurate enough for our purposes
but allow to generate reproducible and portable random fields (when using a constant seed)
for testing purposes.
```cpp
#include <random>
#include <dumux/common/random.hh>
```
We include the spatial parameters class for single-phase models discretized
......@@ -380,15 +386,19 @@ of 10% here and compute permeabily values for all elements of the computational
// Furthermore, the position of the lens, which is defined by the position of the lower left and the upper right corners, are obtained from the input file.
lensLowerLeft_ = getParam<GlobalPosition>("SpatialParams.LensLowerLeft");
lensUpperRight_ =getParam<GlobalPosition>("SpatialParams.LensUpperRight");
lensUpperRight_ = getParam<GlobalPosition>("SpatialParams.LensUpperRight");
// We generate random fields for the permeability using lognormal distributions,
// with `permeability_` as mean value and 10 % of it as standard deviation.
// A separate distribution is used for the lens using `permeabilityLens_`.
// A permeability value is created for each element of the grid and is stored in the vector `K_`.
// For a "truly" random field (different every time we execute) the seed `0` for the
// Mersenne-Twister pseudo-random-number generator should be replaced
// by `std::random_device{}()`. For unbiased high-quality distributions (usually not needed)
// replace `Dumux::SimpleLogNormalDistribution` by `std::lognormal_distribution`.
std::mt19937 rand(0);
std::lognormal_distribution<Scalar> K(std::log(permeability_), std::log(permeability_)*0.1);
std::lognormal_distribution<Scalar> KLens(std::log(permeabilityLens_), std::log(permeabilityLens_)*0.1);
Dumux::SimpleLogNormalDistribution<Scalar> K(std::log(permeability_), std::log(permeability_)*0.1);
Dumux::SimpleLogNormalDistribution<Scalar> KLens(std::log(permeabilityLens_), std::log(permeabilityLens_)*0.1);
// loop over all elements and compute a permeability value
for (const auto& element : elements(gridGeometry->gridView()))
......
......@@ -31,8 +31,6 @@ These are DUNE helper classes related to parallel computations, time measurement
```cpp
#include <dune/common/parallel/mpihelper.hh>
#include <dune/common/timer.hh>
#include <dune/grid/io/file/dgfparser/dgfexception.hh>
#include <dune/grid/io/file/vtk.hh>
```
The following headers include functionality related to property definition or retrieval, as well as
......@@ -161,7 +159,8 @@ The grid variables are used store variables (primary and secondary variables) on
```
We now instantiate the assembler class, assemble the linear system and solve it with the linear
solver UMFPack. Besides that, the time needed for assembly and solve is measured and printed.
solver ILUnBiCGSTABBackend (a bi-conjugate gradient solver preconditioned by an incomplete LU-factorization preconditioner).
Besides that, the time needed for assembly and solve is measured and printed.
```cpp
using OnePAssembler = FVAssembler<OnePTypeTag, DiffMethod::analytic>;
......@@ -175,7 +174,7 @@ solver UMFPack. Besides that, the time needed for assembly and solve is measured
(*r) *= -1.0; // We want to solve `Ax = -r`.
using LinearSolver = UMFPackBackend;
using LinearSolver = ILUnBiCGSTABBackend;
Dune::Timer solverTimer; std::cout << "Solving linear system ..." << std::flush;
auto linearSolver = std::make_shared<LinearSolver>();
linearSolver->solve(*A, p, *r);
......
......@@ -31,8 +31,6 @@
// These are DUNE helper classes related to parallel computations, time measurements and file I/O
#include <dune/common/parallel/mpihelper.hh>
#include <dune/common/timer.hh>
#include <dune/grid/io/file/dgfparser/dgfexception.hh>
#include <dune/grid/io/file/vtk.hh>
// The following headers include functionality related to property definition or retrieval, as well as
// the retrieval of input parameters specified in the input file or via the command line.
......@@ -127,7 +125,8 @@ int main(int argc, char** argv) try
onePGridVariables->init(p);
// We now instantiate the assembler class, assemble the linear system and solve it with the linear
// solver UMFPack. Besides that, the time needed for assembly and solve is measured and printed.
// solver ILUnBiCGSTABBackend (a bi-conjugate gradient solver preconditioned by an incomplete LU-factorization preconditioner).
// Besides that, the time needed for assembly and solve is measured and printed.
using OnePAssembler = FVAssembler<OnePTypeTag, DiffMethod::analytic>;
auto assemblerOneP = std::make_shared<OnePAssembler>(problemOneP, gridGeometry, onePGridVariables);
assemblerOneP->setLinearSystem(A, r); // tell assembler to use our previously defined system
......@@ -139,7 +138,7 @@ int main(int argc, char** argv) try
(*r) *= -1.0; // We want to solve `Ax = -r`.
using LinearSolver = UMFPackBackend;
using LinearSolver = ILUnBiCGSTABBackend;
Dune::Timer solverTimer; std::cout << "Solving linear system ..." << std::flush;
auto linearSolver = std::make_shared<LinearSolver>();
linearSolver->solve(*A, p, *r);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment