pylbm.stencil.
Stencil
(dico)¶Create the stencil of velocities used by the scheme(s).
The numbering of the velocities follows the convention for 1D and 2D.
dico (a dictionary that contains the following key:value) –
dim : the value of the spatial dimension (1, 2 or 3)
schemes : a list of the dictionaries that contain the key:value velocities
[{‘velocities’:[…]}, {‘velocities’:[…]}, {‘velocities’:[…]}, …]
dim
¶the spatial dimension (1, 2 or 3).
int
unique_velocities
¶array of all velocities involved in the stencils. Each unique velocity appeared only once.
NumPy array
uvx
¶the x component of the unique velocities.
NumPy array
uvy
¶the y component of the unique velocities.
NumPy array
uvz
¶the z component of the unique velocities.
NumPy array
unum
¶the numbering of the unique velocities.
NumPy array
vmax
¶the maximal velocity in norm for each spatial direction.
int
vmin
¶the minimal velocity in norm for each spatial direction.
int
nstencils
¶the number of elementary stencils.
int
nv
¶the number of velocities for each elementary stencil.
list of integers
v
¶list of all the velocities for each elementary stencil.
list of velocities
vx
¶the x component of the velocities for the stencil k.
NumPy array
vy
¶the y component of the velocities for the stencil k.
NumPy array
vz
¶the z component of the velocities for the stencil k.
NumPy array
num
¶the numbering of the velocities for the stencil k.
NumPy array
nv_ptr
¶used to obtain the list of the velocities involved in a stencil. For instance, the list for the kth stencil is
v[nv_ptr[k]:nv_ptr[k+1]]
list of integers
unvtot
¶the number of unique velocities involved in the stencils.
int
Notes
The velocities for each schemes are defined as a Python list.
Examples
>>> s = Stencil({'dim': 1,
'schemes':[{'velocities': range(9)}, ],
})
>>> s
Stencil informations
* spatial dimension: 1
* maximal velocity in each direction: [4 None None]
* minimal velocity in each direction: [-4 None None]
* Informations for each elementary stencil:
stencil 0
- number of velocities: 9
- velocities: (0: 0), (1: 1), (2: -1), (3: 2), (4: -2), (5: 3), (6: -3), (7: 4), (8: -4),
>>> s = Stencil({'dim': 2,
'schemes':[{'velocities':range(9)},
{'velocities':range(50)},
],
})
>>> s
Stencil informations
* spatial dimension: 2
* maximal velocity in each direction: [4 3 None]
* minimal velocity in each direction: [-3 -3 None]
* Informations for each elementary stencil:
stencil 0
- number of velocities: 9
- velocities: (0: 0, 0), (1: 1, 0), (2: 0, 1), (3: -1, 0), (4: 0, -1), (5: 1, 1), (6: -1, 1), (7: -1, -1), (8: 1, -1),
stencil 1
- number of velocities: 50
- velocities: (0: 0, 0), (1: 1, 0), (2: 0, 1), (3: -1, 0), (4: 0, -1), (5: 1, 1), (6: -1, 1), (7: -1, -1), (8: 1, -1), (9: 2, 0), (10: 0, 2), (11: -2, 0), (12: 0, -2), (13: 2, 2), (14: -2, 2), (15: -2, -2), (16: 2, -2), (17: 2, 1), (18: 1, 2), (19: -1, 2), (20: -2, 1), (21: -2, -1), (22: -1, -2), (23: 1, -2), (24: 2, -1), (25: 3, 0), (26: 0, 3), (27: -3, 0), (28: 0, -3), (29: 3, 3), (30: -3, 3), (31: -3, -3), (32: 3, -3), (33: 3, 1), (34: 1, 3), (35: -1, 3), (36: -3, 1), (37: -3, -1), (38: -1, -3), (39: 1, -3), (40: 3, -1), (41: 3, 2), (42: 2, 3), (43: -2, 3), (44: -3, 2), (45: -3, -2), (46: -2, -3), (47: 2, -3), (48: 3, -2), (49: 4, 0),
get the x component of the unique velocities
>>> s.uvx
array([ 0, 1, 0, -1, 0, 1, -1, -1, 1, 2, 0, -2, 0, 2, -2, -2, 2,
2, 1, -1, -2, -2, -1, 1, 2, 3, 0, -3, 0, 3, -3, -3, 3, 3,
1, -1, -3, -3, -1, 1, 3, 3, 2, -2, -3, -3, -2, 2, 3, 4])
get the y component of the velocity for the second stencil
>>> s.vy[1]
array([ 0, 0, 1, 0, -1, 1, 1, -1, -1, 0, 2, 0, -2, 2, 2, -2, -2,
1, 2, 2, 1, -1, -2, -2, -1, 0, 3, 0, -3, 3, 3, -3, -3, 1,
3, 3, 1, -1, -3, -3, -1, 2, 3, 3, 2, -2, -3, -3, -2, 0])
__init__
(dico)¶Initialize self. See help(type(self)) for accurate signature.
Methods
|
Initialize self. |
|
|
|
|
|
|
|
|
|
|
|
get all the velocities for all the stencils in one array |
|
|
|
get the symetrics velocities. |
|
Raises ValueError if the value is not present. |
|
L.insert(index, object) – insert object before index |
|
check if all the velocities have their symetric. |
|
Raises IndexError if list is empty or index is out of range. |
|
Raises ValueError if the value is not present. |
|
L.reverse() – reverse IN PLACE |
|
|
|
plot the velocities |
Attributes
num[k] the numbering of the velocities for the stencil k. |
|
the numbering of the unique velocities. |
|
the number of unique velocities involved in the stencils. |
|
the x component of the unique velocities. |
|
the y component of the unique velocities. |
|
the z component of the unique velocities. |
|
the maximal velocity in norm for each spatial direction. |
|
the minimal velocity in norm for each spatial direction. |
|
vx[k] the x component of the velocities for the stencil k. |
|
vy[k] the y component of the velocities for the stencil k. |
|
vz[k] the z component of the velocities for the stencil k. |