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