1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
11 cfMesh 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 3 of the License, or (at your
14 option) any later version.
16 cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 // Construct from polyMeshGen
37 Foam::fpmaMesh::fpmaMesh(const polyMeshGen& mesh)
44 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
46 Foam::fpmaMesh::~fpmaMesh()
49 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
51 void Foam::fpmaMesh::writePoints(Foam::OFstream& fpmaGeometryFile) const
53 fpmaGeometryFile << mesh_.points().size() << nl;
54 const pointFieldPMG& points = mesh_.points();
55 forAll(points, pointI)
57 const point& p = points[pointI];
58 fpmaGeometryFile << p.x() << ' ' << p.y() << ' ' << p.z() << ' ';
61 fpmaGeometryFile << nl;
64 void fpmaMesh::writeCells(OFstream& fpmaGeometryFile) const
66 const cellListPMG& cells = mesh_.cells();
68 fpmaGeometryFile << cells.size() << nl;
71 const cell& c = cells[cellI];
73 fpmaGeometryFile << c.size();
75 fpmaGeometryFile << ' ' << c[fI];
76 fpmaGeometryFile << nl;
80 void Foam::fpmaMesh::writeFaces(OFstream& fpmaGeometryFile) const
82 const faceListPMG& faces = mesh_.faces();
83 fpmaGeometryFile << faces.size() << nl;
86 const face& f = faces[faceI];
88 fpmaGeometryFile << f.size();
90 fpmaGeometryFile << ' ' << f[pI];
91 fpmaGeometryFile << nl;
95 void Foam::fpmaMesh::writeSubsets(Foam::OFstream& fpmaGeometryFile) const
97 //- write patches as face selections
98 const PtrList<boundaryPatch>& patches = mesh_.boundaries();
102 nSubsets += patches.size();
103 DynList<label> indices;
104 mesh_.pointSubsetIndices(indices);
105 nSubsets += indices.size();
106 Info << "Mesh has " << indices.size() << " point subsets" << endl;
107 mesh_.faceSubsetIndices(indices);
108 nSubsets += indices.size();
109 Info << "Mesh has " << indices.size() << " face subsets" << endl;
110 mesh_.cellSubsetIndices(indices);
111 nSubsets += indices.size();
112 Info << "Mesh has " << indices.size() << " cell subsets" << endl;
114 fpmaGeometryFile << nSubsets << nl;
116 //- write patches as face selections
117 forAll(patches, patchI)
119 label start = patches[patchI].patchStart();
120 const label size = patches[patchI].patchSize();
122 fpmaGeometryFile << patches[patchI].patchName() << nl;
123 fpmaGeometryFile << 3 << nl;
124 fpmaGeometryFile << size << nl;
125 for(label i=0;i<size;++i)
126 fpmaGeometryFile << start++ << ' ';
127 fpmaGeometryFile << nl;
130 //- write node selections
131 mesh_.pointSubsetIndices(indices);
132 forAll(indices, indexI)
134 labelLongList nodesInSubset;
135 mesh_.pointsInSubset(indices[indexI], nodesInSubset);
137 fpmaGeometryFile << mesh_.pointSubsetName(indices[indexI]) << nl;
138 fpmaGeometryFile << 1 << nl;
139 fpmaGeometryFile << nodesInSubset.size() << nl;
140 forAll(nodesInSubset, i)
141 fpmaGeometryFile << nodesInSubset[i] << ' ';
142 fpmaGeometryFile << nl;
145 //- write face selections
146 mesh_.faceSubsetIndices(indices);
147 forAll(indices, indexI)
149 labelLongList facesInSubset;
150 mesh_.facesInSubset(indices[indexI], facesInSubset);
152 fpmaGeometryFile << mesh_.faceSubsetName(indices[indexI]) << nl;
153 fpmaGeometryFile << 3 << nl;
154 fpmaGeometryFile << facesInSubset.size() << nl;
155 forAll(facesInSubset, i)
156 fpmaGeometryFile << facesInSubset[i] << ' ';
157 fpmaGeometryFile << nl;
160 //- write cell selections
161 mesh_.cellSubsetIndices(indices);
162 forAll(indices, indexI)
164 labelLongList cellsInSubset;
165 mesh_.cellsInSubset(indices[indexI], cellsInSubset);
167 fpmaGeometryFile << mesh_.cellSubsetName(indices[indexI]) << nl;
168 fpmaGeometryFile << 2 << nl;
169 fpmaGeometryFile << cellsInSubset.size() << nl;
170 forAll(cellsInSubset, i)
171 fpmaGeometryFile << cellsInSubset[i] << ' ';
172 fpmaGeometryFile << nl;
177 void fpmaMesh::write(OFstream& fpmaGeometryFile) const
179 writePoints(fpmaGeometryFile);
181 writeFaces(fpmaGeometryFile);
183 writeCells(fpmaGeometryFile);
185 writeSubsets(fpmaGeometryFile);
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 } // End namespace Foam
192 // ************************************************************************* //