The following code does not work, i.e. the grid is not refined, and we should at least raise an Exception that this does not work. Or is it simply a bug.
from dune.grid import cartesianDomain
from dune.grid import yaspGrid
from dune.fem.view import adaptiveLeafGridView
from dune.fem.space import finiteVolume
from dune.fem import globalRefine as globalRefine
domain = cartesianDomain([0,0], [1,1], [4, 4])
view = adaptiveLeafGridView( yaspGrid( domain ) )
spc = finiteVolume(view)
uh = spc.interpolate(1, name="uh")
globalRefine(1, uh)
uh.plot()
When using the precompiled modules I came across the following problem. After removing the cache I ran this script and it fails with a message that PETSc was not found.
raise ConfigurationError("petsc has not been found during configuration of dune - please add the path to petsc to the DUNE_CMAKE_FLAGS")
dune.generator.exceptions.ConfigurationError: petsc has not been found during configuration of dune - please add the path to petsc to the DUNE_CMAKE_FLAGS
This is because for some reasons the creation of dune-py
is not triggered. Probably this never occured before, because the grid compilation would trigger the creation of dune-py
.
This code triggers the bug.
from dune.fem.space import lagrange
from dune.alugrid import aluConformGrid
from dune.grid import cartesianDomain
domain = cartesianDomain([0,0] , [1,1], [16,16])
view = aluConformGrid( domain )
spc = lagrange(view, order=1, storage='petsc')`
Fixed in core/dune-common!1365 (merged).
Claus-Justus Heine (2ba765ef) at 26 Mar 17:13
Andreas Dedner (7bc94280) at 26 Mar 17:13
Merge branch 'bugfix/combinedspace-tuplemapper-adaptive' into 'master'
... and 1 more commit
fem-py: using the tuple-space together with the adaptiveLeafGridView leads to compilation errors as tuplespace.hh only has a forward declaration of the class template AdaptationMethod but does not include adaptationmanager.hh to get hold of the actual definition of the template.
Question is: is this the correct place to include adaptationmanager.hh? The tuplemapper.hh is included from tuplespace.hh which is included from autogenerated C++ code generated by fempy, so it should in principled not matter ...
If this fixes the problem and the test go through then it can be merged.
fem-py: using the tuple-space together with the adaptiveLeafGridView leads to compilation errors as tuplespace.hh only has a forward declaration of the class template AdaptationMethod but does not include adaptationmanager.hh to get hold of the actual definition of the template.
Question is: is this the correct place to include adaptationmanager.hh? The tuplemapper.hh is included from tuplespace.hh which is included from autogenerated C++ code generated by fempy, so it should in principled not matter ...
Claus-Justus Heine (2ba765ef) at 26 Mar 15:30
tuplemapper + adaptive leaf grid, try fix fempy compilation error
Robert K (e7b67c52) at 26 Mar 12:01
Robert K (6986a17e) at 26 Mar 12:01
Merge branch 'cleanup/remove-unnecessary-imports' into 'master'
... and 3 more commits
stability.
Tests on github green (https://github.com/dune-project/dune-testpypi/actions/runs/8434349975). Merging.
Ok, I changed now the implementation in checkconfiguration.py
slightly and I'm not entirely happy with this patch. Least invasive.
That was my impression too. That's why I did not do it that way.
But the usage in checkconfiguration.py
is actually, get the path and make sure it exists. So one could write a special method for that.
I think this is what I will do. Then it's finally "perfect".
I don't think that would be the right place - that is just to get the right path name not to initialize anything (at least that is currently the purpose of that method). It just checks for virtual env etc. and is used anywhere the path for dune-py is needed.
Actually, if you look into packagemetadata.py
then a function like getdunePyDir
would be the corect location to put this check and initialize call. However, this getdunePyDir
is used in many places, so only God knows what will happen...
PS: Because of all these unnecessary imports I started to cleanup.
But I was also thinking that in general it would be better to add the initializeDunePy
call to the functions in checkconfiguration.py
so that importing the module does not do anything. But for now I decided against it.
Of course, this line you are referring to was removed because these functions were not used anywhere. I just forgot to push that branch in dune-grid.
Just tested. The following line does not trigger a configuration.
import dune.grid