Commit 38d5508c authored by Dion Haefner's avatar Dion Haefner

merge

parent bbecedbd
......@@ -5,10 +5,11 @@ FIND_PACKAGE (HDF5 REQUIRED)
FIND_PACKAGE (FFTW REQUIRED)
FIND_PACKAGE (SuperLU REQUIRED)
FIND_PACKAGE (MPI REQUIRED)
FIND_PACKAGE (METIS REQUIRED)
FIND_PACKAGE (ParMETIS REQUIRED)
FIND_PACKAGE (UG REQUIRED)
FIND_PACKAGE (METIS)
FIND_PACKAGE (ParMETIS)
include_directories(${FFTW_INCLUDES})
include_directories(${HDF5_INCLUDE_DIRS})
......
This diff is collapsed.
# This cmake module provides macros that install python packages into the virtualenv
# that is shared by all dune modules that depend on dune-python.
#
# .. cmake_function:: dune_install_python_package
#
# .. cmake_param:: PATH
# :required:
# :single:
#
# Relative path to the given python package source code.
#
# .. cmake_param:: MAJOR_VERSION
# :single:
#
# Set to "2" or "3" if your python package only works with
# python2 or python3. This will restrict the installation process to that
# python version.
#
# .. cmake_param:: NO_PIP
# :option:
#
# Instead of :code:`pip -e`, `python setup.py develop` will be used as
# the installation command.
#
# .. cmake_param:: NO_EDIT
# :option:
#
# Will drop :code:`pip`s :code:`-e` option (or switch :code:`develop` to :code:`install`).
# Only use this option if your package is incompatible with :code:`-e`.
#
# Installs the python package located at path into the virtualenv used by dune-python
# The package at the given location is expected to be a pip installable package.
# Also marks the given python package for global installation during :code:`make install`.
# By default, the python package will then be installed into the system-wide site-packages
# location. If you do not want to install it there, or you do not have permission to,
# you may optionally set :ref:`DUNE_PYTHON_INSTALL_USER` to a username. The
# packages will then be installed in the home directory of that user.
# This is done through pips :code:`--user` option. Installation in arbitrary locations is not
# supported to minimize :code:`PYTHONPATH` issues.
#
# .. cmake_variable:: DUNE_PYTHON_INSTALL_USER
#
# dune-python only supports two ways of globally installing python packages during
# :code:`make install`:
#
# * Into standard system paths (default)
# * Into the standard python path of a users home directory (through :code:`pip --user`)
#
# Set this variable to a username to use the latter.
#
include(CheckPythonPackage)
function(dorie_install_python_package)
# Parse Arguments
set(OPTION NO_PIP NO_EDIT QUIET)
set(SINGLE PATH MAJOR_VERSION)
set(MULTI)
include(CMakeParseArguments)
cmake_parse_arguments(PYINST "${OPTION}" "${SINGLE}" "${MULTI}" ${ARGN})
if(PYINST_UNPARSED_ARGUMENTS)
message(WARNING "Unparsed arguments in dune_install_python_package: This often indicates typos!")
endif()
# apply defaults
if(NOT PYINST_MAJOR_VERSION)
set(PYINST_MAJOR_VERSION 2 3)
endif()
# check for available pip packages
check_python_package(PACKAGE pip
INTERPRETER ${PYTHON2_EXECUTABLE}
RESULT PIP2_FOUND)
check_python_package(PACKAGE pip
INTERPRETER ${PYTHON3_EXECUTABLE}
RESULT PIP3_FOUND)
# Construct the installation command strings from the given options
if(PYINST_NO_PIP)
if(PYINST_NO_EDIT)
set(INST_COMMAND install)
else()
set(INST_COMMAND develop)
endif()
set(VENV_INSTALL_COMMAND python setup.py ${INST_COMMAND})
else()
set(EDIT_OPTION)
if(NOT PYINST_NO_EDIT)
set(EDIT_OPTION -e)
endif()
if(PYINST_QUIET)
set(EDIT_OPTION "-q ${EDIT_OPTION}")
endif()
set(VENV_INSTALL_COMMAND python -m pip install ${EDIT_OPTION} .)
endif()
# Construct the interpreter options for global installation
if(PYINST_NO_PIP)
set(SYSTEM_INSTALL_OPTIONS setup.py install)
if(DUNE_PYTHON_INSTALL_USER)
message("Error message: Incompatible options - NO_PIP and DUNE_PYTHON_INSTALL_USER")
endif()
else()
set(USER_STRING "")
if(DUNE_PYTHON_INSTALL_USER)
set(USER_STRING --user ${DUNE_PYTHON_INSTALL_USER})
endif()
set(SYSTEM_INSTALL_OPTIONS -m pip install ${USER_STRING} .)
endif()
# iterate over the given interpreters
foreach(version ${PYINST_MAJOR_VERSION})
# install the package into the virtual env
execute_process(COMMAND ${CMAKE_BINARY_DIR}/dune-env-${version} ${VENV_INSTALL_COMMAND}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${PYINST_PATH})
# define a rule on how to install the package during make install
if(PIP${version}_FOUND)
install(CODE "execute_process(COMMAND ${PYTHON${version}_EXECUTABLE} ${SYSTEM_INSTALL_OPTIONS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${PYINST_PATH})
")
else()
install(CODE "message(FATAL_ERROR \"You need the python${version} package pip installed on the host system to install a module that contains python code\")")
endif()
endforeach()
endfunction()
function(install_python_package curdir packagelist)
message(STATUS "Installing python package dorie.${curdir}")
dorie_install_python_package(PATH ${curdir} QUIET)
dune_install_python_package(PATH ${curdir} ADDITIONAL_PIP_PARAMS -r ${CMAKE_CURRENT_SOURCE_DIR}/${curdir}/requirements.txt -q)
set(${packagelist} ${${packagelist}} ${CMAKE_CURRENT_SOURCE_DIR}/${curdir} PARENT_SCOPE)
endfunction()
......
from __future__ import absolute_import
import os
from warnings import warn
......
from __future__ import absolute_import
import xml.etree.ElementTree as ET
from warnings import warn
from collections import OrderedDict
......
from __future__ import unicode_literals
import datetime
import os
import re
......@@ -5,7 +9,7 @@ import re
from dorie.utilities.check_path import check_path
from dorie.parscraper.parameter import Parameter
def write(parameters,out,path_format,**kwargs):
def write(parameters,out,path_base,*args,**kwargs):
"""
Writes the contents of the ``parameters`` input dict to a .html file. The output is
structured as
......@@ -21,9 +25,8 @@ def write(parameters,out,path_format,**kwargs):
:param dict parameters: dict with categories as keys and iterables of :class:`dorie.parscraper.parameter.Parameter` \
instances as values.
:param str out: Path to the output file. Must be writable.
:param str path_format: Format string pointing to the source files. \
Needed for creation of working links to the files. May contain \{filename\} and \{line\} that are substituted \
by the file name and line number, respectively.
:param str path_base: Base path to the source files. Needed for creation of working links \
to the files.
:param str css: Path to a CSS file containing the styling of the HTML output. Is \
included into the HTML output (inline). Optional.
......@@ -32,7 +35,7 @@ def write(parameters,out,path_format,**kwargs):
# DEFINE SOME PROPERTIES
title = "DORiE parameter cheat sheet"
headings = ["Parameter","Definition","Possible values","Default","Queried at"]
table_content = lambda p: (p.key,p.definition,p.values,p.suggestion,_sources(p,path_format))
table_content = lambda p: (p.key,p.definition,p.values,p.suggestion,_sources(p,path_base))
widths = [13, 40, 17, 10, 20] # relative column widths
# WRITE HTML CODE TO OUTPUT
......@@ -176,7 +179,7 @@ def _parse_markdown(text):
return text
def _sources(p,path_format):
def _sources(p,path_base):
"""
Assembles the cell text for the sources of a parameter. Since the
Parameter._sources attribute is a list of tuples, we need to parse this
......@@ -186,14 +189,12 @@ def _sources(p,path_format):
Returns a unicode string containing the HTML code.
:param p: Parameter object
:param str path_format: Format string pointing to the source files. \
Needed for creation of working links to the files. May contain \{filename\} and \{line\} that are substituted \
by the file name and line number, respectively.
:param path_base: Base path to the source files. Needed for creation of working links to the files.
"""
out = u""
for source_file, line_num, var_type in p._sources:
full_path = path_format.format(filename=source_file,line=line_num)
full_path = os.path.join(path_base,source_file)
# truncate long file names
if len(source_file) > 20:
......@@ -201,6 +202,8 @@ def _sources(p,path_format):
else:
link_text = source_file
out += "<a href='{2}' title='{3}'>{0}</a>:{1}<br />"\
out += "<a href='file://{2}' title='{3}'>{0}</a>:{1}<br />"\
.format(link_text,line_num,full_path,source_file)
return out
from __future__ import unicode_literals
import datetime
import os
import re
try:
str = unicode
except NameError:
pass
from dorie.utilities.check_path import check_path
from dorie.parscraper.parameter import Parameter
def write(parameters,out,path_format,**kwargs):
def write(parameters,out,path_base,*args,**kwargs):
"""
Writes the contents of the ``parameters`` input dict to a .rst file. The output is
structured as
......@@ -21,9 +30,8 @@ def write(parameters,out,path_format,**kwargs):
:param dict parameters: dict with categories as keys and iterables of :class:`dorie.parscraper.parameter.Parameter` \
instances as values.
:param str out: Path to the output file. Must be writable.
:param str path_format: Format string pointing to the source files. \
Needed for creation of working links to the files. May contain \{filename\} and \{line\} that are substituted \
by the file name and line number, respectively.
:param str path_base: Base path to the source files. Needed for creation of working links \
to the files.
"""
......@@ -31,27 +39,26 @@ def write(parameters,out,path_format,**kwargs):
headings = ["Parameter","Definition","Possible values","Default","Queried at"]
widths = ["15","45","20","10","10"] # relative column widths
table_content = lambda p: (p.key,p.definition,p.values,p.suggestion,_sources(p,path_format))
table_content = lambda p: (p.key,p.definition,p.values,p.suggestion,_sources(p,path_base))
check_path(out)
with open(out,"w") as output:
with open(out,"wb") as output:
rst_document = _format_rst(parameters, headings, widths, table_content)
output.write(rst_document)
output.write(rst_document.encode('utf-8'))
def _format_rst(parameters,headers,widths,content_function):
rst = ""
for category in parameters.keys():
rst = u""
for category in parameters:
rst += _format_heading(category)
if parameters[category]:
table_content = [content_function(p) for p in parameters[category]]
rst += _format_table(table_content,headers,widths)
table_content = [content_function(p) for p in parameters[category]]
rst += _format_table(table_content,headers,widths)
return rst
def _format_table(content,headers,widths):
tab = " "
delimiter = ","
table = ""
table = u""
table += ".. csv-table::\n"
table += tab + ":header: {}\n".format(", ".join(headers))
table += tab + ":delim: {}\n".format(delimiter)
......@@ -74,16 +81,7 @@ def _format_heading(text):
sep = "+"*len(text)
return text + "\n" + sep + "\n\n"
def _format_footer():
# UNUSED
tab = " "
footer = ""
footer += ".. class:: center"
footer += tab + "Automatically created by the :mod:`DORiE parameter scraper <dorie.parscraper>`\n\n"
footer += tab + "{0:%d-%m-%Y, %H:%M}".format(datetime.datetime.today())
return footer
def _sources(p,path_format):
def _sources(p,path_base):
"""
Assembles the cell text for the sources of a parameter. Since the
Parameter._sources attribute is a list of tuples, we need to parse this
......@@ -93,14 +91,10 @@ def _sources(p,path_format):
Returns a unicode string containing the RST code.
:param p: Parameter object.
:param str path_format: Format string pointing to the source files. \
Needed for creation of working links to the files. May contain \{filename\} and \{line\} that are substituted \
by the file name and line number, respectively.
"""
out = u""
for source_file, line_num, var_type in p._sources:
full_path = path_format.format(filename=source_file,line=line_num)
full_path = os.path.join(path_base,source_file)
# truncate long file names
if len(source_file) > 20:
......@@ -108,6 +102,8 @@ def _sources(p,path_format):
else:
link_text = source_file
out += "`{0} <{2}>`__:{1}\n\n"\
out += "`{0} <file://{2}>`_:{1}\n\n"\
.format(link_text,line_num,full_path,source_file)
return out
include /home/dion/codes/dune/dorie/build-cmake/doc/default_files/default_pf.ini
__name = correlation
__inifile_optionkey = pfg
_asset_path = "/home/dion/codes/dune/dorie/testing"
_evaluation = correlation
[_correlation]
padding = true
[general]
generator = fft
overwrite = true
[generator]
extensions = 1 1, 1 1 1 | expand dim
[generator.fft]
dimensions = 2, 3 | expand dim
outputPath = fft_fields/
N = 2048 2048, 128 128 128 | expand dim
variance = 0.2
correlationLengths = .0039 .00195, .0313 .0625 .0781 | expand dim
include /home/dion/codes/dune/dorie/build-cmake/doc/default_files/default.ini
__name = muphi
__inifile_optionkey = run
_asset_path = "/home/dion/codes/dune/dorie/testing"
_evaluation = muphi
_reference.path = {_asset_path}/reference/
output.fileName = muphi | unique name
output.outputPath = muphi | unique name
output.verbose = 0
time.end = 1.5E5
time.maxTimestep = 1E5
time.startTimestep = 1E3
adaptivity.useAdaptivity = false
grid.dimensions = 2
grid.initialLevel = 0
grid.gridType = rectangular
grid.cells = 50 200
grid.extensions = 1 1
boundary.file = "{_asset_path}/bcs/muphi2d.dat"
parameters.soilDistribution = twoMedia
# fix some parameters so we make sure they are the same as in the muphi run
[parameters.vanGenuchten.1]
thetaR = 0.03
thetaS = 0.32
alpha = -2.3
tau = -1.1
n = 4.17
K0 = 2.2e-5
fraction = 0.8 #Part of the field that is filled with medium 1 (top)
[parameters.vanGenuchten.2]
thetaR = 0.01
thetaS = 0.41
alpha = -0.7
tau = 0
n = 1.3
K0 = 1e-5
[randomField]
N = 1000 1000
variance = 0.2
correlationLengths = .4 .05
seed = 223141598
beta = 0
embeddingFactor = .01
variogramModel = gaussian
newField = false
newEV = false
showEV = false
include /home/dion/codes/dune/dorie/build-cmake/doc/default_files/default.ini
__name = ode
__inifile_optionkey = run
_asset_path = "/home/dion/codes/dune/dorie/testing"
_evaluation = ode
output.fileName = ode | unique
output.outputPath = ode | unique
output.verbose = 0
time.end = 1E7
time.maxTimestep = 1E7
time.startTimestep = 1E4
adaptivity.threshold = 1E-10
adaptivity.useAdaptivity = false, true, true | expand gridtype
grid.initialLevel = 2, 0, 0 | expand gridtype
grid.gridType = rectangular, rectangular, gmsh | expand gridtype
grid.cells = 1 100
grid.gridFile = "{_asset_path}/meshes/mesh.msh"
boundary.file = "{_asset_path}/bcs/bcFile2d.dat"
parameters.soilDistribution = homogeneous, twoLayers | expand
parameters.fraction = 0.6
[_ode]
flux = -3e-6
l2_abstol = 5E-5
include /home/dion/codes/dune/dorie/build-cmake/doc/default_files/default.ini
__name = reference
__inifile_optionkey = run
_asset_path = "/home/dion/codes/dune/dorie/testing"
_evaluation = reference
_reference.path = {_asset_path}/reference/
output.fileName = reference | unique name
output.outputPath = reference | unique name
output.verbose = 0
time.end = 1E5
time.maxTimestep = 1E5
time.startTimestep = 1E4
adaptivity.threshold = 1E-10
adaptivity.useAdaptivity = false, true, false | expand dim
adaptivity.refinementFraction = .05
grid.dimensions = 2, 2, 3 | expand dim
grid.initialLevel = 0
grid.gridType = gmsh, rectangular, rectangular | expand dim
grid.cells = 20 20, 20 20, 10 10 10 | expand dim
grid.extensions = 1 1, 1 1, 1 1 1 | expand dim
grid.gridFile = "{_asset_path}/meshes/mesh.msh", "{_asset_path}/meshes/mesh.msh", "{_asset_path}/meshes/3dcube.msh" | expand dim
boundary.file = "{_asset_path}/bcs/bcFile2d.dat", "{_asset_path}/bcs/bcFile2d.dat", "{_asset_path}/bcs/bcFile3d.dat" | expand dim
parameters.soilDistribution = twoMedia, millerSimilarity | expand
randomField.N = 1000 1000, 1000 1000, 100 100 100 | expand dim
randomField.correlationLengths = .2 .1, .2 .1, .2 .1 .4 | expand dim
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