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/>.
25 Translates FOAM mesh to AVL's FPMA format
27 \*---------------------------------------------------------------------------*/
29 #include "objectRegistry.H"
31 #include "polyMeshGen.H"
32 #include "meshSurfaceEngine.H"
38 #include "writeMeshFPMA.H"
39 #include "helperFunctions.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 void writeMeshFPMA(const polyMeshGen& mesh, const word& fName)
48 const Time& time = mesh.returnTime();
50 const word postProcDir = "FPMA";
52 fileName postProcPath = time.path()/postProcDir;
54 if( !Foam::isDir(postProcPath) )
60 const fileName fpmaFileName = fName + ".fpma";
62 Info << "Writting mesh into " << fpmaFileName << endl;
64 /* OFstream fpmaGeometryFile
66 postProcPath/fpmaFileName,
68 IOstream::currentVersion,
69 IOstream::UNCOMPRESSED
73 OFstream fpmaGeometryFile(postProcPath/fpmaFileName);
75 // Construct the FIRE mesh
77 Mesh.write(fpmaGeometryFile);
80 void createFIRESelections(polyMeshGen& mesh)
82 if( !Pstream::parRun() )
85 const faceListPMG& faces = mesh.faces();
86 const PtrList<processorBoundaryPatch>& procBoundaries =
87 mesh.procBoundaries();
89 //- create face selections from proc patches
90 forAll(procBoundaries, patchI)
92 word sName = "InterFacesToProc";
93 sName += help::scalarToText(procBoundaries[patchI].neiProcNo());
94 const label sID = mesh.addFaceSubset(sName);
96 label faceI = procBoundaries[patchI].patchStart();
97 const label end = faceI + procBoundaries[patchI].patchSize();
98 for(;faceI<end;++faceI)
99 mesh.addFaceToSubset(sID, faceI);
102 //- create cell selections
103 DynList<label> subsets;
104 mesh.faceSubsetIndices(subsets);
105 forAll(subsets, subsetI)
107 const word sName = mesh.faceSubsetName(subsets[subsetI]);
109 if( sName.substr(0, 10) == "processor_" )
111 const word newName = "Proc" + sName.substr(10, sName.size()-10);
113 labelLongList cellsInSubset;
114 mesh.cellsInSubset(subsets[subsetI], cellsInSubset);
115 const label subsetID = mesh.addCellSubset(newName);
116 forAll(cellsInSubset, i)
117 mesh.addCellToSubset(subsetID, cellsInSubset[i]);
121 //- creating node selections
122 boolList bndVertex(mesh.points().size(), false);
123 forAll(mesh.boundaries(), patchI)
125 label faceI = mesh.boundaries()[patchI].patchStart();
126 const label end = faceI + mesh.boundaries()[patchI].patchSize();
127 for(;faceI<end;++faceI)
129 const face& f = mesh.faces()[faceI];
132 bndVertex[f[pI]] = true;
136 forAll(procBoundaries, patchI)
138 word sName = "InterSurfaceEdgesToProc";
139 sName += help::scalarToText(procBoundaries[patchI].neiProcNo());
140 const label subsetID = mesh.addPointSubset(sName);
142 label faceI = procBoundaries[patchI].patchStart();
143 const label end = faceI + procBoundaries[patchI].patchSize();
144 for(;faceI<end;++faceI)
146 const face& f = faces[faceI];
150 if( bndVertex[f[pI]] )
151 mesh.addPointToSubset(subsetID, f[pI]);
159 // ************************************************************************* //