CSRectGrid

Rectilinear Grid Class for CSXCAD

class CSXCAD.CSRectGrid.CSRectGrid

Rectilinear Grid Class for CSXCAD. The grid can be defined e.g. as a Cartesian or cylindrical mesh and can hold mesh lines in the 3 fundamental directions. E.g. x,y and z for the Cartesian and rho, a and z for the cylindrical mesh.

Parameters:

CoordSystem – define the coordinate system (default 0 : Cartesian)

AddLine(ny, lines)

Add an array of lines. This will not clear the previous defined lines in the given direction.

Parameters:
  • ny – int or str – direction definition

  • lines – array – list of lines to be added in the given direction

Clear()

Clear all lines and delta unit.

ClearLines(ny)

Clear all lines in a given direction ny.

Parameters:

ny – int or str – direction definition

GetDeltaUnit()

Get the drawing unit for all mesh lines.

GetLine(ny, idx)

Get the line in a given direction ny and index

Parameters:
  • ny – int or str – direction definition

  • idx – int – line index

GetLines(ny, do_sort=False)

Get all lines in a given direction ny.

Parameters:
  • ny – int or str – direction definition

  • do_sort – bool – sort lines

GetMeshType()
GetQtyLines(ny)
Parameters:

ny – int or str – direction definition

GetSimArea()

Get the simulation area as defined by the mesh.

Returns:

(2,3) array – Simulation domain box

IsValid()

Check if the mesh is valid. That is at least 2 mesh lines in all directions.

SetDeltaUnit(unit)

Set the drawing unit for all mesh lines. Default is 1 (m)

SetLines(ny, lines)

Set an array of lines. This will clear all previous defined lines in the given direction.

Parameters:
  • ny – int or str – direction definition

  • lines – array – list of lines to be set in the given direction

SetMeshType(cs_type)

Set the coordinate system type (Cartesian or cylindrical) for this mesh.

Parameters:

cs_type – coordinate system (0 : Cartesian, 1 : Cylindrical)

SmoothMeshLines(ny, max_res, ratio=1.5)

Smooth all mesh lines in the given direction with a max. allowed resolution.

Parameters:
  • ny – int or str – direction definition or ‘all’ for all directions

  • max_res – float – max. allowed resolution

  • ratio – float – max. allowed ration of mesh smoothing de/increase

Snap2LineNumber(ny, value)

Find a fitting mesh line index for the given direction and value.

Sort(ny='all')

Sort mesh lines in the given direction or all directions.