1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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
29 Decompose point, face and cell sets after the case has been decomposed
31 \*---------------------------------------------------------------------------*/
34 #include "processorMeshes.H"
38 #include "IOobjectList.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 int main(int argc, char *argv[])
44 argList::noParallel();
45 # include "addRegionOption.H"
47 # include "setRootCase.H"
48 # include "createTime.H"
50 Info<< "Time = " << runTime.timeName() << endl;
52 // Determine the processor count directly
54 while (isDir(args.path()/(word("processor") + name(nProcs))))
61 FatalErrorIn(args.executable())
62 << "No processor* directories found"
66 PtrList<Time> databases(nProcs);
68 forAll (databases, procI)
75 Time::controlDictName,
77 args.caseName()/fileName(word("processor") + name(procI))
82 # include "createNamedMesh.H"
84 // Set all times on processor meshes equal to decomposed mesh
85 forAll (databases, procI)
87 databases[procI].setTime(runTime.timeName(), runTime.timeIndex());
90 // Read all meshes and addressing to reconstructed mesh
91 processorMeshes procMeshes(databases, regionName);
93 // Find all sets on complete mesh
96 // Search for list of objects for the time of the mesh
100 mesh.facesInstance(),
101 polyMesh::meshSubDir/"sets"
104 Info<< "Searched : " << mesh.facesInstance()/polyMesh::meshSubDir/"sets"
106 << "Found : " << objects.names() << nl
110 IOobjectList pointObjects(objects.lookupClass(pointSet::typeName));
114 IOobjectList::const_iterator iter = pointObjects.begin();
115 iter != pointObjects.end();
119 // Set not in memory. Load it.
120 pointSet set(*iter());
122 // Go through all processors
123 forAll (procMeshes.meshes(), procI)
125 const labelList& addr = procMeshes.pointProcAddressing()[procI];
127 labelHashSet procSet;
129 forAll (addr, pointI)
131 if (set.found(addr[pointI]))
133 procSet.insert(pointI);
137 if (!procSet.empty())
139 // Set created, write it
140 Info<< "Writing point set " << set.name()
141 << " on processor " << procI << endl;
144 procMeshes.meshes()[procI],
154 IOobjectList faceObjects(objects.lookupClass(faceSet::typeName));
158 IOobjectList::const_iterator iter = faceObjects.begin();
159 iter != faceObjects.end();
163 // Set not in memory. Load it.
164 faceSet set(*iter());
166 // Go through all processors
167 forAll (procMeshes.meshes(), procI)
169 const labelList& addr = procMeshes.faceProcAddressing()[procI];
171 labelHashSet procSet;
175 // Note faceProcAddressing peculiarity:
176 // change of sign and offset. HJ, 7/Mar/2011
177 if (set.found(mag(addr[faceI]) - 1))
179 procSet.insert(faceI);
183 if (!procSet.empty())
185 // Set created, write it
186 Info<< "Writing face set " << set.name()
187 << " on processor " << procI << endl;
190 procMeshes.meshes()[procI],
200 IOobjectList cellObjects(objects.lookupClass(cellSet::typeName));
204 IOobjectList::const_iterator iter = cellObjects.begin();
205 iter != cellObjects.end();
209 // Set not in memory. Load it.
210 cellSet set(*iter());
212 // Go through all processors
213 forAll (procMeshes.meshes(), procI)
215 const labelList& addr = procMeshes.cellProcAddressing()[procI];
217 labelHashSet procSet;
221 if (set.found(addr[cellI]))
223 procSet.insert(cellI);
227 if (!procSet.empty())
229 // Set created, write it
230 Info<< "Writing cell set " << set.name()
231 << " on processor " << procI << endl;
234 procMeshes.meshes()[procI],
245 Info<< "End.\n" << endl;
251 // ************************************************************************* //