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

polyMeshAdder.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::polyMeshAdder
00026 
00027 Description
00028     Adds two meshes without using any polyMesh morphing.
00029 
00030     Gets faces to couple as faceCoupleInfo which is list of faces on both
00031     meshes. Returns map from last mesh addition.
00032 
00033 SourceFiles
00034     polyMeshAdder.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef polyMeshAdder_H
00039 #define polyMeshAdder_H
00040 
00041 #include <OpenFOAM/autoPtr.H>
00042 #include <OpenFOAM/polyMesh.H>
00043 #include <OpenFOAM/mapAddedPolyMesh.H>
00044 #include "faceCoupleInfo.H"
00045 #include <OpenFOAM/SortableList.H>
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 namespace Foam
00050 {
00051 
00052 // Forward declaration of classes
00053 class IOobject;
00054 class polyTopoChange;
00055 
00056 /*---------------------------------------------------------------------------*\
00057                         Class polyMeshAdder Declaration
00058 \*---------------------------------------------------------------------------*/
00059 
00060 class polyMeshAdder
00061 {
00062 
00063 private:
00064     // Private data
00065 
00066 
00067     // Private Member Functions
00068 
00069         //- Append all elements of a list to a DynamicList
00070         template<class T>
00071         static void append(const List<T>&, DynamicList<T>&);
00072 
00073         //- Append all mapped elements of a list to a DynamicList
00074         static void append
00075         (
00076             const labelList& map,
00077             const labelList& lst,
00078             DynamicList<label>&
00079         );
00080 
00081         //- Append all mapped elements of a list to a DynamicList that are
00082         //  not already present in the sorted list.
00083         static void append
00084         (
00085             const labelList& map,
00086             const labelList& lst,
00087             const SortableList<label>& sortedLst,
00088             DynamicList<label>&
00089         );
00090 
00091         //- Index of patch in allPatches. Add if nonexisting.
00092         static label patchIndex
00093         (
00094             const polyPatch&,
00095             DynamicList<word>& allPatchNames,
00096             DynamicList<word>& allPatchTypes
00097         );
00098 
00099         //- Index of zone in all zones
00100         static label zoneIndex(const word&, DynamicList<word>&);
00101 
00102         static void mergePatchNames
00103         (
00104             const polyBoundaryMesh& patches0,
00105             const polyBoundaryMesh& patches1,
00106 
00107             DynamicList<word>& allPatchNames,
00108             DynamicList<word>& allPatchTypes,
00109 
00110             labelList& from1ToAllPatches,
00111             labelList& fromAllTo1Patches
00112         );
00113 
00114         //- Get starts of patches
00115         static labelList getPatchStarts(const polyBoundaryMesh&);
00116         //- Get sizes of patches
00117         static labelList getPatchSizes(const polyBoundaryMesh&);
00118 
00119         static List<polyPatch*> combinePatches
00120         (
00121             const polyMesh& mesh0,
00122             const polyMesh& mesh1,
00123             const polyBoundaryMesh& allBoundaryMesh,
00124             const label nAllPatches,
00125             const labelList& fromAllTo1Patches,
00126 
00127             const label nInternalFaces,
00128             const labelList& nFaces,
00129 
00130             labelList& from0ToAllPatches,
00131             labelList& from1ToAllPatches
00132         );
00133 
00134         //- Determine order for internalFaces to be upper-triangular.
00135         //  Does not change order of external faces.
00136         static labelList getFaceOrder
00137         (
00138             const cellList& cells,
00139             const label nInternalFaces,
00140             const labelList& owner,
00141             const labelList& neighbour
00142         );
00143 
00144         //- Extends face f with split points. cutEdgeToPoints gives for every
00145         // edge the points introduced inbetween the endpoints.
00146         static void insertVertices
00147         (
00148             const edgeLookup& cutEdgeToPoints,
00149             const Map<label>& meshToMaster,
00150             const labelList& masterToCutPoints,
00151             const face& masterFace,
00152 
00153             DynamicList<label>& workFace,
00154             face& f
00155         );
00156 
00157         //- Merges primitives of two meshes.
00158         static void mergePrimitives
00159         (
00160             const polyMesh& mesh0,
00161             const polyMesh& mesh1,
00162             const faceCoupleInfo& coupleInfo,
00163 
00164             const label nAllPatches,
00165             const labelList& fromAllTo1Patches,
00166             const labelList& from1ToAllPatches,
00167 
00168             pointField& allPoints,
00169             labelList& from0ToAllPoints,
00170             labelList& from1ToAllPoints,
00171 
00172             faceList& allFaces,
00173             labelList& allOwner,
00174             labelList& allNeighbour,
00175             label& nInternalFaces,
00176             labelList& nFacesPerPatch,
00177             label& nCells,
00178 
00179             labelList& from0ToAllFaces,
00180             labelList& from1ToAllFaces,
00181             labelList& from1ToAllCells
00182         );
00183 
00184         //- Merge point zones
00185         static void mergePointZones
00186         (
00187             const pointZoneMesh& pz0,
00188             const pointZoneMesh& pz1,
00189             const labelList& from0ToAllPoints,
00190             const labelList& from1ToAllPoints,
00191 
00192             DynamicList<word>& zoneNames,
00193             labelList& from1ToAll,
00194             List<DynamicList<label> >& pzPoints
00195         );
00196 
00197         //- Merge face zones
00198         static void mergeFaceZones
00199         (
00200             const faceZoneMesh& fz0,
00201             const faceZoneMesh& fz1,
00202             const labelList& from0ToAllFaces,
00203             const labelList& from1ToAllFaces,
00204 
00205             DynamicList<word>& zoneNames,
00206             labelList& from1ToAll,
00207             List<DynamicList<label> >& fzFaces,
00208             List<DynamicList<bool> >& fzFlips
00209         );
00210 
00211         //- Merge cell zones
00212         static void mergeCellZones
00213         (
00214             const cellZoneMesh& cz0,
00215             const cellZoneMesh& cz1,
00216             const labelList& from1ToAllCells,
00217 
00218             DynamicList<word>& zoneNames,
00219             labelList& from1ToAll,
00220             List<DynamicList<label> >& czCells
00221         );
00222 
00223         //- Merge point/face/cell zone information
00224         static void mergeZones
00225         (
00226             const polyMesh& mesh0,
00227             const polyMesh& mesh1,
00228             const labelList& from0ToAllPoints,
00229             const labelList& from0ToAllFaces,
00230             const labelList& from1ToAllPoints,
00231             const labelList& from1ToAllFaces,
00232             const labelList& from1ToAllCells,
00233 
00234             DynamicList<word>& pointZoneNames,
00235             List<DynamicList<label> >& pzPoints,
00236 
00237             DynamicList<word>& faceZoneNames,
00238             List<DynamicList<label> >& fzFaces,
00239             List<DynamicList<bool> >& fzFlips,
00240 
00241             DynamicList<word>& cellZoneNames,
00242             List<DynamicList<label> >& czCells
00243         );
00244 
00245         //- Create new zones and add to new mesh.
00246         static void addZones
00247         (
00248             const DynamicList<word>& pointZoneNames,
00249             const List<DynamicList<label> >& pzPoints,
00250 
00251             const DynamicList<word>& faceZoneNames,
00252             const List<DynamicList<label> >& fzFaces,
00253             const List<DynamicList<bool> >& fzFlips,
00254 
00255             const DynamicList<word>& cellZoneNames,
00256             const List<DynamicList<label> >& czCells,
00257 
00258             polyMesh& mesh
00259         );
00260 
00261 public:
00262 
00263 
00264     // Member Functions
00265 
00266 
00267         //- Add two polyMeshes. Returns new polyMesh and map construct.
00268         static autoPtr<polyMesh> add
00269         (
00270             const IOobject& io,
00271             const polyMesh& mesh0,
00272             const polyMesh& mesh1,
00273             const faceCoupleInfo& coupleInfo,
00274             autoPtr<mapAddedPolyMesh>& mapPtr
00275         );
00276 
00277         //- Inplace add mesh to polyMesh. Returns map construct.
00278         static autoPtr<mapAddedPolyMesh> add
00279         (
00280             polyMesh& mesh0,
00281             const polyMesh& mesh1,
00282             const faceCoupleInfo& coupleInfo,
00283             const bool validBoundary = true
00284         );
00285 
00286         // Point merging
00287 
00288             //- Find topologically&geometrically shared points.
00289             //  - should only be called for parallel correct mesh
00290             //    (since uses mesh.globalData)
00291             //  - returns Map from point to master point (all in mesh point
00292             //    labels) for any sets of points that need to be merged.
00293             static Map<label> findSharedPoints
00294             (
00295                 const polyMesh&,
00296                 const scalar mergeTol
00297             );
00298 
00299             //- Helper: Merge points.
00300             //  - Gets map from point to destination point
00301             //  - Removes all points that don't map to themselves
00302             //  - Modifies all faces that use the points to be removed.
00303             static void mergePoints
00304             (
00305                 const polyMesh&,
00306                 const Map<label>& pointToMaster,
00307                 polyTopoChange& meshMod
00308             );
00309 };
00310 
00311 
00312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00313 
00314 } // End namespace Foam
00315 
00316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00317 
00318 #ifdef NoRepository
00319 #   include <dynamicMesh/polyMeshAdderTemplates.C>
00320 #endif
00321 
00322 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00323 
00324 #endif
00325 
00326 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines