ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / dynamicMesh / polyTopoChange / attachPolyTopoChanger / attachPolyTopoChanger.C
blobeb4a2eb36d3a4efbdeeabca43a32750f4d7a9e9b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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"
27 #include "polyMesh.H"
28 #include "polyTopoChange.H"
30 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
32 Foam::attachPolyTopoChanger::attachPolyTopoChanger
34     const IOobject& io,
35     polyMesh& mesh
38     polyTopoChanger(io, mesh)
42 Foam::attachPolyTopoChanger::attachPolyTopoChanger
44     polyMesh& mesh
47     polyTopoChanger(mesh)
51 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
53 //- Attach mesh
54 void Foam::attachPolyTopoChanger::attach(const bool removeEmptyPatches)
56     if (debug)
57     {
58         Pout<< "void attachPolyTopoChanger::attach(): "
59             << "Attaching mesh" << endl;
60     }
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();
70     mesh_.movePoints(p);
72     if (debug)
73     {
74         Pout<< "Clearing mesh." << endl;
75     }
77     if (removeEmptyPatches)
78     {
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)
86         {
87             if (oldPatches[patchI].size())
88             {
89                 newPatches[nNewPatches] = oldPatches[patchI].clone
90                 (
91                     mesh_.boundaryMesh(),
92                     nNewPatches,
93                     oldPatches[patchI].size(),
94                     oldPatches[patchI].start()
95                 ).ptr();
97                 nNewPatches++;
98             }
99             else
100             {
101                 if (debug)
102                 {
103                     Pout<< "Removing zero-sized patch " << patchI
104                         << " named " << oldPatches[patchI].name() << endl;
105                 }
106             }
107         }
109         newPatches.setSize(nNewPatches);
111         mesh_.removeBoundary();
112         mesh_.addPatches(newPatches);
113     }
115     // Reset the file instance to overwrite the original mesh
116     mesh_.setInstance(oldInst);
118     if (debug)
119     {
120         Pout<< "void attachPolyTopoChanger::attach(): "
121             << "Finished attaching mesh" << endl;
122     }
124     mesh_.checkMesh();
128 // ************************************************************************* //