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

mapPolyMesh.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 Description
00025 
00026 \*---------------------------------------------------------------------------*/
00027 
00028 #include "mapPolyMesh.H"
00029 #include <OpenFOAM/polyMesh.H>
00030 
00031 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00032 
00033 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00034 
00035 // Construct from components
00036 Foam::mapPolyMesh::mapPolyMesh
00037 (
00038     const polyMesh& mesh,
00039     const label nOldPoints,
00040     const label nOldFaces,
00041     const label nOldCells,
00042     const labelList& pointMap,
00043     const List<objectMap>& pointsFromPoints,
00044     const labelList& faceMap,
00045     const List<objectMap>& facesFromPoints,
00046     const List<objectMap>& facesFromEdges,
00047     const List<objectMap>& facesFromFaces,
00048     const labelList& cellMap,
00049     const List<objectMap>& cellsFromPoints,
00050     const List<objectMap>& cellsFromEdges,
00051     const List<objectMap>& cellsFromFaces,
00052     const List<objectMap>& cellsFromCells,
00053     const labelList& reversePointMap,
00054     const labelList& reverseFaceMap,
00055     const labelList& reverseCellMap,
00056     const labelHashSet& flipFaceFlux,
00057     const labelListList& patchPointMap,
00058     const labelListList& pointZoneMap,
00059     const labelListList& faceZonePointMap,
00060     const labelListList& faceZoneFaceMap,
00061     const labelListList& cellZoneMap,
00062     const pointField& preMotionPoints,
00063     const labelList& oldPatchStarts,
00064     const labelList& oldPatchNMeshPoints
00065 )
00066 :
00067     mesh_(mesh),
00068     nOldPoints_(nOldPoints),
00069     nOldFaces_(nOldFaces),
00070     nOldCells_(nOldCells),
00071     pointMap_(pointMap),
00072     pointsFromPointsMap_(pointsFromPoints),
00073     faceMap_(faceMap),
00074     facesFromPointsMap_(facesFromPoints),
00075     facesFromEdgesMap_(facesFromEdges),
00076     facesFromFacesMap_(facesFromFaces),
00077     cellMap_(cellMap),
00078     cellsFromPointsMap_(cellsFromPoints),
00079     cellsFromEdgesMap_(cellsFromEdges),
00080     cellsFromFacesMap_(cellsFromFaces),
00081     cellsFromCellsMap_(cellsFromCells),
00082     reversePointMap_(reversePointMap),
00083     reverseFaceMap_(reverseFaceMap),
00084     reverseCellMap_(reverseCellMap),
00085     flipFaceFlux_(flipFaceFlux),
00086     patchPointMap_(patchPointMap),
00087     pointZoneMap_(pointZoneMap),
00088     faceZonePointMap_(faceZonePointMap),
00089     faceZoneFaceMap_(faceZoneFaceMap),
00090     cellZoneMap_(cellZoneMap),
00091     preMotionPoints_(preMotionPoints),
00092     oldPatchSizes_(oldPatchStarts.size()),
00093     oldPatchStarts_(oldPatchStarts),
00094     oldPatchNMeshPoints_(oldPatchNMeshPoints)
00095 {
00096     // Calculate old patch sizes
00097     for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
00098     {
00099         oldPatchSizes_[patchI] =
00100             oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
00101     }
00102 
00103     // Set the last one by hand
00104     const label lastPatchID = oldPatchStarts_.size() - 1;
00105 
00106     oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
00107 
00108     if (polyMesh::debug)
00109     {
00110         if (min(oldPatchSizes_) < 0)
00111         {
00112             FatalErrorIn("mapPolyMesh::mapPolyMesh(...)")
00113                 << "Calculated negative old patch size.  Error in mapping data"
00114                 << abort(FatalError);
00115         }
00116     }
00117 }
00118 
00119 
00120 // Construct from components and optionally reuse storage
00121 Foam::mapPolyMesh::mapPolyMesh
00122 (
00123     const polyMesh& mesh,
00124     const label nOldPoints,
00125     const label nOldFaces,
00126     const label nOldCells,
00127     labelList& pointMap,
00128     List<objectMap>& pointsFromPoints,
00129     labelList& faceMap,
00130     List<objectMap>& facesFromPoints,
00131     List<objectMap>& facesFromEdges,
00132     List<objectMap>& facesFromFaces,
00133     labelList& cellMap,
00134     List<objectMap>& cellsFromPoints,
00135     List<objectMap>& cellsFromEdges,
00136     List<objectMap>& cellsFromFaces,
00137     List<objectMap>& cellsFromCells,
00138     labelList& reversePointMap,
00139     labelList& reverseFaceMap,
00140     labelList& reverseCellMap,
00141     labelHashSet& flipFaceFlux,
00142     labelListList& patchPointMap,
00143     labelListList& pointZoneMap,
00144     labelListList& faceZonePointMap,
00145     labelListList& faceZoneFaceMap,
00146     labelListList& cellZoneMap,
00147     pointField& preMotionPoints,
00148     labelList& oldPatchStarts,
00149     labelList& oldPatchNMeshPoints,
00150     const bool reUse
00151 )
00152 :
00153     mesh_(mesh),
00154     nOldPoints_(nOldPoints),
00155     nOldFaces_(nOldFaces),
00156     nOldCells_(nOldCells),
00157     pointMap_(pointMap, reUse),
00158     pointsFromPointsMap_(pointsFromPoints, reUse),
00159     faceMap_(faceMap, reUse),
00160     facesFromPointsMap_(facesFromPoints, reUse),
00161     facesFromEdgesMap_(facesFromEdges, reUse),
00162     facesFromFacesMap_(facesFromFaces, reUse),
00163     cellMap_(cellMap, reUse),
00164     cellsFromPointsMap_(cellsFromPoints, reUse),
00165     cellsFromEdgesMap_(cellsFromEdges, reUse),
00166     cellsFromFacesMap_(cellsFromFaces, reUse),
00167     cellsFromCellsMap_(cellsFromCells, reUse),
00168     reversePointMap_(reversePointMap, reUse),
00169     reverseFaceMap_(reverseFaceMap, reUse),
00170     reverseCellMap_(reverseCellMap, reUse),
00171     flipFaceFlux_(flipFaceFlux),
00172     patchPointMap_(patchPointMap, reUse),
00173     pointZoneMap_(pointZoneMap, reUse),
00174     faceZonePointMap_(faceZonePointMap, reUse),
00175     faceZoneFaceMap_(faceZoneFaceMap, reUse),
00176     cellZoneMap_(cellZoneMap, reUse),
00177     preMotionPoints_(preMotionPoints, reUse),
00178     oldPatchSizes_(oldPatchStarts.size()),
00179     oldPatchStarts_(oldPatchStarts, reUse),
00180     oldPatchNMeshPoints_(oldPatchNMeshPoints, reUse)
00181 {
00182     // Calculate old patch sizes
00183     for (label patchI = 0; patchI < oldPatchStarts_.size() - 1; patchI++)
00184     {
00185         oldPatchSizes_[patchI] =
00186             oldPatchStarts_[patchI + 1] - oldPatchStarts_[patchI];
00187     }
00188 
00189     // Set the last one by hand
00190     const label lastPatchID = oldPatchStarts_.size() - 1;
00191 
00192     oldPatchSizes_[lastPatchID] = nOldFaces_ - oldPatchStarts_[lastPatchID];
00193 
00194     if (polyMesh::debug)
00195     {
00196         if (min(oldPatchSizes_) < 0)
00197         {
00198             FatalErrorIn("mapPolyMesh::mapPolyMesh(...)")
00199                 << "Calculated negative old patch size.  Error in mapping data"
00200                 << abort(FatalError);
00201         }
00202     }
00203 }
00204 
00205 
00206 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00207 
00208 
00209 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines