FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

attachPolyTopoChanger.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "attachPolyTopoChanger.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <dynamicMesh/polyTopoChange.H>
00029 
00030 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00031 
00032 Foam::attachPolyTopoChanger::attachPolyTopoChanger
00033 (
00034     const IOobject& io,
00035     polyMesh& mesh
00036 )
00037 :
00038     polyTopoChanger(io, mesh)
00039 {}
00040 
00041 
00042 Foam::attachPolyTopoChanger::attachPolyTopoChanger
00043 (
00044     polyMesh& mesh
00045 )
00046 :
00047     polyTopoChanger(mesh)
00048 {}
00049 
00050 
00051 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00052 
00053 //- Attach mesh
00054 void Foam::attachPolyTopoChanger::attach(const bool removeEmptyPatches)
00055 {
00056     if (debug)
00057     {
00058         Pout<< "void attachPolyTopoChanger::attach(): "
00059             << "Attaching mesh" << endl;
00060     }
00061 
00062     // Save current file instance
00063     const fileName oldInst = mesh_.facesInstance();
00064 
00065     // Execute all polyMeshModifiers
00066     changeMesh(false);  // no inflation
00067 
00068     const pointField p = mesh_.oldPoints();
00069 
00070     mesh_.movePoints(p);
00071 
00072     if (debug)
00073     {
00074         Pout << "Clearing mesh." << endl;
00075     }
00076 
00077     if (removeEmptyPatches)
00078     {
00079         // Re-do the boundary patches, removing the ones with zero size
00080         const polyBoundaryMesh& oldPatches = mesh_.boundaryMesh();
00081 
00082         List<polyPatch*> newPatches(oldPatches.size());
00083         label nNewPatches = 0;
00084 
00085         forAll (oldPatches, patchI)
00086         {
00087             if (oldPatches[patchI].size())
00088             {
00089                 newPatches[nNewPatches] = oldPatches[patchI].clone
00090                 (
00091                     mesh_.boundaryMesh(),
00092                     nNewPatches,
00093                     oldPatches[patchI].size(),
00094                     oldPatches[patchI].start()
00095                 ).ptr();
00096 
00097                 nNewPatches++;
00098             }
00099             else
00100             {
00101                 if (debug)
00102                 {
00103                     Pout<< "Removing zero-sized patch " << patchI
00104                         << " named " << oldPatches[patchI].name() << endl;
00105                 }
00106             }
00107         }
00108 
00109         newPatches.setSize(nNewPatches);
00110 
00111         mesh_.removeBoundary();
00112         mesh_.addPatches(newPatches);
00113     }
00114 
00115     // Reset the file instance to overwrite the original mesh
00116     mesh_.setInstance(oldInst);
00117 
00118     if (debug)
00119     {
00120         Pout<< "void attachPolyTopoChanger::attach(): "
00121             << "Finished attaching mesh" << endl;
00122     }
00123 
00124     mesh_.checkMesh();
00125 }
00126 
00127 
00128 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines