Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pycodegen
pystencils
Commits
1e02ab8f
Commit
1e02ab8f
authored
Dec 17, 2019
by
Michael Kuron
Browse files
fix staggered field access prettyprinter
parent
37aff58b
Pipeline
#20570
passed with stage
in 12 minutes and 40 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
pystencils/field.py
View file @
1e02ab8f
...
...
@@ -845,7 +845,7 @@ class Field(AbstractField):
assert
FieldType
.
is_staggered
(
self
.
_field
)
neighbor
=
self
.
_field
.
staggered_stencil
[
index
]
neighbor
=
direction_string_to_offset
(
neighbor
,
self
.
_field
.
spatial_dimensions
)
return
[(
o
-
sp
.
Rational
(
int
(
neighbor
[
i
]),
2
))
for
i
,
o
in
enumerate
(
offsets
)]
return
[(
o
+
sp
.
Rational
(
int
(
neighbor
[
i
]),
2
))
for
i
,
o
in
enumerate
(
offsets
)]
def
_latex
(
self
,
_
):
n
=
self
.
_field
.
latex_name
if
self
.
_field
.
latex_name
else
self
.
_field
.
name
...
...
pystencils_tests/test_field.py
View file @
1e02ab8f
...
...
@@ -154,12 +154,18 @@ def test_staggered():
for
j
in
range
(
2
)]
for
i
in
range
(
2
)])
# D2Q9
k
=
ps
.
fields
(
'k(4) : double[2D]'
,
field_type
=
FieldType
.
STAGGERED
)
assert
k
[
1
,
1
](
2
)
==
k
.
staggered_access
(
"NE"
)
assert
k
[
0
,
0
](
2
)
==
k
.
staggered_access
(
"SW"
)
assert
k
[
0
,
0
](
3
)
==
k
.
staggered_access
(
"NW"
)
k1
,
k2
=
ps
.
fields
(
'k1(4), k2(2) : double[2D]'
,
field_type
=
FieldType
.
STAGGERED
)
assert
k1
[
1
,
1
](
2
)
==
k1
.
staggered_access
(
"NE"
)
assert
k1
[
0
,
0
](
2
)
==
k1
.
staggered_access
(
"SW"
)
assert
k1
[
0
,
0
](
3
)
==
k1
.
staggered_access
(
"NW"
)
a
=
k1
.
staggered_access
(
"NE"
)
assert
a
.
_staggered_offset
(
a
.
offsets
,
a
.
index
[
0
])
==
[
sp
.
Rational
(
1
,
2
),
sp
.
Rational
(
1
,
2
)]
a
=
k1
.
staggered_access
(
"SW"
)
assert
a
.
_staggered_offset
(
a
.
offsets
,
a
.
index
[
0
])
==
[
sp
.
Rational
(
-
1
,
2
),
sp
.
Rational
(
-
1
,
2
)]
a
=
k1
.
staggered_access
(
"NW"
)
assert
a
.
_staggered_offset
(
a
.
offsets
,
a
.
index
[
0
])
==
[
sp
.
Rational
(
-
1
,
2
),
sp
.
Rational
(
1
,
2
)]
# sign reversed when using as flux field
r
=
ps
.
fields
(
'r(2) : double[2D]'
,
field_type
=
FieldType
.
STAGGERED_FLUX
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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