Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tom Harke
pystencils
Commits
8d278092
Commit
8d278092
authored
Jun 17, 2017
by
Martin Bauer
Browse files
Started implementation of parallel waLBerla based scenarios
parent
b25d4a85
Changes
2
Hide whitespace changes
Inline
Side-by-side
field.py
View file @
8d278092
...
...
@@ -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
)
...
...
slicing.py
View file @
8d278092
...
...
@@ -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
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment