Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
lbmpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
lbmpy
Commits
50e0d088
Commit
50e0d088
authored
Jan 2, 2018
by
Martin Bauer
Browse files
Options
Downloads
Patches
Plain Diff
DataHandling for pystencils
parent
ec91b547
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
parallel/blockiteration.py
+0
-47
0 additions, 47 deletions
parallel/blockiteration.py
parallel/boundaryhandling.py
+3
-3
3 additions, 3 deletions
parallel/boundaryhandling.py
parallel/scenarios.py
+6
-6
6 additions, 6 deletions
parallel/scenarios.py
with
9 additions
and
56 deletions
parallel/blockiteration.py
deleted
100644 → 0
+
0
−
47
View file @
ec91b547
import
numpy
as
np
import
waLBerla
as
wlb
from
pystencils.slicing
import
normalizeSlice
def
slicedBlockIteration
(
blocks
,
sliceObj
=
None
,
ghostLayers
=
1
,
sliceNormalizationGhostLayers
=
1
,
withIndexArrays
=
False
):
"""
Iterates of all blocks that have an intersection with the given slice object.
For these blocks a slice object in local block coordinates is given
:param blocks: waLBerla block data structure
:param sliceObj: a slice (i.e. rectangular subregion), can be created with makeSlice[]
:param ghostLayers: how many ghost layers are included in the local slice and the optional index arrays
:param sliceNormalizationGhostLayers: slices can have relative coordinates e.g. makeSlice[0.2, :, :]
when computing absolute values, the domain size is needed. This parameter
specifies how many ghost layers are taken into account for this operation.
:param withIndexArrays: if true index arrays [x,y,z] are yielded as last parameters. These arrays contain the
cell midpoints in global coordinates
"""
if
sliceObj
is
None
:
sliceObj
=
[
sliceObj
(
None
,
None
,
None
)]
*
3
domainCellBB
=
blocks
.
getDomainCellBB
()
domainExtent
=
[
s
+
2
*
sliceNormalizationGhostLayers
for
s
in
domainCellBB
.
size
]
sliceObj
=
normalizeSlice
(
sliceObj
,
domainExtent
)
targetCellBB
=
wlb
.
CellInterval
.
fromSlice
(
sliceObj
)
targetCellBB
.
shift
(
*
[
a
-
sliceNormalizationGhostLayers
for
a
in
domainCellBB
.
min
])
for
block
in
blocks
:
intersection
=
blocks
.
getBlockCellBB
(
block
).
getExpanded
(
ghostLayers
)
intersection
.
intersect
(
targetCellBB
)
if
intersection
.
empty
():
continue
localTargetBB
=
blocks
.
transformGlobalToLocal
(
block
,
intersection
)
localTargetBB
.
shift
(
ghostLayers
,
ghostLayers
,
ghostLayers
)
localSlice
=
localTargetBB
.
toSlice
()
if
withIndexArrays
:
meshGridParams
=
[
offset
+
0.5
+
np
.
arange
(
width
)
for
offset
,
width
in
zip
(
intersection
.
min
,
intersection
.
size
)]
indexArrays
=
np
.
meshgrid
(
*
meshGridParams
,
indexing
=
'
ij
'
)
yield
block
,
localSlice
,
indexArrays
else
:
yield
block
,
localSlice
This diff is collapsed.
Click to expand it.
parallel/boundaryhandling.py
+
3
−
3
View file @
50e0d088
import
numpy
as
np
import
numpy
as
np
import
waLBerla
as
wlb
import
waLBerla
as
wlb
from
lbmpy.boundaries.handlinginterface
import
GenericBoundaryHandling
,
FlagFieldInterface
from
lbmpy.boundaries.handlinginterface
import
GenericBoundaryHandling
,
FlagFieldInterface
from
lbmpy
.parallel.blockiteration
import
slicedBlockIteration
from
pystencils
.parallel.blockiteration
import
slicedBlockIteration
class
BoundaryHandling
(
object
):
class
BoundaryHandling
(
object
):
...
@@ -61,8 +61,8 @@ class BoundaryHandling(object):
...
@@ -61,8 +61,8 @@ class BoundaryHandling(object):
for
block
in
self
.
_blocks
:
for
block
in
self
.
_blocks
:
block
[
self
.
_boundaryId
].
reserveFlag
(
boundaryObject
)
block
[
self
.
_boundaryId
].
reserveFlag
(
boundaryObject
)
for
block
,
localSlice
in
slicedBlockIteration
(
self
.
_blocks
,
indexExpr
,
gl
,
sliceNormalizationGhostLayers
):
for
iter
in
slicedBlockIteration
(
self
.
_blocks
,
indexExpr
,
gl
,
sliceNormalizationGhostLayers
):
block
[
self
.
_boundaryId
].
setBoundary
(
boundaryObject
,
indexExpr
=
localSlice
,
maskCallback
=
maskCallback
)
block
[
self
.
_boundaryId
].
setBoundary
(
boundaryObject
,
indexExpr
=
iter
.
localSlice
,
maskCallback
=
maskCallback
)
# ----------------------------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
parallel/scenarios.py
+
6
−
6
View file @
50e0d088
...
@@ -5,7 +5,7 @@ from lbmpy.creationfunctions import createLatticeBoltzmannFunction, updateWithDe
...
@@ -5,7 +5,7 @@ from lbmpy.creationfunctions import createLatticeBoltzmannFunction, updateWithDe
switchToSymbolicRelaxationRatesForEntropicMethods
switchToSymbolicRelaxationRatesForEntropicMethods
from
lbmpy.macroscopic_value_kernels
import
compileMacroscopicValuesGetter
,
compileMacroscopicValuesSetter
from
lbmpy.macroscopic_value_kernels
import
compileMacroscopicValuesGetter
,
compileMacroscopicValuesSetter
from
lbmpy.parallel.boundaryhandling
import
BoundaryHandling
from
lbmpy.parallel.boundaryhandling
import
BoundaryHandling
from
lbmpy
.parallel.blockiteration
import
slicedBlockIteration
from
pystencils
.parallel.blockiteration
import
slicedBlockIteration
from
lbmpy.boundaries
import
NoSlip
,
UBB
from
lbmpy.boundaries
import
NoSlip
,
UBB
from
pystencils.slicing
import
sliceFromDirection
from
pystencils.slicing
import
sliceFromDirection
...
@@ -170,13 +170,13 @@ class Scenario(object):
...
@@ -170,13 +170,13 @@ class Scenario(object):
else
:
else
:
raise
ValueError
(
"
density has to be a number or a callback function
"
)
raise
ValueError
(
"
density has to be a number or a callback function
"
)
for
block
,
(
x
,
y
,
z
),
localSlice
in
slicedBlockIteration
(
self
.
blocks
,
indexExpr
,
1
,
1
):
for
it
in
slicedBlockIteration
(
self
.
blocks
,
indexExpr
,
1
,
1
):
if
density
:
if
density
:
densityArr
=
wlb
.
field
.
toArray
(
block
[
self
.
densityFieldId
],
withGhostLayers
=
True
)
densityArr
=
wlb
.
field
.
toArray
(
it
.
block
[
self
.
densityFieldId
],
withGhostLayers
=
True
)
densityArr
[
localSlice
]
=
densityCallback
(
x
,
y
,
z
)
if
densityCallback
else
densityValue
densityArr
[
it
.
localSlice
]
=
densityCallback
(
*
it
.
midpointArrays
)
if
densityCallback
else
densityValue
if
velocity
:
if
velocity
:
velArr
=
wlb
.
field
.
toArray
(
block
[
self
.
velocityFieldId
],
withGhostLayers
=
True
)
velArr
=
wlb
.
field
.
toArray
(
it
.
block
[
self
.
velocityFieldId
],
withGhostLayers
=
True
)
velArr
[
localSlice
,
:]
=
velocityCallback
(
x
,
y
,
z
)
if
velocityCallback
else
velocityValue
velArr
[
it
.
localSlice
,
:]
=
velocityCallback
(
*
it
.
midpointArrays
)
if
velocityCallback
else
velocityValue
self
.
_setMacroscpicValues
()
self
.
_setMacroscpicValues
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
sign in
to comment