CSRectGrid
Rectilinear Grid Class for CSXCAD
- class CSXCAD.CSRectGrid.CSRectGrid
- AddLine(ny, lines)
Add an array of lines. This will not clear the previous defined lines in the given direction.
Changed in version 0.7.0: The lines are sorted into the existing lines, a line that is already present is dropped.
- 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
The lines are always sorted and unique, index 0 is the smallest line.
Changed in version 0.7.0: An out of range index raises an
IndexErrorinstead of returning 0, and a negative index counts from the end.- Parameters:
ny – int or str – direction definition
idx – int – line index, negative counts from the end
- Returns:
float – line position
- Raises:
IndexError – if idx is out of range
- GetLines(ny, do_sort=True)
Get all lines in a given direction ny, sorted and unique.
Deprecated since version 0.7.0: The do_sort argument is ignored, the lines are always sorted and unique.
- Parameters:
ny – int or str – direction definition
do_sort – bool – ignored
- GetMeshType()
- GetQtyLines(ny)
Get the number of lines in a given direction ny.
Changed in version 0.7.0: Duplicate lines are dropped and are not counted any more.
- 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.
Changed in version 0.7.0: The lines are sorted and duplicates are dropped, lines does not have to be given in increasing order any more.
- 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, check_symmetry=True)
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
check_symmetry – bool – detect a symmetric mesh and smooth only one half (default True); set False to disable and smooth the full line set
- 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.
Deprecated since version 0.7.0: The mesh lines are always sorted and unique, this method has no effect.