Add option to not throw error when coefficient is not found
It can be convenient to attach all coefficients to all forms, in which case the DOLFIN wrapper shouldn't throw an error. A scenario is the $\theta$ method for time stepping. It $\theta$ is the in the UFL file, the coefficients attached to the bilinear and linear for can change depending on the value of $\theta$ (due to UFL optimising away zero), which is tedious to modify code for.
Comments (7)
-
-
reporter The relevant code is in the C++ wrappers for DOLFIN that FFC generates. In addition to what you sketched above, we also have
BilinearForm a(V, V); auto f = std::make_shared<Constant>(1.0); a.set_coefficient("f", f);
I use this form as it accepts shared pointers (
a.f
only takes a reference tof
.) -
Ok, so just adding a.set_coefficients(functions); and adding the Functions (FunctionSet?) class (doesn't need to be generated) is one fairly simple way to go.
-
reporter Much simpler;
a.set_coefficients
already exists in the wrappers. Just need an extra argument to disable the error. -
- changed milestone to 2017.1
-
- changed milestone to 2017.2
-
- removed milestone
- Log in to comment
In the C++ layer? The difficulty is that the a.f = f; notation is only possible for a fixed set of names. Adding a class to collect sets of named objects could solve that and additionally remove the need to repeat a.f=f; L.f=f; etc.