1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 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
26 Utility to remove faces (combines cells on both sides).
28 Takes faceSet of candidates for removal and writes faceSet with faces that
29 will actually be removed. (because e.g. would cause two faces between the
30 same cells). See removeFaces in dynamicMesh library for constraints.
32 \*---------------------------------------------------------------------------*/
36 #include "polyTopoChange.H"
38 #include "removeFaces.H"
39 #include "ReadFields.H"
40 #include "volFields.H"
41 #include "surfaceFields.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 int main(int argc, char *argv[])
51 Foam::argList::validOptions.insert("overwrite", "");
52 Foam::argList::validArgs.append("faceSet");
54 # include "setRootCase.H"
55 # include "createTime.H"
56 runTime.functionObjects().off();
57 # include "createMesh.H"
58 const word oldInstance = mesh.pointsInstance();
60 bool overwrite = args.optionFound("overwrite");
62 word setName(args.additionalArgs()[0]);
65 faceSet candidateSet(mesh, setName);
67 Pout<< "Read " << candidateSet.size() << " faces to remove" << nl
71 labelList candidates(candidateSet.toc());
73 // Face removal engine. No checking for not merging boundary faces.
74 removeFaces faceRemover(mesh, 2);
76 // Get compatible set of faces and connected sets of cells.
78 labelList cellRegionMaster;
79 labelList facesToRemove;
81 faceRemover.compatibleRemoves
90 faceSet compatibleRemoves(mesh, "compatibleRemoves", facesToRemove);
92 Pout<< "Original faces to be removed:" << candidateSet.size() << nl
93 << "New faces to be removed:" << compatibleRemoves.size() << nl
96 Pout<< "Writing new faces to be removed to faceSet "
97 << compatibleRemoves.instance()
98 /compatibleRemoves.local()
99 /compatibleRemoves.name()
102 compatibleRemoves.write();
106 // Read objects in time directory
107 IOobjectList objects(mesh, runTime.timeName());
110 PtrList<volScalarField> vsFlds;
111 ReadFields(mesh, objects, vsFlds);
113 PtrList<volVectorField> vvFlds;
114 ReadFields(mesh, objects, vvFlds);
116 PtrList<volSphericalTensorField> vstFlds;
117 ReadFields(mesh, objects, vstFlds);
119 PtrList<volSymmTensorField> vsymtFlds;
120 ReadFields(mesh, objects, vsymtFlds);
122 PtrList<volTensorField> vtFlds;
123 ReadFields(mesh, objects, vtFlds);
125 // Read surface fields.
126 PtrList<surfaceScalarField> ssFlds;
127 ReadFields(mesh, objects, ssFlds);
129 PtrList<surfaceVectorField> svFlds;
130 ReadFields(mesh, objects, svFlds);
132 PtrList<surfaceSphericalTensorField> sstFlds;
133 ReadFields(mesh, objects, sstFlds);
135 PtrList<surfaceSymmTensorField> ssymtFlds;
136 ReadFields(mesh, objects, ssymtFlds);
138 PtrList<surfaceTensorField> stFlds;
139 ReadFields(mesh, objects, stFlds);
142 // Topo changes container
143 polyTopoChange meshMod(mesh);
145 // Insert mesh refinement into polyTopoChange.
146 faceRemover.setRefinement
154 autoPtr<mapPolyMesh> morphMap = meshMod.changeMesh(mesh, false);
156 mesh.updateMesh(morphMap);
158 // Move mesh (since morphing does not do this)
159 if (morphMap().hasMotionPoints())
161 mesh.movePoints(morphMap().preMotionPoints());
164 // Update numbering of cells/vertices.
165 faceRemover.updateMesh(morphMap);
173 mesh.setInstance(oldInstance);
176 // Take over refinement levels and write to new time directory.
177 Pout<< "Writing mesh to time " << runTime.timeName() << endl;
180 Pout<< "End\n" << endl;
186 // ************************************************************************* //