3.1.5.2. c3po.multi1D.Grid module
Contain the classes Grid, MEDGrid, CartesianGrid,
HexagonalGrid and MultiLevelGrid.
- class c3po.multi1D.Grid.CartesianGrid(xSizes, ySizes)
Bases:
MEDGridCartesianGridallows to define and handle a cartesian 2D mesh.Cells are numbered along the x axis first, then along the y axis (
loop(yDim){ loop(xDim) {i++}}). The mesh is centered on(0., 0.).- __init__(xSizes, ySizes)
Build a cartesian grid (centered on
(0., 0.)) from the sizes of the cells.
- clone()
see
Grid.clone()
- setCorrespondenceCartesian(xIndex, yIndex, correspondence)
Set one correspondence from the indexes of the cell in the cartesian grid.
Note
Use
c3po.multi1D.NO_CORRESPONDENCEas correspondence value in empty positions.- Parameters:
xIndex – Index of the cell along the x axis.
yIndex – Index of the cell along the y axis.
correspondence – Value to associate with the cell.
- class c3po.multi1D.Grid.Grid
Bases:
ABCGridis an abstract class defining a 2D mesh to be used byMEDInterface.Each cell is associated with an integer (correspondence) that will be used to identify a 1D object.
- abstractmethod getCorrespondence(cellId)
Return the correspondence associated with the required cell.
- Parameters:
cellId – Index of the cell in the mesh.
- Return type:
Correspondence associated with the cell.
- abstractmethod getMEDMesh()
Return a MEDCoupling mesh image of the grid (but without correspondences).
Note
It should be the same result than
toMED().getMesh().- Return type:
A MEDCoupling 2D mesh.
- abstractmethod getNodeCoordinates(cellId)
Return the coordinate of the nodes of one cell.
- Parameters:
cellId – Index of the cell in the mesh.
- Returns:
A list with the 2D coordinates of the nodes of the cell.
- Return type:
- abstractmethod getNumberOfCells()
Return the number of cells in the grid.
- Return type:
The number of cells in the grid.
- abstractmethod setCorrespondence(cellId, correspondence)
Set one correspondence in one cell.
Note
Use
c3po.multi1D.NO_CORRESPONDENCEas correspondence value in empty positions.- Parameters:
cellId – Index of the cell in the mesh.
correspondence – Value to set in the cell.
- abstractmethod setCorrespondences(correspondences)
Set the whole table of correspondences.
Note
Use
c3po.multi1D.NO_CORRESPONDENCEas correspondence value in empty positions.- Parameters:
correspondences – Table of correspondence to be copied.
correspondences[i]will be associated with the celli.
- abstractmethod shift(xShift, yShift)
Shift (geometric translation) the grid.
- Parameters:
xShift – Shift to be applied on x coordinate.
yShift – Shift to be applied on y coordinate.
- toMED()
Return a MEDCoupling field image of
self.- Return type:
A MEDCoupling field image of
self.
- class c3po.multi1D.Grid.HexagonalGrid(numRings, pitch)
Bases:
MEDGridHexagonalGridallows to define and handle an hexagonal 2D mesh.Cells are numbered in a “snail” way, from inside to outside. The central cell is numbered 0. The first cell of each ring makes an angle of
-pi/6with x axis. The mesh is centered on(0., 0.).- __init__(numRings, pitch)
Build a hexagonal grid (centered on
(0., 0.)).- Parameters:
numRings – Number of rings (use 0 for only one cell, 1 to get 7 etc.)
pitch – flat-to-flat distance.
- clone()
see
Grid.clone()
- setCorrespondenceHexagonal(ringIndex, positionIndex, correspondence)
Set one correspondence from the indexes of the cell in the hexagonal grid.
Note
Use
c3po.multi1D.NO_CORRESPONDENCEas correspondence value in empty positions.- Parameters:
ringIndex – Index of the ring.
positionIndex – Index of the cell on the ring.
correspondence – Value to associate with the cell.
- class c3po.multi1D.Grid.MEDGrid(field)
Bases:
GridMEDGrid allows to handle a 2D grid defined with a MEDCoupling mesh or field.
- __init__(field)
Build a MEDgrid from the provided MEDCoupling field. This field could have been written by
Grid.toMED().- Parameters:
field – MEDCoupling field (should be a
MEDCouplingFieldInt). It may have one component providing the correspondences (seeGrid).
- clone()
See
Grid.clone().
- getCorrespondence(cellId)
- getMEDMesh()
Return a MEDCoupling mesh image of the grid (but without correspondences).
Note
It should be the same result than
toMED().getMesh().- Return type:
A MEDCoupling 2D mesh.
- getNodeCoordinates(cellId)
- getNumberOfCells()
- setCorrespondence(cellId, correspondence)
- setCorrespondences(correspondences)
- shift(xShift, yShift)
See
Grid.translate().
- class c3po.multi1D.Grid.MultiLevelGrid(rootGrid, leafGrids)
Bases:
GridMultiLevelGridallows to define and handle grids inside other grids.- __init__(rootGrid, leafGrids)
Build a multi-level grid.
Note
We store and use clones of the provided leaf grids.
- Parameters:
rootGrid – Root level
Grid. Cannot be aMultiLevelGrid.leafGrids (list) – List of second level grids. There must be as many leaf grids than cells in the rootGrid. Leaf grids can be
MultiLevelGrid: in this case, all of them should beMultiLevelGrid, and those that are non-empty should all have the same number of levels.
- clone()
see
Grid.clone()
- getCorrespondence(cellId)
- getCurrentLevel()
Return the current level (see
setCurrentLevel()).- Return type:
The current level.
- getMEDMesh()
Return a MEDCoupling mesh image of the grid (but without correspondences).
Note
It should be the same result than
toMED().getMesh().- Return type:
A MEDCoupling 2D mesh.
- getNodeCoordinates(cellId)
- getNumLevels()
Return the number of level.
Note
level = 0if empty (rootGridwith no cells), 1 if leaf grids are not themselvesMultiLevelGrid, andn + 1withnthe level of leaf grids otherwise.- Return type:
Number of level.
- getNumberOfCells()
- setCorrespondence(cellId, correspondence)
- setCorrespondences(correspondences)
- setCurrentLevel(level)
Set the current level.
Note
All methods inherited from
Gridwill address this level. At level 0, theMultiLevelGridbehaves like therootGrid. At leveln > 0, it behaves like the juxtaposition of leaf grids with current leveln - 1. Defaut : the value returned begetNumLevels().- Parameters:
level – Level New current level.
- shift(xShift, yShift)
See
Grid.shift()