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
Jonas Plewinski
pystencils
Commits
afc933d9
Commit
afc933d9
authored
Apr 13, 2018
by
Martin Bauer
Browse files
lbmpy geometry: documentation and tests
parent
1fcc24b8
Changes
4
Hide whitespace changes
Inline
Side-by-side
__init__.py
View file @
afc933d9
import
pystencils.sympy_gmpy_bug_workaround
from
pystencils.field
import
Field
,
FieldType
from
pystencils.data_types
import
TypedSymbol
from
pystencils.slicing
import
make_slice
from
pystencils.kernelcreation
import
create_kernel
,
create_indexed_kernel
from
pystencils.display_utils
import
show_code
,
to_dot
from
pystencils.assignment_collection
import
AssignmentCollection
from
pystencils.assignment
import
Assignment
from
pystencils.sympyextensions
import
SymbolCreator
"""Module to generate stencil kernels in C or CUDA using sympy expressions and call them as Python functions"""
from
.
import
sympy_gmpy_bug_workaround
from
.field
import
Field
,
FieldType
from
.data_types
import
TypedSymbol
from
.slicing
import
make_slice
from
.kernelcreation
import
create_kernel
,
create_indexed_kernel
from
.display_utils
import
show_code
,
to_dot
from
.assignment_collection
import
AssignmentCollection
from
.assignment
import
Assignment
from
.sympyextensions
import
SymbolCreator
__all__
=
[
'Field'
,
'FieldType'
,
'TypedSymbol'
,
...
...
field.py
View file @
afc933d9
...
...
@@ -153,7 +153,7 @@ class Field(object):
@
staticmethod
def
create_fixed_size
(
field_name
:
str
,
shape
:
Tuple
[
int
,
...],
index_dimensions
:
int
=
0
,
dtype
=
np
.
float64
,
layout
:
str
=
'numpy'
,
strides
:
Optional
[
Sequence
[
int
]]
=
None
)
->
'Field'
:
dtype
=
np
.
float64
,
layout
:
str
=
'numpy'
,
strides
:
Optional
[
Sequence
[
int
]]
=
None
)
->
'Field'
:
"""
Creates a field with fixed sizes i.e. can be called only with arrays of the same size and layout
...
...
@@ -192,7 +192,7 @@ class Field(object):
def
__init__
(
self
,
field_name
,
field_type
,
dtype
,
layout
,
shape
,
strides
):
"""Do not use directly. Use static create* methods"""
self
.
_field
N
ame
=
field_name
self
.
_field
_n
ame
=
field_name
assert
isinstance
(
field_type
,
FieldType
)
self
.
field_type
=
field_type
self
.
_dtype
=
create_type
(
dtype
)
...
...
@@ -218,7 +218,7 @@ class Field(object):
@
property
def
name
(
self
)
->
str
:
return
self
.
_field
N
ame
return
self
.
_field
_n
ame
@
property
def
spatial_shape
(
self
)
->
Tuple
[
int
,
...]:
...
...
@@ -249,7 +249,7 @@ class Field(object):
return
self
.
_dtype
def
__repr__
(
self
):
return
self
.
_field
N
ame
return
self
.
_field
_n
ame
def
neighbor
(
self
,
coord_id
,
offset
):
offset_list
=
[
0
]
*
self
.
spatial_dimensions
...
...
@@ -294,7 +294,7 @@ class Field(object):
return
Field
.
Access
(
self
,
center
)(
*
args
,
**
kwargs
)
def
__hash__
(
self
):
return
hash
((
self
.
_layout
,
self
.
shape
,
self
.
strides
,
self
.
_dtype
,
self
.
field_type
,
self
.
_field
N
ame
))
return
hash
((
self
.
_layout
,
self
.
shape
,
self
.
strides
,
self
.
_dtype
,
self
.
field_type
,
self
.
_field
_n
ame
))
def
__eq__
(
self
,
other
):
self_tuple
=
(
self
.
shape
,
self
.
strides
,
self
.
name
,
self
.
dtype
,
self
.
field_type
)
...
...
@@ -576,8 +576,7 @@ def offset_component_to_direction_string(coordinate_id: int, value: int) -> str:
"""
name_components
=
((
'W'
,
'E'
),
# west, east
(
'S'
,
'N'
),
# south, north
(
'B'
,
'T'
),
# bottom, top
)
(
'B'
,
'T'
))
# bottom, top
if
value
==
0
:
result
=
""
elif
value
<
0
:
...
...
sympy_gmpy_bug_workaround.py
View file @
afc933d9
...
...
@@ -14,3 +14,5 @@ try:
"MPMATH_NOGMPY=1"
)
except
ImportError
:
pass
__all__
=
[]
vtk.py
View file @
afc933d9
...
...
@@ -27,8 +27,8 @@ def image_to_vtk(path, cell_data, origin=(0.0, 0.0, 0.0), spacing=(1.0, 1.0, 1.0
>>> with TemporaryDirectory() as tmp_dir:
... path = os.path.join(tmp_dir, 'out')
... size = (20, 20, 20)
... res_file = image_to_vtk(path, cell_data={'
scala
r': np.
zeros(size
),
... '
vecto
r':
(
np.
ones(size), np.ones(size), np.ones(size)
)
... res_file = image_to_vtk(path, cell_data={'
vecto
r':
(
np.
ones(size), np.ones(size), np.ones(size)
),
... '
scala
r': np.
zeros(size
)
... })
"""
...
...
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