1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 Create intermediate mesh from SAMM files
27 \*---------------------------------------------------------------------------*/
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 void sammMesh::readCouples()
36 fileName couplesFileName(casePrefix_ + ".cpl");
38 IFstream couplesFile(couplesFileName);
40 if (couplesFile.good())
42 Info<< "\nReading couples" << endl;
44 // A mesh with couples cannot be a shape mesh
47 label matchLabel, nEntries, typeFlag;
48 label masterCell, masterFace;
49 label slaveCell, slaveFace;
51 while (!(couplesFile >> matchLabel).eof())
53 // read number of entries and match type.
54 // Note. At the moment, only integral matches are supported
55 couplesFile >> nEntries;
57 couplesFile >> typeFlag;
62 << "void sammMesh::readCouples() : "
63 << "couple " << matchLabel << " is not an integral match. "
64 << "Currently not supported" << endl;
67 // read master cell and face
68 couplesFile >> masterCell >> masterFace;
70 // get reference to master cell faces
71 faceList& masterFaces = cellFaces_[masterCell - 1];
73 // Info<< "Master cell: " << masterCell - 1 << " index: "
74 // << cellShapes_[masterCell - 1].model().index()
79 // [cellShapes_[masterCell - 1].model().index()]
84 // reset master face to zero size. It cannot be removed at this
85 // stage because thisw would mess up the numbering in case of
86 // more than one couple an a single master cell
90 [cellShapes_[masterCell - 1].model().index()]
94 // number of slave faces
95 label nSlavesToRead = nEntries - 1;
97 // get index for slave face add
98 label slaveToAdd = masterFaces.size();
100 // reset size of master faces to accept new (couple) faces
101 masterFaces.setSize(masterFaces.size() + nSlavesToRead);
103 for (int i = 0; i < nSlavesToRead; i++)
105 couplesFile >> slaveCell >> slaveFace;
107 masterFaces[slaveToAdd] =
114 [cellShapes_[slaveCell - 1].model().index()]
118 // Info<< " slave cell: " << slaveCell - 1 << " index: "
119 // << cellShapes_[slaveCell - 1].model().index()
120 // << " face: " << masterFaces[slaveToAdd] << endl;
129 // Once all couples are read, remove zero size faces from all cells
130 forAll(cellFaces_, cellI)
132 faceList& curFaces = cellFaces_[cellI];
134 label zeroSizeFound = 0;
136 forAll(curFaces, faceI)
138 if (curFaces[faceI].empty())
144 if (zeroSizeFound > 0)
146 // compress the list. A copy needs to made first
147 faceList oldFaces = curFaces;
149 curFaces.setSize(curFaces.size() - zeroSizeFound);
153 forAll(oldFaces, faceI)
155 if (oldFaces[faceI].size())
157 curFaces[nFaces] = oldFaces[faceI];
168 << "void sammMesh::readCouples() : "
169 << "Cannot read file "
171 << ". No matches defined."
177 // ************************************************************************* //