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
25 \*---------------------------------------------------------------------------*/
27 #include "attachPolyTopoChanger.H"
29 #include "polyTopoChange.H"
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 Foam::attachPolyTopoChanger::attachPolyTopoChanger
39 polyTopoChanger(io, mesh)
43 Foam::attachPolyTopoChanger::attachPolyTopoChanger
52 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
55 void Foam::attachPolyTopoChanger::attach(const bool removeEmptyPatches)
59 Pout<< "void attachPolyTopoChanger::attach(): "
60 << "Attaching mesh" << endl;
63 // Save current file instance
64 const fileName oldInst = mesh_.facesInstance();
66 // Execute all polyMeshModifiers
67 changeMesh(false); // no inflation
69 const pointField p = mesh_.oldPoints();
75 Pout << "Clearing mesh." << endl;
78 if (removeEmptyPatches)
80 // Re-do the boundary patches, removing the ones with zero size
81 const polyBoundaryMesh& oldPatches = mesh_.boundaryMesh();
83 List<polyPatch*> newPatches(oldPatches.size());
84 label nNewPatches = 0;
86 forAll (oldPatches, patchI)
88 if (oldPatches[patchI].size())
90 newPatches[nNewPatches] = oldPatches[patchI].clone
94 oldPatches[patchI].size(),
95 oldPatches[patchI].start()
104 Pout<< "Removing zero-sized patch " << patchI
105 << " named " << oldPatches[patchI].name() << endl;
110 newPatches.setSize(nNewPatches);
112 mesh_.removeBoundary();
113 mesh_.addPatches(newPatches);
116 // Reset the file instance to overwrite the original mesh
117 mesh_.setInstance(oldInst);
121 Pout<< "void attachPolyTopoChanger::attach(): "
122 << "Finished attaching mesh" << endl;
129 // ************************************************************************* //