I am trying to avoid copy pasting my UFL files for each element type, and then dealing with the different forms in my solver.
For example, I'd rather not carry Pressure1D, Pressure2D, and Pressure3D. Instead I would like to carry a 'base' Pressure which I can assign as one of the three. Is there a way to do this, perhaps a base class that I can use and assign appropriately?
EDIT
An example of a UFL file for divergence:
vector = VectorElement("Lagrange", etype, hvector)
scalar = FiniteElement("Lagrange", etype, hscalar)
q = Coefficient(vector)
a = u*w*dx
L = (Dx(q[i],i))*w*dx
I take that UFL file and copy it with sed to replace etype, hvector and hscalar with the element type (interval,triangle,tetrahedral), and hvector and hscalar with the interpolation order for the vector and scalar respectively. This templates out the UFL files for me nicely which I then run FFC upon to get cpp/h files.
What I would like to do is code the solver agnostic to which particular FunctionSpace is used. I found I can do a fair amount of it using boost::optional and use the base dolfin:: types. So I might have:
boost::optional<dolfin::Function> u;
boost::optional<dolfin::FunctionSpace> V;
switch(dimensions){
case 1:
V = DivergenceOneDim::FunctionSpace(mesh); break;
case 2:
V = DivergenceTwoDim::FunctionSpace(mesh); break;
case 3:
V = DivergenceThreeDim::FunctionSpace(mesh); break;
}
u = Function(*u)
This doesnt solve the problem of access 'q' without boxing/wrapping, though.