no type named ‘GridPartType’ in SimpleGridFunction
Hi,
I am enjoy using the python bindings for dune-fem intalled via pip (in a singularity container).
Next I'd like to create a geometryGridView
using a gridFunction
(full mwe.py):
from dune.grid import structuredGrid
from dune.fem.function import gridFunction
from dune.fem.view import geometryGridView
gv = structuredGrid([0,0],[1,1],[10,10])
@gridFunction(gv, name="transformation", order=1)
def trans(element, hatx):
xglobal = element.geometry.toGlobal(hatx)
return xglobal
geo = geometryGridView(trans)
This fails with a nice long error message (mwe.out). The important bit is:
/opt/dune/dune-env/include/dune/fem/gridpart/geometrygridpart.hh:126:51: error: no type named ‘GridPartType’ in ‘class Dune::Python::SimpleGridFunction<Dune::GridView<Dune::ALU3dLeafGridViewTraits<const Dune::ALUGrid<2, 2, Dune::simplex, Dune::conforming>, Dune::All_Partition> >, Dune::Python::detail::PyGridFunctionEvaluator<Dune::GridView<Dune::ALU3dLeafGridViewTraits<const Dune::ALUGrid<2, 2, Dune::simplex, Dune::conforming>, Dune::All_Partition> >, 2, pybind11::function> >’
Would it be possible to expose this type?
SimpleGridFunction
is defined in dune-fem/dune/fempy/function/simplegridfunction.hh L129. It seems like this could be fixed by adding somewhere:
typedef GridPart GridPartType;
The issue is that this is a dune-grid
class so the type is GridView
.
Possible solutions:
- extend the
dune.grid.gridFunction
function to take an additional argument where theSimpleGridFunction
class can be replaced by something else. Then we could derive from that class indune-fem
and simply add the required typedefs there - might still be problematic in places wheregridFunction.gridPart()
is used. - slowly change code in
dune-fem to replace lines like
typedef typename GridFunction::GridPartType HostGridPartType;(dune/fem/gridpart/geometrygridpart.hh:128) with something like
typedef typename GridPartGetter::Type HostGridPartType;Places with
gridFunction.gridPart()then need replacing with
GridPartGetter::get(gridFunction)`
Edited by Andreas Dedner