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

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