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
703d4048
Commit
703d4048
authored
Apr 12, 2018
by
Martin Bauer
Browse files
Coverage tests for pystencils.Field
parent
1534a936
Changes
2
Hide whitespace changes
Inline
Side-by-side
boundaries/boundaryhandling.py
View file @
703d4048
...
...
@@ -69,7 +69,7 @@ class BoundaryHandling:
@
property
def
boundary_objects
(
self
):
return
tuple
(
self
.
_boundary_object
ToName
.
keys
())
return
tuple
(
self
.
_boundary_object
_to_boundary_info
.
keys
())
@
property
def
flag_array_name
(
self
):
...
...
@@ -97,21 +97,24 @@ class BoundaryHandling:
def
set_boundary
(
self
,
boundary_obj
,
slice_obj
=
None
,
mask_callback
=
None
,
ghost_layers
=
True
,
inner_ghost_layers
=
True
,
replace
=
True
):
"""
Sets boundary using either a rectangular slice, a boolean mask or a combination of both
:param boundary_obj: instance of a boundary object that should be set
:param slice_obj: a slice object (can be created with make_slice[]) that selects a part of the domain where
the boundary should be set. If none, the complete domain is selected which makes only sense
if a mask_callback is passed. The slice can have ':' placeholders, which are interpreted
depending on the 'inner_ghost_layers' parameter i.e. if it is True, the slice extends
into the ghost layers
:param mask_callback: callback function getting x,y (z) parameters of the cell midpoints and returning a
boolean mask with True entries where boundary cells should be set.
The x, y, z arrays have 2D/3D shape such that they can be used directly
to create the boolean return array. i.e return x < 10 sets boundaries in cells with
midpoint x coordinate smaller than 10.
:param ghost_layers see DataHandling.iterate()
"""Sets boundary using either a rectangular slice, a boolean mask or a combination of both.
Args:
boundary_obj: instance of a boundary object that should be set
slice_obj: a slice object (can be created with make_slice[]) that selects a part of the domain where
the boundary should be set. If none, the complete domain is selected which makes only sense
if a mask_callback is passed. The slice can have ':' placeholders, which are interpreted
depending on the 'inner_ghost_layers' parameter i.e. if it is True, the slice extends
into the ghost layers
mask_callback: callback function getting x,y (z) parameters of the cell midpoints and returning a
boolean mask with True entries where boundary cells should be set.
The x, y, z arrays have 2D/3D shape such that they can be used directly
to create the boolean return array. i.e return x < 10 sets boundaries in cells with
midpoint x coordinate smaller than 10.
ghost_layers: see DataHandling.iterate()
inner_ghost_layers: see DataHandling.iterate()
replace: by default all other flags are erased in the cells where the boundary is set. To add a
boundary condition, set this replace flag to False
"""
if
isinstance
(
boundary_obj
,
str
)
and
boundary_obj
.
lower
()
==
'domain'
:
flag
=
self
.
flag_interface
.
domain_flag
...
...
field.py
View file @
703d4048
...
...
@@ -393,11 +393,7 @@ class Field(object):
@
property
def
offsets
(
self
):
return
self
.
_offsets
@
offsets
.
setter
def
offsets
(
self
,
value
):
self
.
_offsets
=
value
return
tuple
(
self
.
_offsets
)
@
property
def
required_ghost_layers
(
self
):
...
...
@@ -415,9 +411,6 @@ class Field(object):
def
index
(
self
):
return
self
.
_index
def
get_neighbor
(
self
,
*
offsets
)
->
'Field.Access'
:
return
Field
.
Access
(
self
.
field
,
offsets
,
self
.
index
)
def
neighbor
(
self
,
coord_id
:
int
,
offset
:
Sequence
[
int
])
->
'Field.Access'
:
offset_list
=
list
(
self
.
offsets
)
offset_list
[
coord_id
]
+=
offset
...
...
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