57 const bool isBinary,
const bool isDP)
61 const int count = iEnd-iBeg+1;
69 buff =
new double[nread];
73 if (nread != (
int)fread(buff,
sizeof(
double),nread,
_fp))
74 cerr <<
"error reading dp binary nodes" << endl;
79 for(
int i=0; i<nread; i++)
80 if (fscanf(
_fp,
"%le",bp++) != 1)
81 cerr <<
"error reading dp formatted nodes" << endl;
87 for(
int i=iBeg; i<=iEnd; i++)
98 float *buff =
new float[nread];
101 if (nread != (
int)fread(buff,
sizeof(
float),nread,
_fp))
102 cerr <<
"error reading sp binary nodes" << endl;
107 for(
int i=0; i<nread; i++)
108 if (fscanf(
_fp,
"%e",bp++) != 1)
109 cerr <<
"error reading sp formatted nodes" << endl;
113 for(
int i=iBeg; i<=iEnd; i++)
123 const bool isDP,
const int sectionID)
125 int threadId, iBeg, iEnd, type, dummy;
172 int threadId, iBeg, iEnd, type, dummy;
180 else if ((type == 1) || (type == 17))
195 throw CException(
"cell thread type not handled");
209 int threadId, iBeg, iEnd, type, shape;
221 if ((type != 0) && (type != 31))
233 for(
int f=iBeg; f<=iEnd; f++)
235 int numNodes = shape;
236 if (shape == 0 || shape == 5)
243 if (c0 == 0 || c1 == 0)
262 if ((threadId != 0) && (type != 0) && (type != 31))
268 for(
int f=iBeg; f<=iEnd; f++)
270 int numNodes = shape;
271 if (shape == 0 || shape == 5)
300 if ((threadId != 0) && (type != 0) && (type != 31))
306 const int maxNodes = 100;
307 int fnodes[maxNodes];
308 for(
int f=iBeg; f<=iEnd; f++)
310 int numNodes = shape;
311 if (shape == 0 || shape == 5)
318 for(
int i=0; i<numNodes; i++)
319 fnodes[i] =
readInt(isBinary)-1;
325 if ((c0 == 0) && (c1 == 0))
327 faceCells.
add(f-1,-1);
328 faceCells.
add(f-1,-1);
332 if (c0 == 0) reverseNodes = !reverseNodes;
335 faceCells.
add(f-1,c0-1);
337 faceCells.
add(f-1,c1-1);
347 for(
int i=0; i<numNodes; i++)
348 faceNodes.
add(f-1,fnodes[numNodes-i-1]);
350 for(
int i=0; i<numNodes; i++)
351 faceNodes.
add(f-1,fnodes[i]);
378 int iBeg, iEnd, leftID, rightID, dummy;
384 const int count = iEnd-iBeg+1;
390 for(
int n=0; n<count; n++)
393 int rightF =
readInt(isBinary);
395 (*leftFaces)[n]=leftF-1;
396 (*rightFaces)[n]=rightF-1;
406 _facePairs[leftID] = shared_ptr<FluentFacePairs>(fp);
428 bool isBinary = (
id > 1000);
429 bool isDP = (
id > 3000);
459 delete [] rpVarString;
472 char zoneName[256], zoneType[80];
474 fscanf(
_fp,
"%d%s",&zoneId,zoneType);
481 while ((c = getc(
_fp)) != EOF)
507 z->
zoneName=string(zoneName,strlen(zoneName));
508 z->
zoneType=string(zoneType,strlen(zoneType));
513 z->
zoneName=string(zoneName,strlen(zoneName));
514 z->
zoneType=string(zoneType,strlen(zoneType));
527 string(zoneVarString,_zoneVarStringLength[zoneId]);
533 string(zoneVarString,_zoneVarStringLength[zoneId]);
535 delete [] zoneVarString;
585 _faceCells->initCount();
591 _faceCells->finishCount();
605 _faceCells->finishAdd();
613 foreach(
const CellZonesMap::value_type& pos,
_cellZones)
621 throw CException(
"getCellZoneID: invalid cell id");
661 foreach(FaceZonesMap::value_type& pos,
_faceZones)
668 const int c0 = faceCells(fz.
iBeg,0);
677 const int c1 = faceCells(fz.
iBeg,1);
709 vector<int> allFaceList;
716 for(
int i=fz.
iBeg; i<=fz.
iEnd; i++) allFaceList.push_back(i);
719 faceOffset = allFaceList.size();
722 vector<int> interfaceFaceList;
728 allFaceList.push_back(i);
729 interfaceFaceList.push_back(i);
732 const int thisFZCount = fz.
iEnd-fz.
iBeg+1;
734 faceOffset += thisFZCount;
737 vector<int> boundaryCells;
741 for(
int i=fz.
iBeg; i<=fz.
iEnd; i++) allFaceList.push_back(i);
743 const int thisFZCount = fz.
iEnd-fz.
iBeg+1;
750 faceOffset += thisFZCount;
752 for(
int j=fcRow[fz.
iBeg]; j<fcRow[fz.
iEnd+1]; j++)
754 boundaryCells.push_back(fcCol[j]);
760 for(
unsigned int i=0; i<allFaceList.size(); i++) allFaceArray[i] = allFaceList[i];
768 int numMeshCells = cz.
iEnd-cz.
iBeg+1;
771 vector<int> interfaceCellList;
773 const int interfaceFaceCount = interfaceFaceList.size();
774 if (interfaceFaceCount > 0)
780 for(
int i=0; i<interfaceFaceCount; i++)
781 ifFacesArray[i] = interfaceFaceList[i];
787 shared_ptr<CRConnectivity>
788 ifFaceNodes(
_faceNodes->getLocalizedSubset(ifFacesSite,
792 const Array<int>& interfaceNodes = ifFaceNodes->getLocalToGlobalMap();
795 shared_ptr<CRConnectivity>
796 ifNodeCells(
getNodeCells().getLocalizedSubset(ifNodesSite,
800 const Array<int>& interfaceAllCells = ifNodeCells->getLocalToGlobalMap();
802 for(
int i=0; i<interfaceAllCells.
getLength(); i++)
804 const int c = interfaceAllCells[i];
805 if ((c < cz.iBeg || c >cz.
iEnd) &&
807 interfaceCellList.push_back(c);
811 const int numGhostCells = interfaceCellList.size();
812 const int numBoundaryCells = boundaryCells.size();
814 const int nTotalCells = numMeshCells+numGhostCells+numBoundaryCells;
822 interiorCellList[nc]=i;
824 globalToLocalCellMap[i]=nc++;
827 foreach(
int i, interfaceCellList)
830 globalToLocalCellMap[i]=nc++;
833 foreach(
int i, boundaryCells)
836 globalToLocalCellMap[i]=nc++;
843 shared_ptr<CRConnectivity>
847 shared_ptr<Array<Vec3> > coords =
848 _coords.getSubset(czAllCellNodes->getLocalToGlobalMap());
853 nodes.
setCount(coords->getLength());
855 mFaceNodes->localize(czAllCellNodes->getGlobalToLocalMap(),nodes);
858 mFaceCells->localize(globalToLocalCellMap,mesh->
getCells());
864 foreach(
const CellZonesMap::value_type& pos,
_cellZones)
885 FacePairsMap::const_iterator pos =
_facePairs.find(fzId);
894 nPeriodic += facePairs.
count;
903 for(
int i=0; i<facePairs.
count; i++)
909 const int lf = pFaces[i] - fz.
iBeg + myOffset;
910 const int rf = shadowFaces[i] - shadowFz.
iBeg + myShadowOffset;
912 periodicFacePairs[lf] = rf;
921 shared_ptr<Array<int> >fromPtr(
new Array<int>(nPeriodic*2));
922 shared_ptr<Array<int> >toPtr(
new Array<int>(nPeriodic*2));
932 for(Mesh::PeriodicFacePairs::const_iterator pos = periodicFacePairs.begin();
933 pos!=periodicFacePairs.end();
936 const int lf = pos->first;
937 const int rf = pos->second;
938 from[nPeriodic] = faceCells(lf,0);
939 from[nPeriodic+1] = faceCells(rf,0);
940 to[nPeriodic] = faceCells(lf,1);
941 to[nPeriodic+1] = faceCells(rf,1);
958 globalToLocalCellMap = -1;
962 map<int, Mesh*> meshMap;
963 foreach(
const CellZonesMap::value_type& pos,
_cellZones)
967 meshes.push_back(mesh);
968 meshMap[cz.
ID] = mesh;
971 foreach(
const CellZonesMap::value_type& pos,
_cellZones)
979 foreach(
const GhostCellMapsMap::value_type& pos2, cz.
ghostCellMaps)
982 shared_ptr<OneToOneIndexMap> mappers = pos2.second;
990 foreach(
const CellZonesMap::value_type& pos2,
_cellZones)
1002 thisNodes.getCommonMap()[&oNodes] = nodeMap->_toIndices;
1010 foreach(
const FacePairsMap::value_type& pos,
_facePairs)
1030 const int count = facePairs.
count;
1032 shared_ptr<Array<int> > lScatter(
new Array<int>(count));
1033 shared_ptr<Array<int> > rScatter(
new Array<int>(count));
1034 shared_ptr<Array<int> > lGather(
new Array<int>(count));
1035 shared_ptr<Array<int> > rGather(
new Array<int>(count));
1038 for(
int f=0; f<count; f++)
1040 const int lf = leftFaces[f];
1041 const int rf = rightFaces[f];
1043 (*lScatter)[f] = globalToLocalCellMap[faceCells(lf,0)];
1044 (*rScatter)[f] = globalToLocalCellMap[faceCells(rf,0)];
1045 (*lGather)[f] = globalToLocalCellMap[faceCells(lf,1)];
1046 (*rGather)[f] = globalToLocalCellMap[faceCells(rf,1)];
1061 shared_ptr<OneToOneIndexMap>
1064 const int iBeg = cz.
iBeg;
1065 const int iEnd = cz.
iEnd;
1067 int thisZoneCells=0;
1068 for(
int ii=0; ii<indices.
getLength(); ii++)
1070 const int c = indices[ii];
1071 if (c >= iBeg && c<=iEnd) thisZoneCells++;
1074 if (thisZoneCells == 0)
return shared_ptr<OneToOneIndexMap>();
1076 shared_ptr<Array<int> >fromPtr(
new Array<int>(thisZoneCells));
1077 shared_ptr<Array<int> >toPtr(
new Array<int>(thisZoneCells));
1083 for(
int ii=0; ii<indices.
getLength(); ii++)
1085 const int c = indices[ii];
1086 if (c >= iBeg && c<=iEnd)
1088 to[thisZoneCells] = ii;
1089 from[thisZoneCells] = c-iBeg;
1098 shared_ptr<OneToOneIndexMap>
1106 const int nNodes = gToLocal0.
getLength();
1108 for(
int n=0; n<nNodes; n++)
1110 const int l0 = gToLocal0[n];
1111 const int l1 = gToLocal1[n];
1112 if ((l0 != -1) && (l1 != -1))
1117 if (nCommon == 0)
return shared_ptr<OneToOneIndexMap>();
1119 shared_ptr<Array<int> >fromPtr(
new Array<int>(nCommon));
1120 shared_ptr<Array<int> >toPtr(
new Array<int>(nCommon));
1126 for(
int n=0; n<nNodes; n++)
1128 const int l0 = gToLocal0[n];
1129 const int l1 = gToLocal1[n];
1130 if ((l0 != -1) && (l1 != -1))
const CRConnectivity & getCellFaces()
const Array< int > & getCol() const
void readNodes(const int pass, const bool isBinary, const bool isDP, const int id)
const Array< int > & getRow() const
shared_ptr< CRConnectivity > _nodeCells
void read(const int pass)
void setFaceNodes(shared_ptr< CRConnectivity > faceNodes)
void readVectorData(Array< Vec3 > &a, const int iBeg, const int iEnd, const bool isBinary, const bool isDP)
int getCellZoneID(const int c) const
PeriodicFacePairs & getPeriodicFacePairs()
vector< int > interfaceZoneIds
const CRConnectivity & getNodeCells()
const StorageSite & getNodes() const
void readFacePairs(const int pass, const bool isBinary, const int id)
const StorageSite & createInteriorFaceGroup(const int size)
GhostCellMapsMap ghostCellMaps
void setCoordinates(shared_ptr< Array< VecD3 > > x)
const FaceGroup & getFaceGroup(const int fgId) const
int readInt(const bool isBinary)
vector< int > boundaryZoneIds
shared_ptr< Array< int > > rightFaces
void setFaceCells(shared_ptr< CRConnectivity > faceCells)
void setCount(const int selfCount, const int nGhost=0)
Mesh * createMesh(const int cellZoneID, Array< int > &)
map< int, int > PeriodicFacePairs
const StorageSite & createBoundaryFaceGroup(const int size, const int offset, const int id, const string &boundaryType)
map< int, int > _zoneVarStringLength
shared_ptr< OneToOneIndexMap > getCommonNodeMap(const FluentCellZone &cz0, const FluentCellZone &cz1)
const CRConnectivity & getAllFaceCells() const
void readCells(const int pass, const bool isBinary, const int id)
const CRConnectivity & getCellNodes()
const StorageSite & createInterfaceGroup(const int size, const int offset, const int id)
virtual void * getData() const
void readFaces(const int pass, const bool isBinary, const int id)
shared_ptr< CRConnectivity > _cellNodes
void setCellZoneID(const int id)
const StorageSite & getFaces() const
const StorageSite & getCells() const
FluentReader(const string &fileName)
shared_ptr< CRConnectivity > _cellFaces
shared_ptr< Array< int > > globalToLocalNodeMap
const ScatterMap & getScatterMap() const
shared_ptr< CRConnectivity > _faceCells
shared_ptr< CRConnectivity > multiply(const CRConnectivity &b, const bool implicitDiagonal) const
const GatherMap & getGatherMap() const
shared_ptr< CRConnectivity > getTranspose() const
int add(const int index, const int val)
vector< int > interiorZoneIds
shared_ptr< OneToOneIndexMap > getGhostCellMap(const FluentCellZone &cz, const Array< int > &indices)
void readHeader(int &i1, int &i2, int &i3, int &i4, int &i5)
shared_ptr< CRConnectivity > _faceNodes
void skipInt(const int n, const bool isBinary)
int closeSectionBinary(const int currentId)
void addCount(const int index, const int count)
void readList(char *buffer)
vector< Mesh * > MeshList
shared_ptr< Array< int > > leftFaces