1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "attachPolyTopoChanger.H"
28 #include "polyTopoChange.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 Foam::attachPolyTopoChanger::attachPolyTopoChanger
38 polyTopoChanger(io, mesh)
42 Foam::attachPolyTopoChanger::attachPolyTopoChanger
51 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
54 void Foam::attachPolyTopoChanger::attach(const bool removeEmptyPatches)
58 Pout<< "void attachPolyTopoChanger::attach(): "
59 << "Attaching mesh" << endl;
62 // Save current file instance
63 const fileName oldInst = mesh_.facesInstance();
65 // Execute all polyMeshModifiers
66 changeMesh(false); // no inflation
68 const pointField p = mesh_.oldPoints();
74 Pout<< "Clearing mesh." << endl;
77 if (removeEmptyPatches)
79 // Re-do the boundary patches, removing the ones with zero size
80 const polyBoundaryMesh& oldPatches = mesh_.boundaryMesh();
82 List<polyPatch*> newPatches(oldPatches.size());
83 label nNewPatches = 0;
85 forAll(oldPatches, patchI)
87 if (oldPatches[patchI].size())
89 newPatches[nNewPatches] = oldPatches[patchI].clone
93 oldPatches[patchI].size(),
94 oldPatches[patchI].start()
103 Pout<< "Removing zero-sized patch " << patchI
104 << " named " << oldPatches[patchI].name() << endl;
109 newPatches.setSize(nNewPatches);
111 mesh_.removeBoundary();
112 mesh_.addPatches(newPatches);
115 // Reset the file instance to overwrite the original mesh
116 mesh_.setInstance(oldInst);
120 Pout<< "void attachPolyTopoChanger::attach(): "
121 << "Finished attaching mesh" << endl;
128 // ************************************************************************* //