Skip to content
Snippets Groups Projects
Commit f708467d authored by Dominic Kempf's avatar Dominic Kempf
Browse files

Read options from an ini file

parent 5daceaaf
No related branches found
No related tags found
No related merge requests found
...@@ -33,12 +33,7 @@ def get_form_compiler_arguments(): ...@@ -33,12 +33,7 @@ def get_form_compiler_arguments():
parser.add_argument("--print-transformations", action="store_true", help="print out dot files after ufl tree transformations") parser.add_argument("--print-transformations", action="store_true", help="print out dot files after ufl tree transformations")
parser.add_argument("--print-transformations-dir", type=str, help="place where to put dot files (can be omitted)") parser.add_argument("--print-transformations-dir", type=str, help="place where to put dot files (can be omitted)")
parser.add_argument("--diagonal-transformation-matrix", action="store_true", help="set option if the jacoby of the transformation is diagonal (axiparallel grids)") parser.add_argument("--diagonal-transformation-matrix", action="store_true", help="set option if the jacoby of the transformation is diagonal (axiparallel grids)")
parser.add_argument("--ini-file", type=str, help="An inifile to use. A generated driver will be hard-coded to it, a [formcompiler] section will be used as default values to form compiler arguments (use snake case)")
# These are the options that I deemed necessary in uflpdelab
# parser.add_argument("--param-class-file", type=str, help="The filename for the generated parameter class header")
# parser.add_argument("--export-trafo-graphs", action="store_true", help="export expression graphs after the application of each single transformation")
# parser.add_argument("--parameter-tree", action="store_true", help="have the generated local operate take a Dune::ParameterTree as constructor argument")
# parser.add_argument("--inifile", type=str, help="The inifile that this program's driver should be hardcoded to. Omit to use a commandline argument ini file")
# Modify the positional argument to not be a list # Modify the positional argument to not be a list
args = vars(parser.parse_args()) args = vars(parser.parse_args())
...@@ -52,6 +47,8 @@ def get_form_compiler_arguments(): ...@@ -52,6 +47,8 @@ def get_form_compiler_arguments():
args["driver_file"] = os.path.abspath(args["driver_file"]) args["driver_file"] = os.path.abspath(args["driver_file"])
if args["operator_file"]: if args["operator_file"]:
args["operator_file"] = os.path.abspath(args["operator_file"]) args["operator_file"] = os.path.abspath(args["operator_file"])
if args["ini_file"]:
args["ini_file"] = os.path.abspath(args["ini_file"])
# Return the argument dict. This result is memoized to turn all get_option calls into simple dict lookups. # Return the argument dict. This result is memoized to turn all get_option calls into simple dict lookups.
return args return args
...@@ -68,6 +65,14 @@ def init_option_dict(): ...@@ -68,6 +65,14 @@ def init_option_dict():
_option_dict.update(get_form_compiler_arguments()) _option_dict.update(get_form_compiler_arguments())
_arguments_read = True _arguments_read = True
# Read arguments from the given inifile
if args["ini_file"]:
from dune.common.parametertree.parser import parse_ini_file
inifile = parse_ini_file(args["ini_file"])
for key, value in inifile["formcompiler"]:
if key not in _option_dict:
_option_dict[key] = value
def set_option(key, value): def set_option(key, value):
"""Add the key value pair to the options. """Add the key value pair to the options.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment