Compile time of UflLocalFunction
I'm a bit annoyed about the long compile time of the UFLLocalFunction. Usually, I have to wait for around 30s - each time I change a single sign in the ufl description.
Do you see any way to improve this?
Minimal working example: (takes 27s for the last line)
from dune.grid import cartesianDomain
from dune.alugrid import aluConformGrid as leafGridView
from dune.fem.view import adaptiveLeafGridView as adaptiveGridView
domain = cartesianDomain([0, 0], [1, 1], [10, 10])
grid = leafGridView( domain )
from dune.fem.space import lagrange
space = lagrange(grid, order=1)
sol = space.interpolate(0, name="sol")
# [added the following two lines later]
from dune.fem.function import uflFunction
u = uflFunction(gridView=grid, name="u", order=0, ufl=sol+42) # this line takes ~27s each time you change '42'
I investigated compile time for the generated UFLLocalFunction code in .cache/dune-py/python/dune/generated
.
Most walltime is spent in generation of this object.
Seems that both "Parts" of this .cc file take half of Walltime.
I experimented with precompiled headers for this file (it's easy with cmake>=3.16, see target_precompile_headers). This actually saves some seconds when recompiling with a different function '42', but at maximum around 5s. The second part still takes around 15s.
Any ideas? I am willing to spend time when I save it on the other end!
Isn't it possible to just compile the new methods and link it to a general function object?
#include ...
namespace UFLLocalFunctions_12345
{
// -- PART 1
// UFLLocalFunction
// ----------------
template< class GridPart, class Coeffnormal_p, class Coeffnormal_m, class Coefftrace_solution, class Coefftrace_solutionA >
struct UFLLocalFunction
: public Dune::Fem::BindableGridFunctionWithSpace<GridPart,Dune::Dim<1>>
{
...
}
...
} // namespace UFLLocalFunctions_12345
// -- PART 2
PYBIND11_MODULE( localfunction_12345, module )
{
auto cls = Dune::Python::insertClass<UFLLocalFunctions...
}