dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #01726
Implement localization of parameters to objects or hierarchies of objects: [...]
Commit from logg (2005-12-20 19:00 CET)
----------------
Implement localization of parameters to objects or hierarchies of objects:
- Som bug fixes in the new system checked in yesterday: string parameters
(const char*) were automatically cast to bool instead of std::string.
Should be fixed now (added explicit initialization from const char*).
- Parameters can now be localized to objects by inheriting from the
new class Parametrized. Here's a short introduction:
Each object of a parametrized class holds a local database of parameters
that override the global database of parameters.
Hierarchies of parametrized objects may be created with the
property that each object inherits the parameters of its parent
and all parameters inherited by the parent. A parameter takes
the value of the first value specified in the hierarchy,
starting at the current object and following the parents back to
the global database.
Thus, a parameter that has not been specified, using the set()
function, in any given object, takes the value specified for the
parent, whereas any parameter value that has been specified
locally overrides the value specified for the parent.
- Here's an example (from src/test/):
class Foo : public Parametrized {};
class Bar : public Parametrized {};
Foo foo;
Bar bar;
bar.set("parent", foo);
foo.set("tolerance", 0.00007);
foo.set("file name", "foo.tmp");
bar.set("file name", "bar.tmp");
bar.set("my parameter", "bar");
And here's some test output:
global parameters:
[Parameter: value = "cg" (string)]
[Parameter: value = 0.1 (real)]
[Parameter: value = "primal.m" (string)]
parameters for foo:
[Parameter: value = "cg" (string)]
[Parameter: value = 7e-05 (real)]
[Parameter: value = "foo.tmp" (string)]
parameters for bar:
[Parameter: value = "cg" (string)]
[Parameter: value = 7e-05 (real)]
[Parameter: value = "bar.tmp" (string)]
[Parameter: value = "bar" (string)]
dolfin ChangeLog 1.268
dolfin src/kernel/io/XMLFile.cpp 1.35
dolfin src/kernel/log/LogStream.cpp 1.12
dolfin src/kernel/parameter/Makefile.am 1.2
dolfin src/kernel/parameter/Makefile.in 1.2
dolfin src/kernel/parameter/Parameter.cpp 1.2
dolfin src/kernel/parameter/ParameterList.cpp 1.2
dolfin src/kernel/parameter/ParameterValue.cpp 1.2
+ dolfin src/kernel/parameter/Parametrized.cpp 1.1
dolfin src/kernel/parameter/dolfin/DefaultParameters.h 1.2
dolfin src/kernel/parameter/dolfin/Makefile.am 1.2
dolfin src/kernel/parameter/dolfin/Makefile.in 1.3
dolfin src/kernel/parameter/dolfin/Parameter.h 1.2
dolfin src/kernel/parameter/dolfin/ParameterList.h 1.2
dolfin src/kernel/parameter/dolfin/ParameterValue.h 1.2
+ dolfin src/kernel/parameter/dolfin/Parametrized.h 1.1
dolfin src/kernel/parameter/dolfin/dolfin_parameter.h 1.2
dolfin src/test/main.cpp 1.16
Follow ups