Skip to content
Snippets Groups Projects
Commit 8d278092 authored by Martin Bauer's avatar Martin Bauer
Browse files

Started implementation of parallel waLBerla based scenarios

parent b25d4a85
No related merge requests found
......@@ -61,12 +61,8 @@ class Field(object):
the outer loop loops over dimension 2, the second outer over dimension 1, and the inner loop
over dimension 0. Also allowed: the strings 'numpy' (0,1,..d) or 'reverseNumpy' (d, ..., 1, 0)
"""
if isinstance(layout, str) and (layout == 'numpy' or layout.lower() == 'c'):
layout = tuple(range(spatialDimensions))
elif isinstance(layout, str) and (layout == 'reverseNumpy' or layout.lower() == 'f'):
layout = tuple(reversed(range(spatialDimensions)))
if len(layout) != spatialDimensions:
raise ValueError("Layout")
if isinstance(layout, str):
layout = layoutStringToTuple(layout, dim=spatialDimensions)
shapeSymbol = IndexedBase(TypedSymbol(Field.SHAPE_PREFIX + fieldName, Field.SHAPE_DTYPE), shape=(1,))
strideSymbol = IndexedBase(TypedSymbol(Field.STRIDE_PREFIX + fieldName, Field.STRIDE_DTYPE), shape=(1,))
totalDimensions = spatialDimensions + indexDimensions
......@@ -409,6 +405,22 @@ def createNumpyArrayWithLayout(shape, layout):
return res
def layoutStringToTuple(layoutStr, dim):
if layoutStr in ('fzyx', 'zyxf') and dim != 4:
if dim == 3:
return tuple(reversed(range(dim)))
else:
raise ValueError("Layout descriptor " + layoutStr + " only valid for dimension 4, not %d" % (dim,))
if layoutStr == "fzyx" or layoutStr == 'f' or layoutStr == 'reverseNumpy':
return tuple(reversed(range(dim)))
elif layoutStr == 'c' or layoutStr == 'numpy':
return tuple(range(dim))
elif layoutStr == 'zyxf':
return tuple(reversed(range(dim-1))) + (dim,)
raise ValueError("Unknown layout descriptor " + layoutStr)
def normalizeLayout(layout):
"""Takes a layout tuple and subtracts the minimum from all entries"""
minEntry = min(layout)
......
......@@ -19,6 +19,8 @@ def normalizeSlice(slices, sizes):
for s, size in zip(slices, sizes):
if type(s) is int:
if s < 0:
s = size + s
result.append(s)
continue
if type(s) is float:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment