Commit 911c397d authored by Santiago Ospina's avatar Santiago Ospina

Merge branch '62-gradientfluxadapter-problem' into...

Merge branch '62-gradientfluxadapter-problem' into 101-couple-the-transportsimulation-with-richardssimulation
parents 0cbae4f0 d803ff0d
......@@ -13,7 +13,7 @@
that models the concept of simulation steps so that they
can be later coupled with other simulations.
* Added an abstract base class
[`SimulationBase`](dune/dorie/interface/base_simulation.hh)
[`SimulationBase`](dune/dorie/common/simulation_base.hh)
that models the concept of simulation steps so that they
can be later coupled with other simulations.
* New classes representing parameterizations. Every parameterization must now
......@@ -32,7 +32,7 @@
### Changed
* `Simulation` is renamed `RichardsSimulation` and moved to
[richards_simulation.hh](dune/dorie/interface/richards_simulation.hh).
[richards.hh](dune/dorie/model/richards/richards.hh).
* `RichardsSimulation` now has its own `RichardsSimulationTraits` derived from
`BaseTraits`, which defines all its member types. `BaseTraits` now have
reduced content and are intended to be shared between models/simulations.
......@@ -59,7 +59,8 @@
solution vector.
* `GradientFluxAdapter` was reimplemented and renamed `WaterFluxAdapter`.
* Every grid function adapter has its own file and are gathered in the
subdirectory [dune/dorie/solver/adapters](dune/dorie/solver/adapters).
subdirectory
[dune/dorie/model/richards/adapters](dune/dorie/model/richards/adapters).
* `VTKAdapters` are now managed with `shared_ptr` instead of references.
* `OutputWriter` class is deprecated in favor of an minimal extension of the
usual `VTKSequenceWriter` for grid functions called
......@@ -102,15 +103,39 @@
* Improved and refurbished `Dorie::H5File`.
The source file was renamed to `dune/dorie/solver/util_h5file.hh`. The
The source file was renamed to `dune/dorie/common/util_h5file.hh`. The
`read_dataset` function is now capable of directly opening dataset paths
that contain groups.
* The following changes were done in order to have a consistent API to support
different models:
* Folder structure has changed to a model based structure: in the main
[C++ source directory](dune/dorie/) there now is a `common` folder, and
a folder for `model` containing the source files for each model.
* The API has been updated to support several models: from now, categories
that target a specific model has to be preceded by a keyword
identifying the corresponding model (e.g. `richards.initial`,
`richards.output`, etc.), while common categories stay with no prefix
at all (e.g. `grid`, `adaptivity`, etc.).
* The parameter scraper now accepts the argument `--model <model>` which
adds the prefix `<model>.` to every category in the scraper. This helps
to be able to use the method `sub()` from the `ParameterTree` object.
It dumps its data into a YAML file which is then loaded for writing
the default configuration files and the cheat sheet.
### Deprecated
* The configuration file key `[parameters.interpolation]` is deprecated due to
the new scheme for storing parameterization data. DORiE now only supports
nearest-neighbor interpolation of parameters and scaling factors.
* The `adaptivity.useAdaptity` keyword is deprecated, please use the new keyword
`adaptivity.policy` (see the
[DORiE Configuration File Guide documentation](https://dorie-doc.netlify.com/quickstart-parameters.html#main-routine)
for details).
### Removed
* The class `H5File::AttributeReader` was completely removed.
......
......@@ -138,6 +138,8 @@ If you installed [Anaconda](https://conda.io/docs/user-guide/install/download.ht
to build all DUNE modules. Additionally, you can add `MAKE_FLAGS="-j X"` before the call to `dunecontrol` to compile on `X` processes in parallel.
**Warning:** Users of **macOS** with Apple Clang version >=10 need to append `-DDUNE_HAVE_CXX_OPTIONAL=Off` to the `CMAKE_FLAGS`.
If you installed software into paths not appended to your `PATH` variable, you will have to add `CMAKE_FLAGS` to the call to make sure that CMake finds all packages. Alternatively, you can add a custom options file. See the [DUNE Installation Instructions](https://dune-project.org/doc/installation/) for details. CMake will throw an error if required packages are not found.
**Warning:** Anacoda supplies its own version of HDF5 which is typically found first by CMake. If you have Anaconda installed on your machine, add
......
function(scrape_parameters SOURCE_DIR XML_FILE CSS OUTPUT RESULT_NAME)
#
# .. cmake_function:: scrape_parameters
#
# The working directory of the function call is the CURRENT_BINARY_DIR.
#
# .. cmake_param:: SOURCE_DIR
# :single:
# :required:
#
# The source directory to parse. The scraper will perform a recursive
# walk through its subdirectories
#
# .. cmake_param:: XML_FILE
# :single:
# :required:
#
# The XML file containing the definitions of parameters to parse for.
#
# .. cmake_param:: OUTPUT
# :single:
# :required:
#
# The output YAML file to dump the data into.
#
# .. cmake_param:: MODEL
# :single:
# :optional:
#
# The name of the associated model category. Required for correct parsing
# of config queries inside models.
#
# .. cmake_param:: OVERWRITE
# :option:
#
# Option to overwrite the YAML file if it exists.
#
function(scrape_parameters)
message(STATUS "Running parameter scraper on sources ${SOURCE_DIR}")
if(DEPLOY_SPHINX_SOURCE_URL)
execute_process(COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env scrape_folder.py --source ${SOURCE_DIR}
--xml ${XML_FILE} --out ${OUTPUT} --css ${CSS}
--source_url ${DEPLOY_SPHINX_SOURCE_URL}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
RESULT_VARIABLE RETURN_CODE)
else()
execute_process(COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env scrape_folder.py --source ${SOURCE_DIR}
--xml ${XML_FILE} --out ${OUTPUT} --css ${CSS}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
RESULT_VARIABLE RETURN_CODE)
set(OPTIONS OVERWRITE)
set(SINGLE SOURCE_DIR XML_FILE OUTPUT MODEL)
cmake_parse_arguments(SCRAPE_PARAMETERS
"${OPTIONS}" "${SINGLE}" "" ${ARGN})
# set options list
set(scrape_options
--source ${SCRAPE_PARAMETERS_SOURCE_DIR}
--xml ${SCRAPE_PARAMETERS_XML_FILE}
--out ${SCRAPE_PARAMETERS_OUTPUT}
)
# evaluate options
if(SCRAPE_PARAMETERS_MODEL)
list(APPEND scrape_options --model ${SCRAPE_PARAMETERS_MODEL})
endif()
if(SCRAPE_PARAMETERS_OVERWRITE)
list(APPEND scrape_options --overwrite)
endif()
set(${RESULT_NAME} ${RETURN_CODE} PARENT_SCOPE)
endfunction()
file(COPY ${CMAKE_CURRENT_LIST_DIR} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/..)
execute_process(COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env
scrape_folder.py ${scrape_options}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
RESULT_VARIABLE RETURN_CODE)
scrape_parameters(${PROJECT_SOURCE_DIR}/dune/dorie-rfg ${CMAKE_CURRENT_SOURCE_DIR}/field-parameters.xml ${CMAKE_CURRENT_SOURCE_DIR}/parameters.css "parfield.ini;field-parameters.html;field-parameters.rst" FIELDPARSCRAPE_RETURN)
if (NOT ${FIELDPARSCRAPE_RETURN} EQUAL 0)
if (NOT ${RETURN_CODE} EQUAL 0)
message(FATAL_ERROR "Parameter scraper failed. DORiE can not be built.")
endif()
endif()
endfunction()
scrape_parameters(${PROJECT_SOURCE_DIR}/dune/dorie ${CMAKE_CURRENT_SOURCE_DIR}/parameters.xml ${CMAKE_CURRENT_SOURCE_DIR}/parameters.css "config.ini;parameters.html;parameters.rst" PARSCRAPE_RETURN)
if (NOT ${PARSCRAPE_RETURN} EQUAL 0)
message(FATAL_ERROR "Parameter scraper failed. DORiE can not be built.")
endif()
#
# .. cmake_function:: create_default_config
#
# The working directory of the function call is the CURRENT_BINARY_DIR.
#
# .. cmake_param:: INPUT
# :single:
# :required:
#
# The YAML file from which to read the scraper data.
#
# .. cmake_param:: OUTPUT
# :multi:
# :required:
#
# The output files to write.
#
# .. cmake_param:: SOURCE_DIR
# :single:
# :required:
#
# The source directory of files to parse. Required for correct links from
# docs to files.
#
# .. cmake_param:: CSS
# :single:
# :optional:
#
# The CSS style file to use for the HTML output.
#
function(create_default_config INPUT OUTPUT SOURCE_DIR CSS)
message(STATUS "Creating default config ${OUTPUT}.")
set(options
${INPUT}
${OUTPUT}
--source ${SOURCE_DIR}
--css ${CSS})
scrape_parameters(${PROJECT_SOURCE_DIR}/dune/dorie ${CMAKE_CURRENT_SOURCE_DIR}/parameters-transport.xml ${CMAKE_CURRENT_SOURCE_DIR}/parameters.css "transport-config.ini;transport-parameters.html;transport-parameters.rst" PARSCRAPE_RETURN)
if (NOT ${PARSCRAPE_RETURN} EQUAL 0)
message(FATAL_ERROR "Parameter scraper failed. DORiE can not be built.")
endif()
\ No newline at end of file
execute_process(COMMAND ${CMAKE_BINARY_DIR}/run-in-dune-env
write_config.py ${options}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
RESULT_VARIABLE RETURN_CODE)
if (NOT ${RETURN_CODE} EQUAL 0)
message(FATAL_ERROR "Creating the default config file failed.")
endif()
endfunction()
# copy BC files
file(COPY 2d_infiltr.bcdat DESTINATION .)
file(COPY 3d_infiltr.bcdat DESTINATION .)
# Random field generator
scrape_parameters(
SOURCE_DIR ${PROJECT_SOURCE_DIR}/dune/dorie-rfg
XML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/field-parameters.xml
OUTPUT rfg.yml
OVERWRITE
)
create_default_config(
${CMAKE_CURRENT_BINARY_DIR}/rfg.yml
"parfield.ini;field-parameters.html;field-parameters.rst"
${PROJECT_SOURCE_DIR}/dune/dorie-rfg
${CMAKE_CURRENT_SOURCE_DIR}/parameters.css
)
# Dorie common
scrape_parameters(
SOURCE_DIR ${PROJECT_SOURCE_DIR}/dune/dorie
XML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/common-parameters.xml
OUTPUT config.yml
OVERWRITE
)
# Model: Richards
scrape_parameters(
SOURCE_DIR ${PROJECT_SOURCE_DIR}/dune/dorie/model/richards
XML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/richards-parameters.xml
OUTPUT config.yml
MODEL "richards"
)
# Model: Transport
scrape_parameters(
SOURCE_DIR ${PROJECT_SOURCE_DIR}/dune/dorie/model/richards
XML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/transport-parameters.xml
OUTPUT config.yml
MODEL "transport"
)
# Final Dorie config
create_default_config(
${CMAKE_CURRENT_BINARY_DIR}/config.yml
"config.ini;parameters.html;parameters.rst"
${PROJECT_SOURCE_DIR}/dune/dorie
${CMAKE_CURRENT_SOURCE_DIR}/parameters.css
)
<?xml version="1.0" encoding="UTF-8"?>
<!--
If you want to use any special characters, you will need to define them here.
A full list is found at https://www.w3.org/TR/REC-html40/sgml/entities.html
-->
<!DOCTYPE naughtyxml [
<!ENTITY alpha "&#945;">
<!ENTITY beta "&#946;">
<!ENTITY eta "&#951;">
<!ENTITY tau "&#964;">
<!ENTITY times "&#215;">
]>
<!--
XML file hierarchy:
<dorie> -> <category> -> <parameter> -> (parameter attributes)
Possible parameter attributes:
definition: meaning of the parameter, will only show up in html output
suggestion: standard value in created parameter files
values: possible values, will only show up in html output
comment: extra comment, will only show up in parameter files
All attributes are optional.
The parser supports rudimentary markdown / styling. You can add a paragraph by
adding an empty line, make text **bold** or ``monospaced``.
-->
<dorie>
<category name="grid">
<parameter name="gridType">
<definition> Grid geometry. The grid can either be structured rectangular / cubic
(``rectangular``) or unstructured triangular / tetrahedral (``gmsh``). The former does not
require any additional input, while in the latter case a gmsh file with
the corresponding grid is to be given. </definition>
<suggestion> rectangular </suggestion>
<values> rectangular, gmsh </values>
<comment> Choose grid type: rectangular, gmsh </comment>
</parameter>
<parameter name="dimensions">
<definition> Dimensionality of the domain. </definition>
<suggestion> 2 </suggestion>
<values> 2, 3 </values>
</parameter>
<parameter name="gridFile">
<definition> Path to the gmsh file containing the grid if ``gridType`` is set
to ``gmsh``. </definition>
<values> path </values>
</parameter>
<parameter name="extensions">
<definition> Physical extensions of the domain in meters. Given in x, then y,
then z-direction. If a mesh file is imported, they have to match its maximum
extensions. </definition>
<values> float &times; float (&times; float) </values>
<suggestion> 1 1 </suggestion>
</parameter>
<parameter name="cells">
<definition> Initial number of cells in each dimension (x, then y, then z) if ``gridType``
is set to ``rectangular``. This represents the coarsest level of the grid
(i.e., refinement level 0). </definition>
<values> int &times; int (&times; int) </values>
<suggestion> 100 100 </suggestion>
</parameter>
<parameter name="initialLevel">
<definition> Initial level of refinement of the grid. 0 means no refinement.
</definition>
<values> int </values>
<suggestion> 0 </suggestion>
</parameter>
<parameter name="mappingFile">
<definition> The H5 file containing the mapping from cell to medium index.
Specify the dataset inside the file with the next key. Leave empty or
set to ``None`` for a global homogeneous medium. In this case,
``grid.globalIndex`` has to be specified.
</definition>
<values> path </values>
</parameter>
<parameter name="mappingFileDataset">
<definition> The H5 dataset inside ``grid.mappingFile`` containing the
mapping from cell to medium index.
</definition>
<values> path </values>
</parameter>
<parameter name="globalIndex">
<definition> The medium index to use for all grid cells, if
``mappingFile`` is unset or ``None``.
</definition>
<values> int </values>
</parameter>
</category>
<category name="adaptivity">
<parameter name="policy">
<definition> Switches the target policy to do adaptive grid refinement
(h-adaptivity). If enabled, an unstructured grid manager with higher
computational cost is used when using rectangular / cubic grids.
</definition>
<values> none, waterFlux </values>
<suggestion> none </suggestion>
<comment> none, waterFlux </comment>
</parameter>
<parameter name="maxLevel">
<definition> The maximum refinement level kept in the grid. This is a useful
tool to prevent over-refinement. If this value is high, the grid can
be refined to an arbitrary degree, leading to an evenly distributed error
across the grid. Make sure you avoid refinement levels which imply grid cell sizes
beyond the Richards continuum scale. </definition>
<values> int </values>
<suggestion> 10 </suggestion>
</parameter>
<parameter name="minLevel">
<definition> Minimum refinement level of the grid. Grid cells will not get
coarsened below this level. </definition>
<values> int </values>
<suggestion> 0 </suggestion>
</parameter>
<parameter name="markingStrategy">
<definition> Marking strategy used in order to find the grid cells that should
be refined / coarsened.
**elementFraction**: Of the N elements in the sorted list of local errors, the first
&alpha;N elements are refined while the last &beta;N elements are being coarsened.
**errorFraction**: Refine (coarse) as many elements as necessary, such that the
total relative contribution of all refined (coarsened) cells to the
global error is &alpha; (&beta;), starting with the most (least) contributing
element. The total number of affected entities can vary greatly
between different iterations, and (with &alpha; = &beta;) much more elements
are coarsened than refined.
**threshold**: All elements with a local error &eta; &gt; &alpha; are being refined once.
Coarsening occurs for all elements that carry an error smaller
than &beta;.
</definition>
<values> elementFraction, errorFraction, threshold </values>
<suggestion> elementFraction </suggestion>
<comment> elementFraction, errorFraction, threshold </comment>
</parameter>
<parameter name="refinementFraction">
<definition> The value of &alpha; for the chosen ``markingStrategy``. </definition>
<values> float </values>
<suggestion> 0.1 </suggestion>
</parameter>
<parameter name="coarseningFraction">
<definition> The value of &beta; for the chosen ``markingStrategy``. </definition>
<values> float </values>
<suggestion> 0.2 </suggestion>
</parameter>
<parameter name="threshold">
<definition> Grid refinement is skipped entirely for the given time step if
all grid elements carry an error lower than this value. This is to only
make the grid as fine as necessary. </definition>
<values> float </values>
<suggestion> 1E-8 </suggestion>
</parameter>
</category>
<category name="output">
<parameter name="verbose">
<definition> Overall verbosity of the program </definition>
<suggestion> 0 </suggestion>
<values> 0, 1, 2, 3 </values>
</parameter>
</category>
<category name="misc">
<parameter name="debugMode">
<definition> Switches debug mode on (``true``) or off (``false``). In debug mode,
the execution of DORiE stops immediately until a developer hooks into the
process with a debugger and sets the variable ``i`` to a value &gt; 0. Only
intended for use by developers.
</definition>
<values> true, false </values>
<suggestion> false </suggestion>
</parameter>
</category>
</dorie>
......@@ -47,7 +47,7 @@ adding an empty line, make text **bold** or ``monospaced``.
<category name="output">
<parameter name="verbose">
<definition> Overall verbosity of the program </definition>
<definition> Verbosity of the Richards simulation </definition>
<suggestion> 0 </suggestion>
<values> 0, 1, 2, 3 </values>
</parameter>
......@@ -97,83 +97,6 @@ adding an empty line, make text **bold** or ``monospaced``.
</parameter>
</category>
<category name="grid">
<parameter name="gridType">
<definition> Grid geometry. The grid can either be structured rectangular / cubic
(``rectangular``) or unstructured triangular / tetrahedral (``gmsh``). The former does not
require any additional input, while in the latter case a gmsh file with
the corresponding grid is to be given. </definition>
<suggestion> rectangular </suggestion>
<values> rectangular, gmsh </values>
<comment> Choose grid type: rectangular, gmsh </comment>
</parameter>
<parameter name="dimensions">
<definition> Dimensionality of the domain. </definition>
<suggestion> 2 </suggestion>
<values> 2, 3 </values>
</parameter>
<parameter name="FEorder">
<definition> Order of the finite element method used. Values &gt; 1 are not
thoroughly tested. </definition>
<suggestion> 1 </suggestion>
<values> 1, 2, 3 </values>
</parameter>
<parameter name="gridFile">
<definition> Path to the gmsh file containing the grid if ``gridType`` is set
to ``gmsh``. </definition>
<values> path </values>
</parameter>
<parameter name="extensions">
<definition> Physical extensions of the domain in meters. Given in x, then y,
then z-direction. If a mesh file is imported, they have to match its maximum
extensions. </definition>
<values> float &times; float (&times; float) </values>
<suggestion> 1 1 </suggestion>
</parameter>
<parameter name="cells">
<definition> Initial number of cells in each dimension (x, then y, then z) if ``gridType``
is set to ``rectangular``. This represents the coarsest level of the grid
(i.e., refinement level 0). </definition>
<values> int &times; int (&times; int) </values>
<suggestion> 100 100 </suggestion>
</parameter>
<parameter name="initialLevel">
<definition> Initial level of refinement of the grid. 0 means no refinement.
</definition>
<values> int </values>
<suggestion> 0 </suggestion>
</parameter>
<parameter name="mappingFile">
<definition> The H5 file containing the mapping from cell to medium index.
Specify the dataset inside the file with the next key. Leave empty or
set to ``None`` for a global homogeneous medium. In this case,
``grid.globalIndex`` has to be specified.
</definition>
<values> path </values>
</parameter>
<parameter name="mappingFileDataset">
<definition> The H5 dataset inside ``grid.mappingFile`` containing the
mapping from cell to medium index.
</definition>
<values> path </values>
</parameter>
<parameter name="globalIndex">
<definition> The medium index to use for all grid cells, if
``mappingFile`` is unset or ``None``.
</definition>
<values> int </values>
</parameter>
</category>
<category name="boundary">
<parameter name="file">
<definition> Path to the boundary condition file. </definition>
......@@ -292,13 +215,20 @@ adding an empty line, make text **bold** or ``monospaced``.
</parameter>
</category>
<category name="dg">
<category name="numerics">
<parameter name="penaltyFactor">
<definition> Penalty factor to be used in the Discontinuous Galerkin scheme
</definition>
<values> float </values>
<suggestion> 10 </suggestion>
</parameter>
<parameter name="FEorder">
<definition> Order of the finite element method used. Values &gt; 1 are not
thoroughly tested. </definition>
<suggestion> 1 </suggestion>
<values> 1, 2, 3 </values>
</parameter>
</category>
<category name="NewtonParameters">
......@@ -350,90 +280,7 @@ adding an empty line, make text **bold** or ``monospaced``.
</parameter>
</category>
<category name="adaptivity">
<parameter name="useAdaptivity">
<definition> Switches adaptive grid refinement (h-adaptivity) on (``true``) or
off (``false``). If enabled, an unstructured grid manager with higher computational
cost is used when using rectangular / cubic grids. </definition>
<values> true, false </values>
<suggestion> false </suggestion>
</parameter>
<parameter name="maxLevel">
<definition> The maximum refinement level kept in the grid. This is a useful
tool to prevent over-refinement. If this value is high, the grid can
be refined to an arbitrary degree, leading to an evenly distributed error
across the grid. Make sure you avoid refinement levels which imply grid cell sizes
beyond the Richards continuum scale. </definition>
<values> int </values>
<suggestion> 10 </suggestion>
</parameter>
<parameter name="minLevel">
<definition> Minimum refinement level of the grid. Grid cells will not get
coarsened below this level. </definition>
<values> int </values>