1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "attachPolyTopoChanger.H"
28 #include "polyTopoChange.H"
29 #include "mapPolyMesh.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
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 // ************************************************************************* //