Skip to content
Snippets Groups Projects
Commit a8214c84 authored by René Fritze's avatar René Fritze Committed by René Milk
Browse files

[py] adds a factory for grid types

parent 8667cb3f
No related branches found
No related tags found
No related merge requests found
......@@ -36,9 +36,6 @@ dune_enable_all_packages(INCLUDE_DIRS ${dune-xt-grid_SOURCE_DIR}/dune MODULE_LIB
add_header_listing()
make_dependent_modules_sys_included()
add_subdirectory(dune)
add_subdirectory(doc)
include(DuneXTInstallPythonPackage)
# this symlinks all files in python/ to the binary dir and install into the virtualenv from there thereby making the
# compiled extensions directly usable from the venv
......@@ -48,6 +45,10 @@ include_dependent_binary_python_dirs()
add_subdirectory(python)
dxt_add_make_dependent_bindings(dune-xt-common dune-xt-la)
# this needs to come after the python install so we can use it in test generation
add_subdirectory(dune)
add_subdirectory(doc)
# enable headercheck
add_definitions("-DENABLE_HEADERCHECK=1")
add_format(${CMAKE_CURRENT_SOURCE_DIR})
......
from collections import namedtuple
arguments = {'alu': namedtuple('alu_args', 'dim element_type refinement'),
'yasp': namedtuple('yasp_args', 'dim'),
'ug': namedtuple('ug_args', 'dim'),
'alberta': namedtuple('alberta_args', 'dim')}
templates = { 'alu': 'Dune::ALUGrid<{dim},{dim},Dune::{element_type},Dune::{refinement}>',
'yasp': 'Dune::YaspGrid<{dim},Dune::EquidistantOffsetCoordinates<double,{dim}>>',
'ug': 'Dune::UGGrid<{}>',
'alberta': 'Dune::AlbertaGrid<{dim},{dim}>'}
guards = { 'alu': 'dune-alugrid',
'yasp': 'dune-grid',
'ug': 'dune-uggrid',
'alberta': 'ALBERTA_FOUND'}
def _is_usable(grid, cache):
return cache[guards[grid]]
def all_args(dims):
two_and_three = [f for f in dims if 1 < f < 4]
return {'alu': [arguments['alu'](d, 'simplex', e) for e in ('nonconforming', 'conforming') for d in two_and_three] +
[arguments['alu'](d, 'cube', 'nonconforming') for d in two_and_three],
'yasp': [arguments['yasp'](d) for d in dims if d > 0],
'ug': [arguments['ug'](d) for d in two_and_three],
'alberta': [arguments['alberta'](d) for d in two_and_three]}
def all_types(cache, dims, gridnames=None):
gridnames = gridnames or templates.keys()
return [templates[grid].format(**arg._asdict()) \
for grid in gridnames if _is_usable(grid, cache) \
for arg in all_args(dims)[grid]]
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