1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Create intermediate mesh from PROSTAR files
28 \*---------------------------------------------------------------------------*/
31 #include <OpenFOAM/IFstream.H>
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 void starMesh::readCouples()
37 fileName couplesFileName(casePrefix_ + ".cpl");
41 // Count number of couples
43 IFstream couplesFile(couplesFileName);
45 if (couplesFile.good())
47 Info << "\nReading couples" << endl;
49 label matchLabel, nEntries, typeFlag;
50 label starMasterCell, rotXMasterFace;
51 label starSlaveCell, rotXSlaveFace;
53 // count the number of entries to read
54 while (!(couplesFile >> matchLabel).eof())
56 // read number of entries and match type flag.
57 couplesFile >> nEntries;
59 couplesFile >> typeFlag;
61 // read master cell and face
62 couplesFile >> starMasterCell >> rotXMasterFace;
64 // add number of couples from current match
65 label nSlavesToRead = nEntries - 1;
67 nCouples += nSlavesToRead;
69 for (int i = 0; i < nSlavesToRead; i++)
71 couplesFile >> starSlaveCell >> rotXSlaveFace;
75 Info<< "Number of couples = " << nCouples << endl << endl;
79 Info<< endl << "No couple matches defined." << endl;
87 couples_.setSize(nCouples);
90 // A mesh with couples cannot be a shape mesh
93 IFstream couplesFile(couplesFileName);
95 label matchLabel, nEntries, typeFlag;
96 label starMasterCell, masterCell, rotXMasterFace, rotZeroMasterFace;
97 label starSlaveCell, slaveCell, rotXSlaveFace, rotZeroSlaveFace;
99 while (!(couplesFile >> matchLabel).eof())
101 // read number of entries and match type flag.
102 // Note. At the moment, only integral matches are supported
103 couplesFile >> nEntries;
105 couplesFile >> typeFlag;
107 // read master cell and face
108 couplesFile >> starMasterCell >> rotXMasterFace;
110 // translate the cell labels
111 masterCell = starCellLabelLookup_[starMasterCell];
113 // translate the master face into rotation zero if applicable
114 if (starCellPermutation_[masterCell] > -1)
116 const label curMasterPermutation =
117 starCellPermutation_[masterCell];
120 sammFacePermutationTable
121 [curMasterPermutation]
126 rotZeroMasterFace = rotXMasterFace;
129 // get master face index
132 [cellShapes_[masterCell].model().index()]
135 // number of slave faces
136 label nSlavesToRead = nEntries - 1;
138 for (int i = 0; i < nSlavesToRead; i++)
140 couplesFile >> starSlaveCell >> rotXSlaveFace;
142 // translate the cell labels
143 slaveCell = starCellLabelLookup_[starSlaveCell];
145 // translate the slave face into rotation zero if applicable
146 if (starCellPermutation_[slaveCell] > -1)
148 const label curSlavePermutation =
149 starCellPermutation_[slaveCell];
152 sammFacePermutationTable
153 [curSlavePermutation]
158 rotZeroSlaveFace = rotXSlaveFace;
163 [cellShapes_[slaveCell].model().index()]
173 masterCell, masterFaceID,
174 slaveCell, slaveFaceID,
181 Info << "finished reading couples" << endl;
186 // ************************ vim: set sw=4 sts=4 et: ************************ //