1 // MED MEDMEM : MED files in memory
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : MEDMEM_Grid.hxx
8 // Author : Edward AGAPOV (eap)
13 #include "MEDMEM_Grid.hxx"
14 #include <MEDMEM_CellModel.hxx>
15 #include <MEDMEM_SkyLineArray.hxx>
17 //=======================================================================
19 //purpose : empty constructor
20 //=======================================================================
24 MESSAGE("A GRID CREATED");
27 //=======================================================================
29 //purpose : empty constructor
30 //=======================================================================
32 GRID::GRID(const med_grid_type type)
36 MESSAGE("A TYPED GRID CREATED");
39 //=======================================================================
41 //purpose : copying constructor
42 //=======================================================================
44 GRID::GRID(const GRID& otherGrid) {
48 //=======================================================================
50 //purpose : destructor
51 //=======================================================================
54 MESSAGE("GRID::~GRID() : Destroying the Grid");
55 if ( _iArray != (double* ) NULL) delete [] _iArray;
56 if ( _jArray != (double* ) NULL) delete [] _jArray;
57 if ( _kArray != (double* ) NULL) delete [] _kArray;
60 //=======================================================================
63 //=======================================================================
67 _gridType = MED_CARTESIAN;
69 _iArray = _jArray = _kArray = (double* ) NULL;
70 _iArrayLength = _jArrayLength = _kArrayLength = 0;
72 _is_coordinates_filled = false;
73 _is_connectivity_filled = false;
80 //=======================================================================
83 //=======================================================================
85 GRID & GRID::operator=(const GRID & otherGrid)
89 MESH::operator=(otherGrid);
93 //=======================================================================
95 //purpose : Create a GRID object using a MESH driver of type
96 // (MED_DRIVER, ....) associated with file <fileName>.
97 //=======================================================================
99 GRID::GRID(driverTypes driverType,
100 const string & fileName,
101 const string & driverName) {
102 const char * LOC ="GRID::GRID(driverTypes , const string & , const string &) : ";
109 MESH(driverType,fileName,driverName);
111 // current = addDriver(driverType,fileName,driverName);
113 // switch(_drivers[current]->getAccessMode() ) {
115 // MESSAGE(LOC << "driverType must have a MED_RDWR accessMode");
116 // rmDriver(current);
120 // _drivers[current]->open();
121 // _drivers[current]->read();
122 // _drivers[current]->close();
124 // // fill some fields of MESH
125 // fillMeshAfterRead();
130 //=======================================================================
131 //function : fillMeshAfterRead
133 //=======================================================================
135 void GRID::fillMeshAfterRead()
137 // fill not only MESH (:-)
138 _is_coordinates_filled = false;
139 _is_connectivity_filled = false;
141 if (_gridType == MED_BODY_FITTED)
143 _is_coordinates_filled = true;
145 // nb of nodes in each direction is not known, set anything
146 // in order to be able to work anyhow
147 // INFOS("GRID::fillMeshAfterRead(): This stub must be removed");
148 // switch (_spaceDimension) {
150 // _iArrayLength = _numberOfNodes;
151 // _jArrayLength = 0;
152 // _kArrayLength = 0;
155 // _iArrayLength = 2;
156 // _jArrayLength = _numberOfNodes / _iArrayLength;
157 // _kArrayLength = 0;
160 // _iArrayLength = 2;
161 // _jArrayLength = _numberOfNodes / _iArrayLength / 2;
162 // _kArrayLength = _numberOfNodes / _iArrayLength / _jArrayLength;
164 //cout << "ARRAY LENGTHS: " << _iArrayLength << " " << _jArrayLength
165 // << " " << _kArrayLength << endl;
168 // int NbNodes = _iArrayLength;
169 // if (_jArrayLength)
170 // NbNodes *= _jArrayLength;
171 // if (_kArrayLength)
172 // NbNodes *= _kArrayLength;
173 // MESH::_numberOfNodes = NbNodes;
176 MESH::_meshDimension = MESH::_spaceDimension;
179 //=======================================================================
180 //function : fillCoordinates
182 //=======================================================================
184 void GRID::fillCoordinates()
186 if (_is_coordinates_filled)
188 MESSAGE("GRID::fillCoordinates(): Already filled");
192 const char * LOC ="GRID::fillCoordinates()";
196 const_cast <double *> ( _coordinate->getCoordinates(MED_FULL_INTERLACE) );
198 bool hasJ = _jArrayLength, hasK = _kArrayLength;
199 int J = hasJ ? _jArrayLength : 1;
200 int K = hasK ? _kArrayLength : 1;
202 for (k=0; k < K; ++k) {
203 for (j=0; j < J; ++j) {
204 for (i=0; i < _iArrayLength; ++i) {
206 * myCoord = _iArray[ i ];
211 * myCoord = _jArray[ j ];
216 * myCoord = _jArray[ k ];
224 _is_coordinates_filled = true;
228 //=======================================================================
229 //function : makeConnectivity
231 //=======================================================================
233 CONNECTIVITY * GRID::makeConnectivity (const medEntityMesh Entity,
234 const medGeometryElement Geometry,
235 const int NbEntities,
239 CONNECTIVITY * Connectivity = new CONNECTIVITY(Entity) ;
240 Connectivity->_numberOfNodes = NbNodes ;
241 Connectivity->_entityDimension = Geometry/100 ;
243 int numberOfGeometricType = 1;
244 Connectivity->_numberOfTypes = numberOfGeometricType;
246 Connectivity->_count = new int [numberOfGeometricType + 1] ;
247 Connectivity->_count[0] = 1;
248 Connectivity->_count[1] = 1 + NbEntities;
250 Connectivity->_type = new CELLMODEL [numberOfGeometricType];
251 Connectivity->_type[0] = CELLMODEL( Geometry ) ;
253 Connectivity->_geometricTypes = new medGeometryElement [ numberOfGeometricType ];
254 Connectivity->_geometricTypes[0] = Geometry;
256 // Connectivity->_nodal = new MEDSKYLINEARRAY() ;
257 int * skyLineArrayIndex = new int [NbEntities + 1];
258 int i, j, nbEntityNodes = Connectivity->_type[0].getNumberOfNodes();
259 for (i=0, j=1; i <= NbEntities; ++i, j += nbEntityNodes)
260 skyLineArrayIndex [ i ] = j;
262 // Connectivity->_nodal->setMEDSKYLINEARRAY (NbEntities, NbNodes,
263 //skyLineArrayIndex, NodeNumbers);
265 Connectivity->_nodal = new MEDSKYLINEARRAY (NbEntities, NbNodes,
266 skyLineArrayIndex, NodeNumbers);
268 delete [] skyLineArrayIndex;
270 // test connectivity right away
271 // for (med_int j = 0; j < numberOfGeometricType; j++)
273 // int node_number = Connectivity->_type[j].getNumberOfNodes();
274 // for (med_int k = Connectivity->_count[j]; k < Connectivity->_count[j+1]; k++)
275 // for (med_int local_node_number = 1 ; local_node_number < node_number+1; local_node_number++)
277 // cout << "MEDSKYLINEARRAY::getIJ(" << k << ", " << local_node_number << endl;
278 // med_int global_node = Connectivity->_nodal->getIJ(k,local_node_number) ;
279 // cout << "...= " << global_node << endl;
286 //=======================================================================
287 //function : fillConnectivity
288 //purpose : fill _coordinates and _connectivity of MESH if not yet done
289 //=======================================================================
291 void GRID::fillConnectivity()
293 if (_is_connectivity_filled)
295 MESSAGE("GRID::fillConnectivity(): Already filled");
299 const char * LOC = "GRID::fillConnectivity() ";
302 int nbCells, nbFaces, nbEdges;
303 int nbCNodes, nbFNodes, nbENodes;
304 int indexC, indexF, indexE;
305 int * nodeCNumbers, * nodeFNumbers, * nodeENumbers;
306 // about descending connectivity
307 int nbSub, nbRevSub, indexSub, indexRevSub, * subNumbers, * subRevNumbers;
309 bool hasFaces = _kArrayLength, hasEdges = _jArrayLength;
311 int iLenMin1 = _iArrayLength-1, jLenMin1 = _jArrayLength-1;
312 int kLenMin1 = _kArrayLength-1, ijLenMin1 = iLenMin1 * jLenMin1;
313 if (!hasEdges) jLenMin1 = 1;
314 if (!hasFaces) kLenMin1 = 1;
316 // nb of cells and of their connectivity nodes
318 nbCells = iLenMin1 * jLenMin1 * kLenMin1;
319 nbCNodes = nbCells * 2 * (hasEdges ? 2 : 1) * (hasFaces ? 2 : 1);
320 nodeCNumbers = new int [ nbCNodes ];
322 // nb of faces and of their connectivity nodes
325 nbFaces = _iArrayLength * jLenMin1 * kLenMin1;
326 nbFaces += _jArrayLength * kLenMin1 * iLenMin1;
327 nbFaces += _kArrayLength * iLenMin1 * jLenMin1;
328 nbFNodes = nbFaces * 4;
329 nodeFNumbers = new int [ nbFNodes ];
331 nbFaces = nbFNodes = 0;
333 // nb of edges and of their connectivity nodes
336 if (_kArrayLength) { // 3d grid
337 nbEdges = iLenMin1 * _jArrayLength * _kArrayLength;
338 nbEdges += jLenMin1 * _kArrayLength * _iArrayLength;
339 nbEdges += kLenMin1 * _iArrayLength * _jArrayLength;
341 else if (_jArrayLength) { // 2d
342 nbEdges = iLenMin1 * _jArrayLength;
343 nbEdges += jLenMin1 * _iArrayLength;
345 nbENodes = nbEdges * 2;
346 nodeENumbers = new int [ nbENodes ];
348 nbEdges = nbENodes = 0;
350 // nb of descending connectivity Elements
355 nbRevSub = nbFaces * 2;
360 nbRevSub = nbEdges * 2;
362 subNumbers = new int [ nbSub ];
363 subRevNumbers = new int [ nbRevSub ];
364 for (int r=0; r<nbRevSub; ++r)
365 subRevNumbers[ r ] = 0;
367 int nSubI = 1, nSubJ, nSubK; // subelement numbers
370 nSubJ = getFaceNumber(2, 0, 0, 0);
371 nSubK = getFaceNumber(3, 0, 0, 0);
374 nSubJ = getEdgeNumber(2, 0, 0, 0);
377 // fill cell node numbers and descending element numbers
380 indexC = indexF = indexE = indexSub = indexRevSub = -1;
381 int iNode = 0, iCell = 0;
382 int ijLen = _iArrayLength * _jArrayLength;
383 int i, j, k, n1, n2, n3 ,n4;
385 int I = _iArrayLength;
386 int J = _jArrayLength ? _jArrayLength : 2; // pass at least once
387 int K = _kArrayLength ? _kArrayLength : 2;
388 // pass by all but last nodes in all directions
389 for (k = 1; k < K; ++k ) {
390 for (j = 1; j < J; ++j ) {
391 for (i = 1; i < I; ++i ) {
395 n1 = ++iNode; // iNode
397 nodeCNumbers [ ++indexC ] = n1;
398 nodeCNumbers [ ++indexC ] = n2;
400 if (hasEdges) { // at least 2d
403 nodeCNumbers [ ++indexC ] = n3;
404 nodeCNumbers [ ++indexC ] = n4;
406 if (hasFaces) { // 3d
407 nodeCNumbers [ ++indexC ] = n1 + ijLen;
408 nodeCNumbers [ ++indexC ] = n2 + ijLen;
409 nodeCNumbers [ ++indexC ] = n3 + ijLen;
410 nodeCNumbers [ ++indexC ] = n4 + ijLen;
417 subNumbers [ ++indexSub ] = n1;
418 subRevNumbers[ n3 ] = iCell;
419 subNumbers [ ++indexSub ] = n2;
420 subRevNumbers[ n4 ] = -iCell;
425 subNumbers [ ++indexSub ] = n1;
426 subRevNumbers[ n3 ] = iCell;
427 subNumbers [ ++indexSub ] = n2;
428 subRevNumbers[ n4 ] = -iCell;
433 subNumbers [ ++indexSub ] = n1;
434 subRevNumbers[ n3 ] = iCell;
435 subNumbers [ ++indexSub ] = n2;
436 subRevNumbers[ n4 ] = -iCell;
445 subNumbers [ ++indexSub ] = n1;
446 subRevNumbers[ n3 ] = iCell;
447 subNumbers [ ++indexSub ] = n2;
448 subRevNumbers[ n4 ] = -iCell;
453 subNumbers [ ++indexSub ] = n1;
454 subRevNumbers[ n3 ] = iCell;
455 subNumbers [ ++indexSub ] = n2;
456 subRevNumbers[ n4 ] = -iCell;
458 ++nSubI; ++nSubJ; ++nSubK;
460 ++iNode; // skip the last node in a row
466 iNode += I; // skip the whole last row
469 // fill face node numbers
471 int ax, AX = hasFaces ? 3 : 0;
472 for (ax = 1; ax <= AX; ++ax) {
480 case 1: --J; --K; break;
481 case 2: --K; --I; break;
484 for (k = 1; k <= K; ++k ) {
485 for (j = 1; j <= J; ++j ) {
486 for (i = 1; i <= I; ++i ) {
491 case 1: // nodes for faces normal to i direction
496 case 2: // nodes for faces normal to j direction
501 default: // nodes for faces normal to k direction
506 nodeFNumbers [ ++indexF ] = n1;
507 nodeFNumbers [ ++indexF ] = n2;
508 nodeFNumbers [ ++indexF ] = n3;
509 nodeFNumbers [ ++indexF ] = n4;
511 if (ax != 1) ++iNode;
513 if (ax != 2) iNode += _iArrayLength;
516 if (nbFNodes != indexF+1) {
517 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Wrong nbFNodes : " \
518 << nbFNodes << " indexF : " << indexF ));
521 // fill edge node numbers
523 AX = hasEdges ? _spaceDimension : 0;
524 for (ax = 1; ax <= AX; ++ax) {
538 for (k = 1; k <= K; ++k ) {
539 for (j = 1; j <= J; ++j ) {
540 for (i = 1; i <= I; ++i ) {
545 case 1: // nodes for edges going along i direction
548 case 2: // nodes for edges going along j direction
549 n2 = n1 + _iArrayLength;
551 default: // nodes for edges going along k direction
554 nodeENumbers [ ++indexE ] = n1;
555 nodeENumbers [ ++indexE ] = n2;
557 if (ax == 1) ++iNode;
559 if (ax == 2) iNode += _iArrayLength;
562 if (nbENodes != indexE+1) {
563 throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Wrong nbFNodes : " \
564 << nbENodes << " indexE : " << indexE ));
568 CONNECTIVITY * CellCNCT, * FaceCNCT, * EdgeCNCT;
570 // make connectivity for CELL
572 medGeometryElement aCellGeometry;
573 if (_kArrayLength) aCellGeometry = MED_HEXA8;
574 else if (_jArrayLength) aCellGeometry = MED_QUAD4;
575 else aCellGeometry = MED_SEG2;
578 CellCNCT = makeConnectivity (MED_CELL, aCellGeometry, nbCells, nbCNodes, nodeCNumbers);
580 delete [] nodeCNumbers;
584 // CellCNCT->_descending = new MEDSKYLINEARRAY() ;
585 int * skyLineArrayIndex = new int [nbCells + 1];
586 int nbEntitySub = CellCNCT->_type[0].getNumberOfConstituents(1);
587 for (i=0, j=1; i <= nbCells; ++i, j += nbEntitySub)
588 skyLineArrayIndex [ i ] = j;
589 // CellCNCT->_descending->setMEDSKYLINEARRAY (nbCells, nbSub,
590 // skyLineArrayIndex, subNumbers);
591 CellCNCT->_descending = new MEDSKYLINEARRAY (nbCells, nbSub,
594 delete [] skyLineArrayIndex;
596 delete [] subNumbers;
598 // reverse descending
600 // CellCNCT->_reverseDescendingConnectivity = new MEDSKYLINEARRAY() ;
602 int * skyLineArrayIndex = new int [nbSub + 1];
603 for (i=0, j=1; i <= nbSub; ++i, j += 2)
604 skyLineArrayIndex [ i ] = j;
605 // CellCNCT->_reverseDescendingConnectivity->setMEDSKYLINEARRAY
606 // (nbSub, nbRevSub, skyLineArrayIndex, subRevNumbers);
608 CellCNCT->_reverseDescendingConnectivity =
609 new MEDSKYLINEARRAY(nbSub, nbRevSub, skyLineArrayIndex, subRevNumbers);
611 delete [] skyLineArrayIndex;
613 delete [] subRevNumbers;
615 // make connectivity for FACE and/or EDGE
618 FaceCNCT = makeConnectivity (MED_FACE, MED_QUAD4, nbFaces, nbFNodes, nodeFNumbers);
620 delete [] nodeFNumbers;
622 CellCNCT->_constituent = FaceCNCT;
625 EdgeCNCT = makeConnectivity (MED_EDGE, MED_SEG2, nbEdges, nbENodes, nodeENumbers);
627 delete [] nodeENumbers;
630 FaceCNCT->_constituent = EdgeCNCT;
632 CellCNCT->_constituent = EdgeCNCT;
635 MESH::_connectivity = CellCNCT;
637 _is_connectivity_filled = true;
642 //=======================================================================
643 //function : getArrayLength
644 //purpose : return array length. Axis = [1,2,3] meaning [i,j,k],
645 //=======================================================================
647 int GRID::getArrayLength( const int Axis ) throw (MEDEXCEPTION)
650 case 1: return _iArrayLength;
651 case 2: return _jArrayLength;
652 case 3: return _kArrayLength;
654 throw MED_EXCEPTION ( LOCALIZED( STRING("GRID::getArrayLength ( ") << Axis << ")"));
659 //=======================================================================
660 //function : getArrayValue
661 //purpose : return i-th array component. Axis = [1,2,3] meaning [i,j,k],
662 // exception if Axis out of [1-3] range
663 // exception if i is out of range 0 <= i < getArrayLength(Axis);
664 //=======================================================================
666 const double GRID::getArrayValue (const int Axis, const int i)
669 if (i < 0 || i >= getArrayLength(Axis))
671 ( LOCALIZED(STRING("GRID::getArrayValue ( ") << Axis << ", " << i << ")"));
674 case 1: return _iArray[ i ];
675 case 2: return _jArray[ i ];
676 default: return _kArray[ i ];
681 //=======================================================================
682 //function : getEdgeNumber
684 //=======================================================================
686 int GRID::getEdgeNumber(const int Axis, const int i, const int j, const int k)
689 const char * LOC = "GRID::getEdgeNumber(Axis, i,j,k) :";
691 int Len[4] = {0,_iArrayLength, _jArrayLength, _kArrayLength }, I=1, J=2, K=3;
692 int maxAxis = Len[ K ] ? 3 : 2;
694 if (Axis <= 0 || Axis > maxAxis)
695 throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Axis out of range: " << Axis));
698 int Nb = 1 + i + j*Len[ I ] + k*Len[ J ]*Len[ K ];
704 if (Axis > 1) { // add all edges in i direction
706 Nb += Len[ I ]*Len[ J ]*Len[ K ];
709 if (Axis > 2) { // add all edges in j direction
711 Nb += Len[ I ]*Len[ J ]*Len[ K ];
717 //=======================================================================
718 //function : getFaceNumber
719 //purpose : return a NODE, EDGE, FACE, CELL number by its position in the grid.
720 // Axis [1,2,3] means one of directions: along i, j or k
721 // For Cell contituents (FACE or EDGE), Axis selects one of those having same (i,j,k):
722 // * a FACE which is normal to direction along given Axis;
723 // * an EDGE going along given Axis.
724 // Exception for Axis out of range
725 //=======================================================================
727 int GRID::getFaceNumber(const int Axis, const int i, const int j, const int k)
730 const char * LOC = "GRID::getFaceNumber(Axis, i,j,k) :";
732 // if (Axis <= 0 || Axis > 3)
733 if (Axis < 0 || Axis > 3)
734 throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Axis = " << Axis));
736 int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2, K=3;
739 int Nb = 1 + i + j*Len[ I ] + k*Len[ J ]*Len[ K ];
742 if (Axis > 1) { // add all faces in i direction
744 Nb += Len[ I ]*Len[ J ]*Len[ K ];
747 if (Axis > 2) { // add all faces in j direction
749 Nb += Len[ I ]*Len[ J ]*Len[ K ];
755 //=======================================================================
756 //function : getNodePosition
758 //=======================================================================
760 void GRID::getNodePosition(const int Number, int& i, int& j, int& k)
763 const char * LOC = "GRID::getNodePosition(Number, i,j,k) :";
765 if (Number <= 0 || Number > _numberOfNodes)
766 throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
768 int Len[] = {_iArrayLength, _jArrayLength, _kArrayLength }, I=0, J=1, K=2;
770 int ijLen = Len[I] * Len[J]; // nb in a full k layer
771 int kLen = (Number - 1) % ijLen; // nb in the non full k layer
775 k = (Number - 1) / ijLen;
777 ////cout <<" NODE POS: " << Number << " - " << i << ", " << j << ", " << k << endl;
780 //=======================================================================
781 //function : getCellPosition
783 //=======================================================================
785 void GRID::getCellPosition(const int Number, int& i, int& j, int& k)
788 const char * LOC = "GRID::getCellPosition(Number, i,j,k) :";
790 int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2, K=3;
792 // if (Number <= 0 || Number > getCellNumber(Len[I]-1, Len[J]-1, Len[K]-1))
793 // throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
795 int ijLen = Len[I] * Len[J]; // nb in a full k layer
796 int kLen = (Number - 1) % ijLen; // nb in the non full k layer
800 k = (Number - 1) / ijLen;
803 //=======================================================================
804 //function : getEdgePosition
806 //=======================================================================
808 void GRID::getEdgePosition(const int Number, int& Axis, int& i, int& j, int& k)
811 const char * LOC = "GRID::getEdgePosition(Number, i,j,k) :";
814 throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "no edges in the grid: "));
817 throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
819 int Len[4] = {0,_iArrayLength, _jArrayLength, _kArrayLength }, I=1, J=2, K=3;
822 int maxAxis = _kArrayLength ? 3 : 2;
824 for (Axis = 1; Axis <= maxAxis; ++Axis)
826 Len[Axis]--; // one less edge in Axis direction
828 // max edge number in Axis direction
829 int maxNb = getEdgeNumber (Axis, Len[I]-1, Len[J]-1, Len[K]-1);
846 int ijLen = Len[I] * Len[J]; // nb in a full k layer
847 int kLen = (theNb - 1) % ijLen; // nb in the non full k layer
850 k = (theNb - 1) / ijLen;
855 throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
858 //=======================================================================
859 //function : getFacePosition
860 //purpose : return position (i,j,k) of an entity #Number
861 // Axis [1,2,3] means one of directions: along i, j or k
862 // For Cell contituents (FACE or EDGE), Axis selects one of those having same (i,j,k):
863 // * a FACE which is normal to direction along given Axis;
864 // * an EDGE going along given Axis.
865 // Exception for Number out of range
866 //=======================================================================
868 void GRID::getFacePosition(const int Number, int& Axis, int& i, int& j, int& k)
871 const char * LOC = "GRID::getFacePosition(Number, i,j,k) :";
873 if (_kArrayLength == 0) {
874 getCellPosition(Number, i, j, k);
880 throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "no faces in the grid: "));
883 throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
885 int Len[4] = {0,_iArrayLength-1, _jArrayLength-1, _kArrayLength-1 }, I=1, J=2, K=3;
888 for (Axis = 1; Axis <= 3; ++Axis)
892 // max face number in Axis direction
893 int maxNb = getFaceNumber (Axis, Len[I]-1, Len[J]-1, Len[K]-1);
910 int ijLen = Len[I] * Len[J]; // nb in a full k layer
911 int kLen = (theNb - 1) % ijLen; // nb in the non full k layer
914 k = (theNb - 1) / ijLen;
919 throw MED_EXCEPTION ( LOCALIZED(STRING(LOC) << "Number is out of range: " << Number));
922 //=======================================================================
923 //function : writeUnstructured
924 //purpose : write a Grid as an Unstructured mesh
925 //=======================================================================
927 void GRID::writeUnstructured(int index, const string & driverName)
929 const char * LOC = "GRID::writeUnstructured(int index=0, const string & driverName) : ";
932 if ( _drivers[index] ) {
937 _drivers[index]->open();
938 if (driverName != "") _drivers[index]->setMeshName(driverName);
939 _drivers[index]->write();
940 _drivers[index]->close();
945 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
946 << "The index given is invalid, index must be between 0 and |"