Skip to content
Snippets Groups Projects
Commit 4c84ea70 authored by dedner's avatar dedner
Browse files

reintroduce dune-corepy testing for existence of add_python_target

Also removed _create.py script moving the registry into the __init__ file
parent 64386ee5
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,9 @@ add_subdirectory(lib)
add_subdirectory(examples EXCLUDE_FROM_ALL)
add_subdirectory(utils)
#add_subdirectory(python)
if (COMMAND add_python_target)
add_subdirectory(python)
endif()
# finalize the dune project, e.g., generate config.h etc.
finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
add_python_targets(alugrid
__init__
_create
_grids
)
from ._grids import *
registry = dict()
registry["grid"] = {
"ALU" : aluGrid,
"ALUConform" : aluConformGrid,
"ALUCube" : aluCubeGrid,
"ALUSimplex" : aluSimplexGrid,
}
from ._grids import *
registry = dict()
registry["grid"] = {
"ALU" : aluGrid,
"ALUConform" : aluConformGrid,
"ALUCube" : aluCubeGrid,
"ALUSimplex" : aluSimplexGrid,
}
from __future__ import absolute_import, division, print_function, unicode_literals
from dune.grid.grid_generator import module
def create(constructor, dimgrid, dimworld=None, elementType=None, **parameters):
if not dimworld:
dimworld = dimgrid
if not elementType:
elementType = parameters.pop("type")
refinement = parameters["refinement"]
if refinement == "conforming":
refinement="Dune::conforming"
elif refinement == "nonconforming":
refinement="Dune::nonconforming"
if not (2<=dimworld and dimworld<=3):
raise KeyError(\
"Parameter error in ALUGrid with "+
"dimworld=" + str(dimworld) + ": " +\
"dimworld has to be either 2 or 3")
if not (2<=dimgrid and dimgrid<=3):
raise KeyError(\
"Parameter error in ALUGrid with "+
"dimgrid=" + str(dimgrid) + ": " +\
"dimgrid has to be either 2 or 3")
if not (dimgrid==dimworld or dimgrid+1==dimworld):
raise KeyError(\
"Parameter error in ALUGrid with "+
"dimworld=" + str(dimworld) + " and dimgrid=" + str(dimgrid) + ": " +\
"dimworld has to be either equal to dimgrid or "+
"dimworld has to be equal to dimgrid+1")
if refinement=="Dune::conforming" and elementType=="Dune::cube":
raise KeyError(\
"Parameter error in ALUGrid with "+
"refinement=" + refinement + " and type=" + elementType + ": " +\
"conforming refinement is only available with simplex element type")
typeName = "Dune::ALUGrid< " + str(dimgrid) + ", " + str(dimworld) + ", " +\
elementType + ", " + refinement + " >"
includes = [ "dune/alugrid/grid.hh", "dune/alugrid/dgf.hh" ]
gridModule = module(includes, typeName)
return gridModule.LeafGrid( gridModule.reader(constructor) )
if __name__ == "__main__":
import doctest
doctest.testmod(optionflags=doctest.ELLIPSIS)
from __future__ import absolute_import, division, print_function, unicode_literals
from dune.grid.grid_generator import module
from . import alu
def create(constructor, dimgrid, dimworld=None, **parameters):
parameters["type"] = "Dune::simplex"
parameters["refinement"] = "Dune::conforming"
return alu.create(constructor, dimgrid, dimworld, **parameters)
if __name__ == "__main__":
import doctest
doctest.testmod(optionflags=doctest.ELLIPSIS)
from __future__ import absolute_import, division, print_function, unicode_literals
from dune.grid.grid_generator import module
from . import alu
def create(constructor, dimgrid, dimworld=None,
**parameters):
parameters["type"] = "Dune::cube"
parameters["refinement"] = "Dune::nonconforming"
return alu.create(constructor, dimgrid, dimworld, **parameters)
if __name__ == "__main__":
import doctest
doctest.testmod(optionflags=doctest.ELLIPSIS)
from __future__ import absolute_import, division, print_function, unicode_literals
from dune.grid.grid_generator import module
from . import alu
def create(constructor, dimgrid, dimworld=None, refinement="Dune::nonconforming",
**parameters):
parameters["type"] = "Dune::simplex"
parameters["refinement"] = refinement
return alu.create(constructor, dimgrid, dimworld, **parameters)
if __name__ == "__main__":
import doctest
doctest.testmod(optionflags=doctest.ELLIPSIS)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment