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
722bfe4d
Commit
722bfe4d
authored
4 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Implemented eq for all boundaries
parent
d3e266d6
No related branches found
No related tags found
1 merge request
!81
add DiffusionDirichlet boundary condition
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lbmpy/boundaries/boundaryconditions.py
+48
-6
48 additions, 6 deletions
lbmpy/boundaries/boundaryconditions.py
lbmpy_tests/test_boundary_handling.py
+43
-2
43 additions, 2 deletions
lbmpy_tests/test_boundary_handling.py
with
91 additions
and
8 deletions
lbmpy/boundaries/boundaryconditions.py
+
48
−
6
View file @
722bfe4d
...
...
@@ -79,11 +79,6 @@ class LbBoundary:
def
name
(
self
,
new_value
):
self
.
_name
=
new_value
def
__eq__
(
self
,
other
):
if
isinstance
(
other
,
type
(
self
)):
return
self
.
__dict__
==
other
.
__dict__
return
False
# end class Boundary
...
...
@@ -103,7 +98,13 @@ class NoSlip(LbBoundary):
def
__call__
(
self
,
f_out
,
f_in
,
dir_symbol
,
inv_dir
,
lb_method
,
index_field
):
return
Assignment
(
f_in
(
inv_dir
[
dir_symbol
]),
f_out
(
dir_symbol
))
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
NoSlip
):
return
False
return
self
.
name
==
other
.
name
# end class NoSlip
...
...
@@ -208,6 +209,13 @@ class UBB(LbBoundary):
else
:
return
[
Assignment
(
f_in
(
inv_dir
[
direction
]),
f_out
(
direction
)
-
vel_term
)]
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
UBB
):
return
False
return
self
.
name
==
other
.
name
# end class UBB
...
...
@@ -254,6 +262,13 @@ class SimpleExtrapolationOutflow(LbBoundary):
tangential_offset
=
tuple
(
offset
-
normal
for
offset
,
normal
in
zip
(
neighbor_offset
,
self
.
normal_direction
))
return
Assignment
(
f_in
.
center
(
inv_dir
[
dir_symbol
]),
f_out
[
tangential_offset
](
inv_dir
[
dir_symbol
]))
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
SimpleExtrapolationOutflow
):
return
False
return
self
.
name
==
other
.
name
# end class SimpleExtrapolationOutflow
...
...
@@ -401,6 +416,12 @@ class ExtrapolationOutflow(LbBoundary):
return
AssignmentCollection
(
boundary_assignments
,
subexpressions
=
subexpressions
)
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
ExtrapolationOutflow
):
return
False
return
self
.
name
==
other
.
name
# end class ExtrapolationOutflow
...
...
@@ -454,6 +475,11 @@ class FixedDensity(LbBoundary):
return
subexpressions
+
[
Assignment
(
f_in
(
inv_dir
[
dir_symbol
]),
2
*
eq_component
-
f_out
(
dir_symbol
))]
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
FixedDensity
):
return
False
return
self
.
name
==
other
.
name
# end class FixedDensity
...
...
@@ -489,6 +515,11 @@ class DiffusionDirichlet(LbBoundary):
return
[
Assignment
(
f_in
(
inv_dir
[
dir_symbol
]),
2
*
w_dir
*
self
.
concentration
-
f_out
(
dir_symbol
))]
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
DiffusionDirichlet
):
return
False
return
self
.
name
==
other
.
name
# end class DiffusionDirichlet
...
...
@@ -513,6 +544,12 @@ class NeumannByCopy(LbBoundary):
return
[
Assignment
(
f_in
(
inv_dir
[
dir_symbol
]),
f_out
(
inv_dir
[
dir_symbol
])),
Assignment
(
f_out
[
neighbour_offset
](
dir_symbol
),
f_out
(
dir_symbol
))]
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
NeumannByCopy
):
return
False
return
self
.
name
==
other
.
name
# end class NeumannByCopy
...
...
@@ -545,4 +582,9 @@ class StreamInConstant(LbBoundary):
return
[
Assignment
(
f_in
(
inv_dir
[
dir_symbol
]),
self
.
constant
),
Assignment
(
f_out
[
neighbour_offset
](
dir_symbol
),
self
.
constant
)]
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
StreamInConstant
):
return
False
return
self
.
name
==
other
.
name
# end class StreamInConstant
This diff is collapsed.
Click to expand it.
lbmpy_tests/test_boundary_handling.py
+
43
−
2
View file @
722bfe4d
import
numpy
as
np
import
pytest
from
lbmpy.boundaries
import
UBB
,
NeumannByCopy
,
NoSlip
,
StreamInConstant
from
lbmpy.boundaries
import
NoSlip
,
UBB
,
SimpleExtrapolationOutflow
,
ExtrapolationOutflow
,
\
FixedDensity
,
DiffusionDirichlet
,
NeumannByCopy
,
StreamInConstant
from
lbmpy.boundaries.boundaryhandling
import
LatticeBoltzmannBoundaryHandling
from
lbmpy.creationfunctions
import
create_lb_function
from
lbmpy.creationfunctions
import
create_lb_function
,
create_lb_method
from
lbmpy.geometry
import
add_box_boundary
from
lbmpy.lbstep
import
LatticeBoltzmannStep
from
lbmpy.stencils
import
get_stencil
from
pystencils
import
create_data_handling
,
make_slice
...
...
@@ -109,3 +111,42 @@ def test_exotic_boundaries():
step
.
boundary_handling
.
set_boundary
(
StreamInConstant
(
0
),
make_slice
[
0
,
:])
step
.
run
(
100
)
assert
np
.
max
(
step
.
velocity
[:,
:,
:])
<
1e-13
def
test_boundary_utility_functions
():
stencil
=
get_stencil
(
"
D2Q9
"
)
method
=
create_lb_method
(
stencil
=
stencil
)
noslip
=
NoSlip
(
"
noslip
"
)
assert
noslip
==
NoSlip
(
"
noslip
"
)
assert
not
noslip
==
NoSlip
(
"
test
"
)
ubb
=
UBB
((
0
,
0
),
name
=
"
ubb
"
)
assert
ubb
==
UBB
((
0
,
0
),
name
=
"
ubb
"
)
assert
not
noslip
==
UBB
((
0
,
0
),
name
=
"
test
"
)
simple_extrapolation
=
SimpleExtrapolationOutflow
(
normal_direction
=
stencil
[
4
],
stencil
=
stencil
,
name
=
"
simple
"
)
assert
simple_extrapolation
==
SimpleExtrapolationOutflow
(
normal_direction
=
stencil
[
4
],
stencil
=
stencil
,
name
=
"
simple
"
)
assert
not
simple_extrapolation
==
SimpleExtrapolationOutflow
(
normal_direction
=
stencil
[
4
],
stencil
=
stencil
,
name
=
"
test
"
)
outflow
=
ExtrapolationOutflow
(
normal_direction
=
stencil
[
4
],
lb_method
=
method
,
name
=
"
outflow
"
)
assert
outflow
==
ExtrapolationOutflow
(
normal_direction
=
stencil
[
4
],
lb_method
=
method
,
name
=
"
outflow
"
)
assert
not
outflow
==
ExtrapolationOutflow
(
normal_direction
=
stencil
[
4
],
lb_method
=
method
,
name
=
"
test
"
)
density
=
FixedDensity
(
density
=
1.0
,
name
=
"
fixedDensity
"
)
assert
density
==
FixedDensity
(
density
=
1.0
,
name
=
"
fixedDensity
"
)
assert
not
density
==
FixedDensity
(
density
=
1.0
,
name
=
"
test
"
)
diffusion
=
DiffusionDirichlet
(
concentration
=
1.0
,
name
=
"
diffusion
"
)
assert
diffusion
==
DiffusionDirichlet
(
concentration
=
1.0
,
name
=
"
diffusion
"
)
assert
not
diffusion
==
DiffusionDirichlet
(
concentration
=
1.0
,
name
=
"
test
"
)
neumann
=
NeumannByCopy
(
name
=
"
Neumann
"
)
assert
neumann
==
NeumannByCopy
(
name
=
"
Neumann
"
)
assert
not
neumann
==
NeumannByCopy
(
name
=
"
Neumann
"
)
stream
=
StreamInConstant
(
constant
=
1.0
,
name
=
"
stream
"
)
assert
stream
==
StreamInConstant
(
constant
=
1.0
,
name
=
"
stream
"
)
assert
not
stream
==
StreamInConstant
(
constant
=
1.0
,
name
=
"
stream
"
)
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