OpenFOAM logo
Open Source CFD Toolkit

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-2005 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 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 // Class forward declarations
00051 class IOobject;
00052 class faceCoupleInfo;
00053 
00054 /*---------------------------------------------------------------------------*\
00055                            Class polyMeshAdder Declaration
00056 \*---------------------------------------------------------------------------*/
00057 
00058 class polyMeshAdder
00059 {
00060 
00061 private:
00062     // Private data
00063 
00064         //- Current set of combined patches
00065         DynamicList<word> allPatchNames_;
00066 
00067         //- Current set of combined patch types.
00068         DynamicList<word> allPatchTypes_;
00069 
00070 
00071         //- After adding: map from new to original meshes.
00072         mapAddedPolyMesh map_;
00073 
00074 
00075     // Private Member Functions
00076 
00077         //- Append all elements of a list to a DynamicList
00078         template<class T>
00079         static void append(const List<T>&, DynamicList<T>&);
00080 
00081         //- Append all mapped elements of a list to a DynamicList
00082         static void append
00083         (
00084             const labelList& map,
00085             const labelList& lst,
00086             DynamicList<label>&
00087         );
00088 
00089         //- Return the vertices inbetween masterEdge endpoints in order.
00090         static labelList stringEdges
00091         (
00092             const pointField& cutPoints,
00093             const edge& meshEdge,
00094             const pointField& meshPoints,
00095             const labelList& cutToAllPoints,
00096             const edgeList& cutEdges,
00097             const labelList& cutEdgeLabels
00098         );
00099 
00100         //- Extract processor neighbour label from patchname
00101         static label neighbourProcNo(const word&);
00102 
00103         //- Index of patch in allPatches. Add if nonexisting.
00104         label patchIndex(const polyPatch&);
00105 
00106         //- Index of zone in all zones
00107         static label zoneIndex(const word&, DynamicList<word>&);
00108 
00109         //- Clone patch with new polyBoundaryMesh and size, start. Returns new
00110         //  patch index or -1 (if size was 0)
00111         static label clonePatch
00112         (
00113             const polyPatch& pp,
00114             const label start,
00115             const label size,
00116             const polyBoundaryMesh&,
00117             DynamicList<polyPatch*>&
00118         );
00119 
00120         //- Determine order for internalFaces to be upper-triangular.
00121         //  Does not change order of external faces.
00122         static labelList getFaceOrder
00123         (
00124             const cellList& cells,
00125             const label nInternalFaces,
00126             const labelList& owner,
00127             const labelList& neighbour
00128         );
00129 
00130         //- Inverts face-cell addressing to create cell-face addressing.
00131         static void makeCells
00132         (
00133             const label nCells,
00134             const labelList& owner,
00135             const labelList& neighbour,
00136             cellList& cells
00137         );
00138 
00139         //- Merge point zones
00140         static void mergePointZones
00141         (
00142             const pointZoneMesh& pz0,
00143             const pointZoneMesh& pz1,
00144             const labelList& from0ToAllPoints,
00145             const labelList& from1ToAllPoints,
00146 
00147             DynamicList<word>& zoneNames,
00148             labelList& from1ToAll,
00149             List<DynamicList<label> >& pzPoints
00150         );
00151 
00152         //- Merge face zones
00153         static void mergeFaceZones
00154         (
00155             const faceZoneMesh& fz0,
00156             const faceZoneMesh& fz1,
00157             const labelList& from0ToAllFaces,
00158             const labelList& from1ToAllFaces,
00159 
00160             DynamicList<word>& zoneNames,
00161             labelList& from1ToAll,
00162             List<DynamicList<label> >& fzFaces,
00163             List<DynamicList<bool> >& fzFlips
00164         );
00165 
00166         //- Merge cell zones
00167         static void mergeCellZones
00168         (
00169             const cellZoneMesh& cz0,
00170             const cellZoneMesh& cz1,
00171             const labelList& from1ToAllCells,
00172 
00173             DynamicList<word>& zoneNames,
00174             labelList& from1ToAll,
00175             List<DynamicList<label> >& czCells
00176         );
00177 
00178         void mergePatchNames
00179         (
00180             const polyBoundaryMesh& patches0,
00181             const polyBoundaryMesh& patches1,
00182 
00183             labelList& from1ToAllPatches,
00184             labelList& fromAllTo1Patches
00185         );
00186 
00187         //- Merges primitives of two meshes.
00188         void mergePrimitives
00189         (
00190             const polyMesh& mesh0,
00191             const polyMesh& mesh1,
00192             const faceCoupleInfo& coupleInfo,
00193 
00194             const labelList& fromAllTo1Patches,
00195             const labelList& from1ToAllPatches,
00196 
00197             pointField& allPoints,
00198             labelList& from0ToAllPoints,
00199             labelList& from1ToAllPoints,
00200 
00201             faceList& allFaces,
00202             labelList& from0ToAllFaces,
00203             labelList& from1ToAllFaces,
00204             labelList& nFaces,
00205 
00206             cellList& allCells,
00207             labelList& from1ToAllCells
00208         ) const;
00209 
00210         //- Merge point/face/cell zone information
00211         static void mergeZones
00212         (
00213             const polyMesh& mesh0,
00214             const polyMesh& mesh1,
00215             const labelList& from0ToAllPoints,
00216             const labelList& from0ToAllFaces,
00217             const labelList& from1ToAllPoints,
00218             const labelList& from1ToAllFaces,
00219             const labelList& from1ToAllCells,
00220 
00221             DynamicList<word>& pointZoneNames,
00222             List<DynamicList<label> >& pzPoints,
00223 
00224             DynamicList<word>& faceZoneNames,
00225             List<DynamicList<label> >& fzFaces,
00226             List<DynamicList<bool> >& fzFlips,
00227 
00228             DynamicList<word>& cellZoneNames,
00229             List<DynamicList<label> >& czCells
00230         );
00231 
00232         List<polyPatch*> combinePatches
00233         (
00234             const polyMesh& mesh0,
00235             const polyMesh& mesh1,
00236             const polyBoundaryMesh& allBoundaryMesh,
00237             const labelList& fromAllTo1Patches,
00238 
00239             const label nInternalFaces,
00240             const labelList& nFaces,
00241 
00242             labelList& from0ToAllPatches,
00243             labelList& from1ToAllPatches
00244         ) const;
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 protected:
00263 
00264     // Used by fvMeshAdder
00265 
00266         //- Do all but setting the patches
00267         List<polyPatch*> addWithoutPatches
00268         (
00269             polyMesh& mesh0,
00270             const polyMesh& mesh1,
00271             const faceCoupleInfo& coupleInfo
00272         );
00273 
00274 public:
00275 
00276     // Constructors
00277 
00278         //- Construct null
00279         polyMeshAdder();
00280 
00281 
00282     // Member Functions
00283 
00284         const mapAddedPolyMesh& map() const
00285         {
00286             return map_;
00287         }
00288 
00289         //- Add two polyMeshes.
00290         autoPtr<polyMesh> add
00291         (
00292             const IOobject& io,
00293             const polyMesh& mesh0,
00294             const polyMesh& mesh1,
00295             const faceCoupleInfo& coupleInfo
00296         );
00297 
00298         //- Inplace add mesh to polyMesh.
00299         void add
00300         (
00301             polyMesh& mesh0,
00302             const polyMesh& mesh1,
00303             const faceCoupleInfo& coupleInfo
00304         );
00305 };
00306 
00307 
00308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00309 
00310 } // End namespace Foam
00311 
00312 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00313 
00314 #ifdef NoRepository
00315 #   include "polyMeshAdderTemplates.C"
00316 #endif
00317 
00318 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00319 
00320 #endif
00321 
00322 // ************************************************************************* //
For further information go to www.openfoam.org