pylbm.stencil.Stencil

class 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) –

  • 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).

Type

int

unique_velocities

array of all velocities involved in the stencils. Each unique velocity appeared only once.

Type

NumPy array

uvx

the x component of the unique velocities.

Type

NumPy array

uvy

the y component of the unique velocities.

Type

NumPy array

uvz

the z component of the unique velocities.

Type

NumPy array

unum

the numbering of the unique velocities.

Type

NumPy array

vmax

the maximal velocity in norm for each spatial direction.

Type

int

vmin

the minimal velocity in norm for each spatial direction.

Type

int

nstencils

the number of elementary stencils.

Type

int

nv

the number of velocities for each elementary stencil.

Type

list of integers

v

list of all the velocities for each elementary stencil.

Type

list of velocities

vx

the x component of the velocities for the stencil k.

Type

NumPy array

vy

the y component of the velocities for the stencil k.

Type

NumPy array

vz

the z component of the velocities for the stencil k.

Type

NumPy array

num

the numbering of the velocities for the stencil k.

Type

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]]

Type

list of integers

unvtot

the number of unique velocities involved in the stencils.

Type

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

__init__(dico)

Initialize self.

append(object)

clear()

copy()

count(value)

extend(iterable)

get_all_velocities([ischeme])

get all the velocities for all the stencils in one array

get_stencil(k)

get_symmetric([axis])

get the symetrics velocities.

index(value, [start, [stop]])

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([index])

Raises IndexError if list is empty or index is out of range.

remove(value)

Raises ValueError if the value is not present.

reverse

L.reverse() – reverse IN PLACE

sort([key, reverse])

visualize([viewer_mod, k, unique_velocities])

plot the velocities

Attributes

num

num[k] the numbering of the velocities for the stencil k.

unum

the numbering of the unique velocities.

unvtot

the number of unique velocities involved in the stencils.

uvx

the x component of the unique velocities.

uvy

the y component of the unique velocities.

uvz

the z component 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.