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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
lbmpy
Commits
340819af
Commit
340819af
authored
8 years ago
by
Martin Bauer
Browse files
Options
Downloads
Patches
Plain Diff
lbmpy: Removed unnecessary conversion of boundary index list
parent
04d4d09c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
boundaries/boundaryhandling.py
+3
-14
3 additions, 14 deletions
boundaries/boundaryhandling.py
boundaries/createindexlist.py
+12
-5
12 additions, 5 deletions
boundaries/createindexlist.py
with
15 additions
and
19 deletions
boundaries/boundaryhandling.py
+
3
−
14
View file @
340819af
...
@@ -72,7 +72,6 @@ class BoundaryHandling(object):
...
@@ -72,7 +72,6 @@ class BoundaryHandling(object):
for
boundaryIdx
,
boundaryFunc
in
enumerate
(
self
.
_boundaryFunctions
):
for
boundaryIdx
,
boundaryFunc
in
enumerate
(
self
.
_boundaryFunctions
):
idxField
=
createBoundaryIndexList
(
self
.
flagField
,
self
.
_lbMethod
.
stencil
,
idxField
=
createBoundaryIndexList
(
self
.
flagField
,
self
.
_lbMethod
.
stencil
,
2
**
boundaryIdx
,
self
.
_fluidFlag
,
self
.
_ghostLayers
)
2
**
boundaryIdx
,
self
.
_fluidFlag
,
self
.
_ghostLayers
)
idxField
=
transformIndexListToStruct
(
idxField
)
ast
=
generateBoundaryHandling
(
self
.
_symbolicPdfField
,
idxField
,
self
.
_lbMethod
,
boundaryFunc
)
ast
=
generateBoundaryHandling
(
self
.
_symbolicPdfField
,
idxField
,
self
.
_lbMethod
,
boundaryFunc
)
if
self
.
_target
==
'
cpu
'
:
if
self
.
_target
==
'
cpu
'
:
...
@@ -134,23 +133,13 @@ class LbmMethodInfo(CustomCppCode):
...
@@ -134,23 +133,13 @@ class LbmMethodInfo(CustomCppCode):
super
(
LbmMethodInfo
,
self
).
__init__
(
code
,
symbolsRead
=
set
(),
symbolsDefined
=
symbolsDefined
)
super
(
LbmMethodInfo
,
self
).
__init__
(
code
,
symbolsRead
=
set
(),
symbolsDefined
=
symbolsDefined
)
def
transformIndexListToStruct
(
arr
):
#TODO create in correct form right away
dim
=
arr
.
shape
[
-
1
]
-
1
coordinateNames
=
[
'
x
'
,
'
y
'
,
'
z
'
][:
dim
]
dataTypeInfo
=
[(
name
,
np
.
int
)
for
name
in
coordinateNames
]
+
[(
'
dir
'
,
np
.
int
)]
indexArrStruct
=
np
.
empty
((
arr
.
shape
[
0
]),
dtype
=
np
.
dtype
(
dataTypeInfo
))
for
idx
,
name
in
enumerate
(
coordinateNames
):
indexArrStruct
[
name
]
=
arr
[:,
idx
]
indexArrStruct
[
'
dir
'
]
=
arr
[:,
-
1
]
return
indexArrStruct
def
generateBoundaryHandling
(
pdfField
,
indexArr
,
lbMethod
,
boundaryFunctor
):
def
generateBoundaryHandling
(
pdfField
,
indexArr
,
lbMethod
,
boundaryFunctor
):
indexField
=
Field
.
createFromNumpyArray
(
"
indexField
"
,
indexArr
)
indexField
=
Field
.
createFromNumpyArray
(
"
indexField
"
,
indexArr
)
elements
=
[
LbmMethodInfo
(
lbMethod
)]
elements
=
[
LbmMethodInfo
(
lbMethod
)]
boundaryEqList
=
boundaryFunctor
(
pdfField
,
indexField
[
0
](
'
dir
'
),
lbMethod
)
dirSymbol
=
TypedSymbol
(
"
dir
"
,
indexArr
.
dtype
.
fields
[
'
dir
'
][
0
])
boundaryEqList
=
[
sp
.
Eq
(
dirSymbol
,
indexField
[
0
](
'
dir
'
))]
boundaryEqList
+=
boundaryFunctor
(
pdfField
,
dirSymbol
,
lbMethod
)
if
type
(
boundaryEqList
)
is
tuple
:
if
type
(
boundaryEqList
)
is
tuple
:
boundaryEqList
,
additionalNodes
=
boundaryEqList
boundaryEqList
,
additionalNodes
=
boundaryEqList
elements
+=
boundaryEqList
elements
+=
boundaryEqList
...
...
This diff is collapsed.
Click to expand it.
boundaries/createindexlist.py
+
12
−
5
View file @
340819af
...
@@ -13,6 +13,9 @@ except Exception:
...
@@ -13,6 +13,9 @@ except Exception:
def
_createBoundaryIndexListPython
(
flagFieldArr
,
nrOfGhostLayers
,
boundaryMask
,
fluidMask
,
stencil
):
def
_createBoundaryIndexListPython
(
flagFieldArr
,
nrOfGhostLayers
,
boundaryMask
,
fluidMask
,
stencil
):
coordinateNames
=
(
"
x
"
,
"
y
"
,
"
z
"
)[:
len
(
flagFieldArr
.
shape
)]
indexArrDtype
=
np
.
dtype
([(
name
,
np
.
int32
)
for
name
in
coordinateNames
]
+
[(
'
dir
'
,
np
.
int32
)])
result
=
[]
result
=
[]
gl
=
nrOfGhostLayers
gl
=
nrOfGhostLayers
for
cell
in
itertools
.
product
(
*
[
range
(
gl
,
i
-
gl
)
for
i
in
flagFieldArr
.
shape
]):
for
cell
in
itertools
.
product
(
*
[
range
(
gl
,
i
-
gl
)
for
i
in
flagFieldArr
.
shape
]):
...
@@ -21,20 +24,24 @@ def _createBoundaryIndexListPython(flagFieldArr, nrOfGhostLayers, boundaryMask,
...
@@ -21,20 +24,24 @@ def _createBoundaryIndexListPython(flagFieldArr, nrOfGhostLayers, boundaryMask,
for
dirIdx
,
direction
in
enumerate
(
stencil
):
for
dirIdx
,
direction
in
enumerate
(
stencil
):
neighborCell
=
tuple
([
cell_i
+
dir_i
for
cell_i
,
dir_i
in
zip
(
cell
,
direction
)])
neighborCell
=
tuple
([
cell_i
+
dir_i
for
cell_i
,
dir_i
in
zip
(
cell
,
direction
)])
if
flagFieldArr
[
neighborCell
]
&
boundaryMask
:
if
flagFieldArr
[
neighborCell
]
&
boundaryMask
:
result
.
append
(
list
(
cell
)
+
[
dirIdx
]
)
result
.
append
(
cell
+
(
dirIdx
,)
)
return
np
.
array
(
result
,
dtype
=
np
.
int32
)
return
np
.
array
(
result
,
dtype
=
indexArrDtype
)
def
createBoundaryIndexList
(
flagField
,
stencil
,
boundaryMask
,
fluidMask
,
nrOfGhostLayers
=
1
):
def
createBoundaryIndexList
(
flagField
,
stencil
,
boundaryMask
,
fluidMask
,
nrOfGhostLayers
=
1
):
dim
=
len
(
flagField
.
shape
)
coordinateNames
=
(
"
x
"
,
"
y
"
,
"
z
"
)[:
dim
]
indexArrDtype
=
np
.
dtype
([(
name
,
np
.
int32
)
for
name
in
coordinateNames
]
+
[(
'
dir
'
,
np
.
int32
)])
if
cythonFuncsAvailable
:
if
cythonFuncsAvailable
:
stencil
=
np
.
array
(
stencil
,
dtype
=
np
.
int32
)
stencil
=
np
.
array
(
stencil
,
dtype
=
np
.
int32
)
if
len
(
flagField
.
shape
)
==
2
:
if
dim
==
2
:
idxList
=
createBoundaryIndexList2D
(
flagField
,
nrOfGhostLayers
,
boundaryMask
,
fluidMask
,
stencil
)
idxList
=
createBoundaryIndexList2D
(
flagField
,
nrOfGhostLayers
,
boundaryMask
,
fluidMask
,
stencil
)
elif
len
(
flagField
.
shape
)
==
3
:
elif
dim
==
3
:
idxList
=
createBoundaryIndexList3D
(
flagField
,
nrOfGhostLayers
,
boundaryMask
,
fluidMask
,
stencil
)
idxList
=
createBoundaryIndexList3D
(
flagField
,
nrOfGhostLayers
,
boundaryMask
,
fluidMask
,
stencil
)
else
:
else
:
raise
ValueError
(
"
Flag field has to be a 2 or 3 dimensional numpy array
"
)
raise
ValueError
(
"
Flag field has to be a 2 or 3 dimensional numpy array
"
)
return
np
.
array
(
idxList
,
dtype
=
np
.
int32
)
return
np
.
array
(
idxList
,
dtype
=
indexArrDtype
)
else
:
else
:
return
_createBoundaryIndexListPython
(
flagField
,
nrOfGhostLayers
,
boundaryMask
,
fluidMask
,
stencil
)
return
_createBoundaryIndexListPython
(
flagField
,
nrOfGhostLayers
,
boundaryMask
,
fluidMask
,
stencil
)
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
register
or
sign in
to comment