Skip to content
Snippets Groups Projects
Commit a51fb2f9 authored by René Heß's avatar René Heß
Browse files

Read default options from scheme and fix some ini file errors

parent 5c193d4b
No related branches found
No related tags found
No related merge requests found
......@@ -42,7 +42,15 @@ class CodegenOption(ImmutableRecord):
class CodegenGlobalOptionsArray(ImmutableRecord):
""" A collection of form compiler arguments """
def __init__(self, **kwargs):
opts = {k: v.default for k, v in CodegenGlobalOptionsArray.__dict__.items() if isinstance(v, CodegenOption)}
# Set the default values from the yaml scheme as defaults
resource_package = __name__
resource_path = 'options_global.yaml'
yaml_stream = pkg_resources.resource_string(resource_package, resource_path)
try:
scheme = yaml.safe_load(yaml_stream)
except Exception as e:
raise e
opts = {k: v['default'] for k, v in scheme.items()}
opts.update(**kwargs)
ImmutableRecord.__init__(self, **opts)
......@@ -80,7 +88,18 @@ class CodegenGlobalOptionsArray(ImmutableRecord):
class CodegenFormOptionsArray(ImmutableRecord):
""" A collection of form-specific form compiler arguments """
def __init__(self, **kwargs):
opts = {k: v.default for k, v in CodegenFormOptionsArray.__dict__.items() if isinstance(v, CodegenOption)}
# opts = {k: v.default for k, v in CodegenFormOptionsArray.__dict__.items() if isinstance(v, CodegenOption)}
# Set the default values from the yaml scheme as defaults
resource_package = __name__
resource_path = 'options_form.yaml'
yaml_stream = pkg_resources.resource_string(resource_package, resource_path)
try:
scheme = yaml.safe_load(yaml_stream)
except Exception as e:
raise e
opts = {k: v['default'] for k, v in scheme.items()}
opts.update(**kwargs)
ImmutableRecord.__init__(self, **opts)
......@@ -156,7 +175,7 @@ def initialize_options():
scheme_global = yaml.safe_load(yaml_stream)
except Exception as e:
raise e
validator_global = CodegenOptionsValidator(scheme_global)
validator_global = CodegenOptionsValidator(scheme_global, require_all=True)
if not validator_global.validate(_global_options.__dict__):
raise RuntimeError("Global options validation failed: {}".format(validator_global.errors))
......@@ -167,7 +186,7 @@ def initialize_options():
scheme_form = yaml.safe_load(yaml_stream)
except Exception as e:
raise e
validator_form = CodegenOptionsValidator(scheme_form)
validator_form = CodegenOptionsValidator(scheme_form, require_all=True)
for form in [i.strip() for i in _global_options.operators.split(",")]:
if not validator_form.validate(_form_options[form].__dict__):
raise RuntimeError("Form options validation failed: {}".format(validator_form.errors))
......@@ -259,13 +278,13 @@ def process_form_options(opt, form):
if opt.numerical_jacobian:
opt = opt.copy(generate_jacobians=False, generate_jacobian_apply=False)
if opt.form is None:
if opt.form == '':
opt = opt.copy(form=form)
if opt.classname is None:
if opt.classname == '':
opt = opt.copy(classname="{}Operator".format(form))
if opt.filename is None:
if opt.filename == '':
opt = opt.copy(filename="{}_{}_file.hh".format(get_option("target_name"), opt.classname))
if opt.block_preconditioner_diagonal or opt.block_preconditioner_offdiagonal:
......
......@@ -24,7 +24,7 @@ blockstructured:
helpstr: "Use block structure"
classname:
type: string
default: None
default: ""
helpstr: "The name of the C++ class to generate"
constant_transformation_matrix:
type: boolean
......@@ -36,7 +36,7 @@ control:
helpstr: "Generate operator of derivative w.r.t. the control variable"
control_variable:
type: string
default: None
default: ""
helpstr: "Name of control variable in UFL file"
diagonal_transformation_matrix:
type: boolean
......@@ -60,11 +60,11 @@ fastdg:
helpstr: "Use FastDGGridOperator from PDELab."
filename:
type: string
default: None
default: ""
helpstr: "The filename to use for this LocalOperator"
form:
type: string
default: None
default: ""
helpstr: "The name of the UFL object representing the form in the UFL file"
generate_jacobian_apply:
type: boolean
......@@ -96,7 +96,7 @@ numerical_jacobian:
helpstr: "use numerical jacobians (only makes sense, if uflpdelab for some reason fails to generate analytic jacobians)"
objective_function:
type: string
default: None
default: ""
helpstr: "Name of form representing the objective function in UFL file"
print_transformations:
type: boolean
......@@ -112,7 +112,7 @@ quadrature_mixins:
helpstr: "A comma separated list of mixin identifiers to use for quadrature. Currently implemented: generic, sumfact"
quadrature_order:
type: string
default: ''
default: ""
helpstr: "Quadrature order used for all integrals."
simplify:
type: boolean
......@@ -160,11 +160,11 @@ vectorization_blockstructured_tail:
helpstr: "Try to fully vectorize block structuring even when 'nunmber_of_blocks' is not divisible by vector length"
vectorization_blockstructured_tail_ordering:
type: string
default: 'consecutive'
default: "consecutive"
helpstr: "Ordering of the tail w.r.t the vectorized loop. Possible values: consecutive|blocked"
vectorization_horizontal:
type: string
default: None
default: ""
helpstr: "an explicit value for horizontal vectorization read by the 'explicit' strategy"
vectorization_jacobians:
type: boolean
......@@ -172,7 +172,7 @@ vectorization_jacobians:
helpstr: "Whether to attempt to vectorize jacobians (takes time, often not needed)"
vectorization_list_index:
type: string
default: None
default: ""
helpstr: "Which vectorization to pick from a list (only valid with vectorization_strategy=fromlist)."
vectorization_not_fully_vectorized_error:
type: boolean
......@@ -180,7 +180,7 @@ vectorization_not_fully_vectorized_error:
helpstr: "throw an error if nonquadloop vectorization did not fully vectorize"
vectorization_padding:
type: string
default: None
default: ""
helpstr: "an explicit value for the allowed padding in vectorization"
vectorization_quadloop:
type: boolean
......@@ -196,5 +196,5 @@ vectorization_target:
helpstr: "The cost function target for the 'target' cost model. Only needed to verify the cost model itself, do not use light-heartedly!!!"
vectorization_vertical:
type: string
default: None
default: ""
helpstr: "an explicit value for vertical vectorization read by the 'explicit' strategy"
\ No newline at end of file
......@@ -21,7 +21,7 @@ geometry_mixins = equidistant, sumfact_equidistant | expand sf
sumfact = 0, 1 | expand sf
fastdg = 0, 0 | expand sf
[formcompiler.operator]
[formcompiler.poisson]
geometry_mixins = equidistant, sumfact_equidistant | expand sf
sumfact = 0, 1 | expand sf
fastdg = 0, 0 | expand sf
......@@ -10,4 +10,6 @@ extension = vtu
[formcompiler]
opcounter = 1
instrumentation_level = 3
[formcompiler.r]
geometry_mixins = equidistant
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