The domains module : handle computation domain
Module domains provides three main objects:
Subdomain : dataclass for subdivisions of the computational domain
Obstacle : Subdomain subclass with custom boundary possibilities
Domain : Container for Subdomain objects
- class fdgrid.domains.Domain(shape, data=None)[source]
Bases:
object
Set of Subdomain objects.
- Parameters
shape (Size of the domain. Must be a 2 elements tuple) –
data (list of Subdomain objects or coordinates) –
- append(val, key=None)[source]
Append ‘val’ to the Domain object.
- Parameters
val (The object to add to the instance.) – Must be a Subdomain object or a list/tuple of Subdomain objects
key (new key for val) –
- property ix
Return list of x coordinates.
- property iz
Return list of z coordinates.
- periodic_bc(mask, axis)[source]
Arange subdomains to take into account periodic boundary condtions.
- property rx
Return list of ranges (over Subdomain x coordinates).
- property rz
Return list of ranges (over Subdomain z coordinates).
- sort(inplace=False)[source]
Sort domains.
If inplace is True, Domain is sorted inplace. If inplace is False, return a new instance.
- property sx
Return list of slices (over Subdomain x coordinates).
- property sz
Return list of slices (over Subdomain z coordinates).
- property xz
Return list of coordinates.
- class fdgrid.domains.Obstacle(xz: tuple, bc: str = '....', key: str = '', axis: int = - 1, tag: str = '')[source]
Bases:
fdgrid.domains.Subdomain
Obstacle object.
- Parameters
xz (Coordinates of the Subdomain : left, bottom, right, top) –
bc (Boundary conditions. Must be a string of 4 characters among 'W|Z|V') –
key (Key of the subdomain. Optional) –
axis (0 or 1. The direction of the subdomain if relevant. Optional.) –
tag (str. The type of Subdomain. Optional) –
- set_moving_bc(*args)[source]
Set parameters for moving bc. For each moving bc of the obstacle, you can specify the parameters as a dictionnary containing the following optional keys :
- Parameters
Note
profile argument can be:
‘sine’ : sinus profile. kw: n - wavelength (default: 2 for half period)
‘tukey’ : tapered cosine profile. kw: alpha - edge width (default: 0)
Examples
>>> obs1 = Obstacle([10, 10, 100, 100], 'VVWV')
>>> obs1.set_moving_bc({'f': 100, 'A': 2.1, 'profile': 'sine'}, {'f': 500, 'A': -1.5, 'profile': 'tukey'}, {'f': 500, 'A': 1.5 'profile': 'tukey', 'kwargs':{'alpha': 0.4}})
- class fdgrid.domains.Subdomain(xz: tuple, bc: str = '....', key: str = '', axis: int = - 1, tag: str = '')[source]
Bases:
object
Subdivision of the computation domain.
- Parameters
xz (list) – Coordinates of the Subdomain : left, bottom, right, top
bc (str) – Boundary conditions. Must be a string of 4 characters among ‘A|W|Z|P|R’
key (int, optional) – Key of the subdomain.
axis ({0, 1}, optional) – The direction of the subdomain if relevant.
tag (str, optional) – The type of Subdomain.
- property axname
Returns “x” or “z” whether axis is 0 or 1. Return 2 if both.
- property center
Returns the center of the Subdomain.