1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 # include "createMesh.H"
58 bool overwrite = args.options().found("overwrite");
60 word setName(args.additionalArgs()[0]);
63 faceSet candidateSet(mesh, setName);
65 Pout<< "Read " << candidateSet.size() << " faces to remove" << nl
69 labelList candidates(candidateSet.toc());
71 // Face removal engine. No checking for not merging boundary faces.
72 removeFaces faceRemover(mesh, 2);
74 // Get compatible set of faces and connected sets of cells.
76 labelList cellRegionMaster;
77 labelList facesToRemove;
79 faceRemover.compatibleRemoves
88 faceSet compatibleRemoves(mesh, "compatibleRemoves", facesToRemove);
90 Pout<< "Original faces to be removed:" << candidateSet.size() << nl
91 << "New faces to be removed:" << compatibleRemoves.size() << nl
94 Pout<< "Writing new faces to be removed to faceSet "
95 << compatibleRemoves.instance()
96 /compatibleRemoves.local()
97 /compatibleRemoves.name()
100 compatibleRemoves.write();
104 // Read objects in time directory
105 IOobjectList objects(mesh, runTime.timeName());
108 PtrList<volScalarField> vsFlds;
109 ReadFields(mesh, objects, vsFlds);
111 PtrList<volVectorField> vvFlds;
112 ReadFields(mesh, objects, vvFlds);
114 PtrList<volSphericalTensorField> vstFlds;
115 ReadFields(mesh, objects, vstFlds);
117 PtrList<volSymmTensorField> vsymtFlds;
118 ReadFields(mesh, objects, vsymtFlds);
120 PtrList<volTensorField> vtFlds;
121 ReadFields(mesh, objects, vtFlds);
123 // Read surface fields.
124 PtrList<surfaceScalarField> ssFlds;
125 ReadFields(mesh, objects, ssFlds);
127 PtrList<surfaceVectorField> svFlds;
128 ReadFields(mesh, objects, svFlds);
130 PtrList<surfaceSphericalTensorField> sstFlds;
131 ReadFields(mesh, objects, sstFlds);
133 PtrList<surfaceSymmTensorField> ssymtFlds;
134 ReadFields(mesh, objects, ssymtFlds);
136 PtrList<surfaceTensorField> stFlds;
137 ReadFields(mesh, objects, stFlds);
140 // Topo changes container
141 polyTopoChange meshMod(mesh);
143 // Insert mesh refinement into polyTopoChange.
144 faceRemover.setRefinement
152 autoPtr<mapPolyMesh> morphMap = meshMod.changeMesh(mesh, false);
154 mesh.updateMesh(morphMap);
156 // Move mesh (since morphing does not do this)
157 if (morphMap().hasMotionPoints())
159 mesh.movePoints(morphMap().preMotionPoints());
162 // Update numbering of cells/vertices.
163 faceRemover.updateMesh(morphMap);
170 // Take over refinement levels and write to new time directory.
171 Pout<< "Writing mesh to time " << runTime.timeName() << endl;
174 Pout<< "End\n" << endl;
180 // ************************************************************************* //