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

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