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.
Parameters: | dico : a dictionary that contains the following key:value
|
---|
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])
Attributes
uvx |
the x component of the unique velocities. |
uvy |
the y component of the unique velocities. |
uvz |
the z component of the unique velocities. |
unum |
the numbering of the unique velocities. |
vmax |
the maximal velocity in norm for each spatial direction. |
vmin |
the minimal velocity in norm for each spatial direction. |
vx |
vx[k] the x component of the velocities for the stencil k. |
vy |
vy[k] the y component of the velocities for the stencil k. |
vz |
vz[k] the z component of the velocities for the stencil k. |
num |
num[k] the numbering of the velocities for the stencil k. |
unvtot |
the number of unique velocities involved in the stencils. |
dim | (int) the spatial dimension (1, 2 or 3). |
unique_velocities | (NumPy array) array of all velocities involved in the stencils. Each unique velocity appeared only once. |
nstencils | (int) the number of elementary stencils. |
nv | (list of integers) the number of velocities for each elementary stencil. |
v | (list of velocities) list of all the velocities for each elementary stencil. |
nv_ptr | (list of integers) 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]] |
Methods
append |
L.append(object) – append object to end |
count (...) |
|
extend |
L.extend(iterable) – extend list by appending elements from the iterable |
get_all_velocities () |
get all the velocities for all the stencils in one array |
get_stencil (k) |
|
get_symmetric ([axis]) |
get the symetrics velocities. |
index ((value, [start, ...) |
Raises ValueError if the value is not present. |
insert |
L.insert(index, object) – insert object before index |
is_symmetric () |
check if all the velocities have their symetric. |
pop (...) |
Raises IndexError if list is empty or index is out of range. |
remove |
L.remove(value) – remove first occurrence of value. |
reverse |
L.reverse() – reverse IN PLACE |
sort |
L.sort(cmp=None, key=None, reverse=False) – stable sort IN PLACE; |
visualize ([viewer_mod, k, unique_velocities]) |
plot the velocities |