The mesh module: build grid


Module mesh provides three classes to build meshes:


class fdgrid.mesh.AdaptativeMesh(shape, step, origin=(0, 0), bc='WWWW', obstacles=None, Npml=15, stencil=11, dilatation=3.0, Nd=23, only_pml=False)[source]

Bases: fdgrid.mesh.Mesh

Build cartesian adaptative grid

Parameters
  • dilatation (float) – dilatation rate over Nd points.

  • Nd (int) – Number of point of adaptative areas.

  • only_pml (bool) – Only adapt grid in PML areas.

class fdgrid.mesh.CurvilinearMesh(shape, step, origin=(0, 0), bc='WWWW', obstacles=None, Npml=15, stencil=11, fcurvxz=<function curv>)[source]

Bases: fdgrid.mesh.Mesh

Build curvilinear grid

Parameters

fcurvxz (function, optional) – Function taking as input arguments the numerical coordinates (‘xn’, ‘yn’) and returning the physical coordinates (‘xp’, ‘zp’).

plot_physical(figsize=(9, 4), legend=False, pml=False, bc_profiles=False, probes=False, filename=None)[source]

Plot physical and numerical domains.

Parameters
  • legend (bool, optional) – Show legend.

  • N (int, optional) – Plot the grid with one point over N.

  • filename (string, optional) – Save to filename.

  • figsize (tuple, optional) – Size of the figure.

  • pml (bool, optional) – Show absorbing area in the figure.

  • bc_profiles (bool, optional) – Show velocity profiles for moving boundaries

class fdgrid.mesh.Mesh(shape, step, origin=(0, 0), bc='WWWW', obstacles=None, Npml=15, stencil=11)[source]

Bases: object

Build cartesian regular grid

Parameters
  • shape (tuple) – Size of the domain. Must be a tuple with two int objects.

  • step (tuple) – Spatial steps. Must be a tuple with two float objects.

  • origin (tuple, optional) – Origin of the grid. Must be a tuple with two int objects.

  • bc ({'[ARZPW][ARZPW][ARZPW][ARZPW]'}, optional) – Boundary conditions. Must be a 4 characters string.

  • obstacles (fdgrid.domains.Domain, optional) – Obstacles in the computation domain.

  • Npml (int, optional) – Number of points of the absorbing area (only if ‘A’ in bc).

  • stencil (int, optional) – Size of the finite difference stencil (used by nsfds2).

N(axis)[source]

Returns the number of points following axis.

du(axis)[source]

Returns the spacial base step following axis.

get_domains(only_xz=False)[source]

Get a list of computational domains.

get_obstacles()[source]

Get a list of the coordinates of all obstacles.

plot_domains(legend=False, N=4, figsize=(9, 18), bc_profiles=False, filename=None)[source]

Plot a scheme of the computation domain higlighting the subdomains.

Parameters
  • legend (bool, optional) – Show legend.

  • N (int, optional) – Plot the grid with one point over N.

  • filename (string, optional) – Save to filename.

  • figsize (tuple, optional) – Size of the figure.

  • bc_profiles (bool, optional) – Show velocity profiles for moving boundaries

plot_grid(figsize=(9, 5), N=4, axis=False, legend=False, pml=False, bc_profiles=False, probes=False, filename=None)[source]

Numerical grid representation.

Parameters
  • legend (bool, optional) – Show legend.

  • N (int, optional) – Plot the grid with one point over N.

  • filename (string, optional) – Save to filename.

  • figsize (tuple, optional) – Size of the figure.

  • pml (bool, optional) – Show absorbing area in the figure.

  • bc_profiles (bool, optional) – Show velocity profiles for moving boundaries

Important

The curves \(dx'/dx\) are not representative on the edges because of the gradient.

plot_physical(figsize=(9, 4), legend=False, pml=False, bc_profiles=False, probes=False, filename=None)[source]

Physical grid representation.

plot_xz(figsize=(9, 4), filename=None)[source]

Plot x & z axis.

Parameters
  • filename (str, optional) – Save figure to filename.

  • figsize (tuple, optional) – Size of the figure.

static show_figures()[source]

Show all figures.