Hello,
To define an object parameters
of type Parameters with the key (i.e. its name) my_parameters you can use this syntax :
// Attempt to add parameters
dolfin::Parameters parameters("my_parameters");
Concerning the call to to add
, this function must be called inside the definition of another function in order to comply with C++ writing rules. Here is a stackoverflow post about that. For example:
[*In the cpp code snippet*]
void add(std::string key, double pval)
{
my_parameters.add(key, pval);
}
// Function for setting a bool--valued parameter
void add(std::string key, bool pval)
{
my_parameters.add(key, pval);
}
};
PYBIND11_MODULE(SIGNATURE, m)
{
py::class_<Profile, std::shared_ptr<Profile>, dolfin::Expression>
(m, "Profile")
.def(py::init<>())
.def("add_parameter", (void (Profile::*)(std::string, double)) &Profile::add, "Add double-valued parameter.")
.def("add_parameter", (void (Profile::*)(std::string, bool)) &Profile::add, "Add bool-valued parameter.");
}
"""
[*In the python script*]
expr.add_parameter("p", 0.1)
However, I cannot use the modified code snippet to generate a FEniCS expression with my current installation. It generates an error similar to the one reported by Nico Schlömer a few weeks ago on this issue.