### Merge branch 'water-content-as-initial-condition' into...

Merge branch 'water-content-as-initial-condition' into 127-add-data-assimilation-interface-to-richardssimulation
parents a81e1c9c 4cccaabc
 ... ... @@ -31,16 +31,16 @@ They are controlled by the initial.type key and available for every model. * type = analytic An analytic function :math:f(\vec{p}) which depends on the physical position :math:\vec{p}. The function must be defined via the key An analytic function :math:f(\mathbf{p}) which depends on the physical position :math:\mathbf{p}. The function must be defined via the key initial.equation. For parsing the input expression, we use muparser_ which supports a set of common mathematical functions. Additionally, the following variables can be used: Available variables: * x: X-coordinate :math:p_1 \, [\mathrm{m}]. * y: Y-coordinate :math:p_2 \, [\mathrm{m}]. * z: Z-coordinate :math:p_3 \, [\mathrm{m}] (only in 3D). * x: X-coordinate :math:p_1 \, [\text{m}]. * y: Y-coordinate :math:p_2 \, [\text{m}]. * z: Z-coordinate :math:p_3 \, [\text{m}] (only in 3D). * h: Height above origin. Synonymous to y in 2D and z in 3D. * pi: Mathematical constant :math:\pi. * dim: Number of physical dimensions. ... ... @@ -50,8 +50,9 @@ They are controlled by the initial.type key and available for every model. :ref:initial-transformation), typical initial conditions for a Richards simulation are * Hydrostatic equilibrium: A vertical gradient of :math:-1 and a fixed value  at height :math:h = 0 \, \mathrm{m}:: * Hydrostatic equilibrium: A vertical gradient of :math:\partial_h h_m = -1 and a fixed value  at height :math:h = 0 \, \text{m}: initial.equation = -h + ... ... @@ -59,7 +60,7 @@ They are controlled by the initial.type key and available for every model. .. tip:: The expression for a gaussian pulse of solute concentration centered at :math:\vec{p} = [0.5, 0.5]^T \, \mathrm{m} is:: :math:\mathbf{p} = [0.5, 0.5]^T \, \text{m} is:: initial.equation = exp(-sqrt((x-0.5)^2+(y-0.5)^2)/(4.*0.002))/(4*pi*0.002)^(2/dim). ... ... @@ -97,7 +98,22 @@ Initial condition tranformations for the Richards solver. * quantity = matricHead The input data is directly interpreted as matric head :math:f = h_m [\mathrm{m}]. :math:f = h_m \, [\text{m}]. .. object:: Water Content to Matric Head * quantity = waterContent The input data is interpreted as water content, :math:f = \theta_w \, [\text{-}], and transformed into matric head via the :doc:parameterization  of the medium. Values greater than the porosity :math:\phi and less than the residual water content :math:\theta_r are automatically clamped to fit the allowed range. Additionally, any input value :math:f(x_0) at some position :math:x_0 on the grid will result in a saturation greater zero, :math:\Theta (x_0) > 0, to avoid divergence of the matric head towards negative infinity. Transport ^^^^^^^^^ ... ... @@ -108,7 +124,7 @@ Initial condition tranformations for the Transport solver. * quantity = soluteConcentration The input data is directly interpreted as solute concentration, :math:f = c_w [\mathrm{kg}/\mathrm{m}^3]. :math:f = c_w [\text{kg}/\text{m}^3]. .. _H5: https://www.h5py.org/ .. _muparser: http://beltoforion.de/article.php?a=muparser&p=features
 ... ... @@ -34,7 +34,7 @@ protected: std::shared_ptr log=get_logger(log_base) ) { std::unique_ptr> ic; std::shared_ptr> ic; auto ic_type = ini_file.get("initial.type"); log->debug("Creating initial condition of type: {}", ic_type); ... ... @@ -56,7 +56,7 @@ protected: const auto file_type = ic_datafile.substr(ext_start + 1); if (file_type == "h5") { using ICH5 = InitialConditionH5; ic = std::make_unique(grid_view, ini_file, log); ic = std::make_shared(grid_view, ini_file, log); } else if (file_type == "vtu") { DUNE_THROW(NotImplemented, ... ... @@ -73,7 +73,7 @@ protected: auto equation_str = ini_file.get("initial.equation"); using ICAnalytic = InitialConditionAnalytic; ic = std::make_unique(log,grid_view,equation_str); ic = std::make_shared(log,grid_view,equation_str); } else { log->error("Unsupported initial condition type: {}", ic_type); ... ...
 include ${CMAKE_BINARY_DIR}/doc/default_files/config.ini _initial_type = analytic, data | expand _quantity = matricHead, waterContent | expand quantity_type {_quantity} == waterContent and {_initial_type} == analytic | exclude __name = ic-richards-{_initial_type}-{_quantity} _asset_path = "${PROJECT_SOURCE_DIR}/test" [grid] dimensions = 2 initialLevel = 1 gridType = rectangular cells = 50 50 extensions = 1 1 [grid.mapping] file = none [richards.initial] type = {_initial_type} quantity = {_quantity} file = ${CMAKE_CURRENT_LIST_DIR}/scaling.h5 dataset = twos interpolation = nearest equation = -1+2*y [richards.parameters] file = test-parameterization-unscaled.yml  ... ... @@ -2,53 +2,12 @@ #include "config.h" #endif #include #include #include #include #include #include #include #include /// Traits stub used for this test template struct Traits { static constexpr int dim = d; using Grid = Dune::YaspGrid; using GridView = typename Grid::LeafGridView; using GV = GridView; using DF = typename Grid::ctype; using Domain = Dune::FieldVector; using RF = double; using Scalar = Dune::FieldVector; }; /// Test an initial condition against a lambda function on the grid template void test_ic_against_function ( const std::shared_ptr grid, const std::unique_ptr& ic, const Function func ) { using Range = typename IC::Traits::RangeType; using namespace Dune::FloatCmp; // iterate over the grid vertices for (auto&& e : Dune::elements(grid->leafGridView())) { Range y; const auto x = e.geometry().local(e.geometry().center()); ic->evaluate(e, x, y); assert(eq(func(e, x), y)); } } #include "test-initial-condition.hh" /// Test the basic initial conditions (without transformation) /** \tparam T Traits ... ... @@ -97,53 +56,26 @@ int main (int argc, char** argv) auto grid = gc.grid(); const auto index_map = gc.element_index_map(); { auto config = Dune::Dorie::Setup::prep_ini_for_richards(inifile); auto config = Dune::Dorie::Setup::prep_ini_for_transport(inifile); // initial condition factory using T = Traits<2>; using ICF = Dune::Dorie::RichardsInitialConditionFactory; // initial condition factory using T = Traits<2>; using ICF = Dune::Dorie::TransportInitialConditionFactory; // create the Richards logger const auto log_level = config.get("output.logLevel"); auto _log = Dune::Dorie::create_logger(Dune::Dorie::log_richards, helper,spdlog::level::from_str(log_level)); // create the transport logger const auto log_level = config.get("output.logLevel"); // FIXME auto _log = Dune::Dorie::create_logger(Dune::Dorie::log_transport, helper/*,spdlog::level::from_str(log_level)*/); const auto quantity = config.get("initial.quantity"); if (quantity == "matricHead") { test_ic_base(grid, config); } else { log->error("Unsupported quantity for initial condition test: {}", quantity); DUNE_THROW(Dune::NotImplemented, "Unsupported initial condition " "quantity"); } const auto quantity = config.get("initial.quantity"); if (quantity == "soluteConcentration") { test_ic_base(grid, config); } { // auto config = Dune::Dorie::Setup::prep_ini_for_transport(inifile); // FIXME auto config = inifile.sub("transport"); // initial condition factory using T = Traits<2>; using ICF = Dune::Dorie::TransportInitialConditionFactory; // create the transport logger // const auto log_level = config.get("output.logLevel"); // FIXME auto _log = Dune::Dorie::create_logger(Dune::Dorie::log_transport, helper/*,spdlog::level::from_str(log_level)*/); const auto quantity = config.get("initial.quantity"); if (quantity == "soluteConcentration") { test_ic_base(grid, config); } else { log->error("Unsupported quantity for initial condition test: {}", quantity); DUNE_THROW(Dune::NotImplemented, "Unsupported initial condition " "quantity"); } else { log->error("Unsupported quantity for initial condition test: {}", quantity); DUNE_THROW(Dune::NotImplemented, "Unsupported initial condition " "quantity"); } return 0; ... ...  include${CMAKE_BINARY_DIR}/doc/default_files/config.ini _initial_type = analytic, data | expand __name = {_initial_type} __name = ic-transport-{_initial_type} _asset_path = "${PROJECT_SOURCE_DIR}/test" [grid] ... ... @@ -14,16 +14,6 @@ extensions = 1 1 [grid.mapping] file = none [richards.initial] type = {_initial_type} quantity = matricHead file =${CMAKE_CURRENT_LIST_DIR}/scaling.h5 dataset = twos interpolation = nearest equation = -1+2*y [transport.initial] type = {_initial_type} quantity = soluteConcentration ... ...