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

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