1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-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 Utility to remove faces (combines cells on both sides).
27 Takes faceSet of candidates for removal and writes faceSet with faces that
28 will actually be removed. (because e.g. would cause two faces between the
29 same cells). See removeFaces in dynamicMesh library for constraints.
31 \*---------------------------------------------------------------------------*/
35 #include "polyTopoChange.H"
37 #include "removeFaces.H"
38 #include "ReadFields.H"
39 #include "volFields.H"
40 #include "surfaceFields.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 int main(int argc, char *argv[])
50 # include "addOverwriteOption.H"
51 argList::validArgs.append("faceSet");
53 # include "setRootCase.H"
54 # include "createTime.H"
55 runTime.functionObjects().off();
56 # include "createMesh.H"
57 const word oldInstance = mesh.pointsInstance();
59 const word setName = args[1];
60 const bool overwrite = args.optionFound("overwrite");
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);
171 mesh.setInstance(oldInstance);
174 // Take over refinement levels and write to new time directory.
175 Pout<< "Writing mesh to time " << runTime.timeName() << endl;
178 Pout<< "End\n" << endl;
184 // ************************************************************************* //