OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

mapPatchChange.H

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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::mapPatchChange
00027 
00028 Description
00029     Class containing mesh-to-mesh mapping information after a patch change
00030     operation.
00031 
00032 SourceFiles
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef mapPatchChange_H
00037 #define mapPatchChange_H
00038 
00039 #include "labelList.H"
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 namespace Foam
00044 {
00045 
00046 /*---------------------------------------------------------------------------*\
00047                            Class mapPatchChange Declaration
00048 \*---------------------------------------------------------------------------*/
00049 
00050 class mapPatchChange
00051 {
00052     // Private data
00053 
00054         //- Old patches
00055         const label nOldPatches_;
00056 
00057         //- Patch mapping array
00058         const labelList patchMap_;
00059 
00060 public:
00061 
00062     // Constructors
00063 
00064         //- Construct from components
00065         mapPatchChange(const label nOldPatches, const labelList& patchMap)
00066         :
00067             nOldPatches_(nOldPatches),
00068             patchMap_(patchMap)
00069         {}
00070 
00071 
00072     // Member Functions
00073 
00074         // Access
00075 
00076             //- Number of old patches
00077             label nOldPatches() const
00078             {
00079                 return nOldPatches_;
00080             }
00081 
00082             //- Patch map. Size of current patches.
00083             //  -1  : patch was added
00084             //  >=0 : old position of patch
00085             //  any original patch which is not in the list has been deleted
00086             const labelList& patchMap() const
00087             {
00088                 return patchMap_;
00089             }
00090 
00091 
00092         // Utility functions
00093 
00094             //- labels of added patches
00095             labelList addedPatches() const
00096             {
00097                 labelList added(patchMap_.size());
00098 
00099                 label addedI = 0;
00100 
00101                 forAll(patchMap_, patchI)
00102                 {
00103                     if (patchMap_[patchI] == -1)
00104                     {
00105                         added[addedI++] = patchI;
00106                     }
00107                 }
00108                 added.setSize(addedI);
00109                 return added;
00110             }
00111 
00112             //- labels (on old mesh) of deleted patches
00113             labelList deletedPatches() const
00114             {
00115                 labelList oldToNew(nOldPatches_, -1);
00116 
00117                 // Mark all preserved patches
00118                 forAll(patchMap_, patchI)
00119                 {
00120                     if (patchMap_[patchI] != -1)
00121                     {
00122                         oldToNew[patchMap_[patchI]] = patchI;
00123                     }
00124                 }
00125 
00126                 // Extract -1 elements from oldToNew. These are the deleted
00127                 // patches.
00128                 label deletedI = 0;
00129 
00130                 forAll(oldToNew, oldPatchI)
00131                 {
00132                     if (oldToNew[oldPatchI] == -1)
00133                     {
00134                         oldToNew[deletedI++] = oldPatchI;
00135                     }
00136                 }
00137 
00138                 oldToNew.setSize(deletedI);
00139 
00140                 return oldToNew;
00141             }
00142 };
00143 
00144 
00145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00146 
00147 } // End namespace Foam
00148 
00149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00150 
00151 #endif
00152 
00153 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd