1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 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
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 Test new primitive patches.
27 \*---------------------------------------------------------------------------*/
32 #include "primitivePatch.H"
33 #include "faceIOList.H"
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 typedef PrimitivePatch<face, List, const pointField&> myPrimitivePatch;
44 void writeObj(Ostream& os,const pointField& points)
46 forAll(points, pointI)
48 const point& pt = points[pointI];
50 os << "v " << pt.x() << ' ' << pt.y()
51 << ' ' << pt.z() << endl;
58 const faceList& localFaces,
59 const edgeList& edges,
60 const labelListList& faceEdges
63 forAll(faceEdges, faceI)
65 const face& f = localFaces[faceI];
67 const labelList& myEdges = faceEdges[faceI];
71 label fp1 = f.fcIndex(fp);
73 if (edges[myEdges[fp]] != edge(f[fp], f[fp1]))
75 FatalErrorIn("checkFaceEdges")
76 << "Edges of face not in face point order:"
77 << "face:" << faceI << " localF:" << f
78 << " faceEdges:" << myEdges
88 const pointField& localPoints,
89 const edgeList& edges,
90 const label nInternalEdges
93 Info<< "Writing internal edges to internalEdges.obj" << nl << endl;
95 OFstream intStream("internalEdges.obj");
97 writeObj(intStream, localPoints);
99 for (label edgeI = 0; edgeI < nInternalEdges; edgeI++)
101 const edge& e = edges[edgeI];
103 intStream << "l " << e.start()+1 << ' ' << e.end()+1 << endl;
106 Info<< "Writing boundary edges to boundaryEdges.obj" << nl << endl;
108 OFstream bndStream("boundaryEdges.obj");
110 writeObj(bndStream, localPoints);
112 for (label edgeI = nInternalEdges; edgeI < edges.size(); edgeI++)
114 const edge& e = edges[edgeI];
116 bndStream << "l " << e.start()+1 << ' ' << e.end()+1 << endl;
123 const pointField& localPoints,
124 const edgeList& edges,
125 const labelListList& faceEdges
128 Info<< "Writing faceEdges per face to faceEdges.obj" << nl << endl;
130 OFstream feStream("faceEdges.obj");
132 writeObj(feStream, localPoints);
134 forAll(faceEdges, faceI)
136 const labelList& myEdges = faceEdges[faceI];
140 const edge& e = edges[myEdges[i]];
142 feStream<< "l " << e.start()+1 << ' ' << e.end()+1 << endl;
150 const pointField& localPoints,
151 const faceList& localFaces,
152 const edgeList& edges,
153 const labelListList& edgeFaces
156 Info<< "Writing edgeFaces per face to edgeFaces.obj" << nl << endl;
158 OFstream efStream("edgeFaces.obj");
160 pointField ctrs(localFaces.size(), vector::zero);
162 forAll(localFaces, faceI)
164 ctrs[faceI] = localFaces[faceI].centre(localPoints);
166 writeObj(efStream, ctrs);
169 forAll(edgeFaces, edgeI)
171 const labelList& myFaces = edgeFaces[edgeI];
175 efStream<< "l " << myFaces[0]+1 << ' ' << myFaces[i]+1 << endl;
183 const pointField& localPoints,
184 const faceList& localFaces,
185 const labelListList& faceFaces
188 Info<< "Writing faceFaces per face to faceFaces.obj" << nl << endl;
190 OFstream ffStream("faceFaces.obj");
192 pointField ctrs(localFaces.size(), vector::zero);
194 forAll(localFaces, faceI)
196 ctrs[faceI] = localFaces[faceI].centre(localPoints);
198 writeObj(ffStream, ctrs);
200 forAll(faceFaces, faceI)
202 const labelList& nbrs = faceFaces[faceI];
206 ffStream << "l " << faceI+1 << ' ' << nbrs[nbI]+1 << endl;
214 int main(int argc, char *argv[])
216 argList::noParallel();
217 argList::validArgs.append("patch");
219 # include "setRootCase.H"
220 # include "createTime.H"
221 # include "createPolyMesh.H"
223 word patchName(args.additionalArgs()[0]);
225 label patchI = mesh.boundaryMesh().findPatchID(patchName);
227 const polyPatch& patch = mesh.boundaryMesh()[patchI];
229 Info<< "Patch:" << patch.name() << endl;
231 PrimitivePatch<face, List, const pointField&> pp(patch, patch.points());
233 const pointField& localPoints = pp.localPoints();
234 const faceList& localFaces = pp.localFaces();
235 const labelListList& faceFaces = pp.faceFaces();
236 const edgeList& edges = pp.edges();
237 const labelListList& edgeFaces = pp.edgeFaces();
238 const labelListList& faceEdges = pp.faceEdges();
241 checkFaceEdges(localFaces, edges, faceEdges);
243 writeEdges(localPoints, edges, pp.nInternalEdges());
245 writeFaceEdges(localPoints, edges, faceEdges);
247 writeEdgeFaces(localPoints, localFaces, edges, edgeFaces);
249 writeFaceFaces(localPoints, localFaces, faceFaces);
251 Info << "End\n" << endl;
257 // ************************************************************************* //