OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

directMappedPolyPatch.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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     directMappedPolyPatch.C
00027 
00028 Description
00029     Determines a mapping between patch face centres and mesh cell centres and
00030     processors they're on.
00031 
00032     Note: storage is not optimal. It stores all face centres and cells on
00033     all processors to keep the addressing calculation simple.
00034 
00035 SourceFiles
00036     directMappedPolyPatch.C
00037 
00038 \*---------------------------------------------------------------------------*/
00039 
00040 #ifndef directMappedPolyPatch_H
00041 #define directMappedPolyPatch_H
00042 
00043 #include "polyPatch.H"
00044 #include "dataSchedule.H"
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 /*---------------------------------------------------------------------------*\
00052                       Class directMappedPolyPatch Declaration
00053 \*---------------------------------------------------------------------------*/
00054 
00055 class directMappedPolyPatch
00056 :
00057     public polyPatch
00058 {
00059     // Private data
00060 
00061         //- Offset vector
00062         const vector offset_;
00063 
00064 
00065         // Derived information
00066 
00067             //- Communication schedule
00068             mutable autoPtr<List<labelPair> > schedulePtr_;
00069 
00070             //- Cells to sample per processor
00071             mutable autoPtr<labelListList> sendCellLabelsPtr_;
00072 
00073             //- Patch faces to receive per processor
00074             mutable autoPtr<labelListList> receiveFaceLabelsPtr_;
00075 
00076 
00077 
00078     // Private Member Functions
00079 
00080         //- Collect single list of samples and originating processor+face.
00081         void collectSamples
00082         (
00083             pointField&,
00084             labelList& patchFaceProcs,
00085             labelList& patchFaces
00086         ) const;
00087 
00088         //- Find cells containing samples
00089         void findSamples
00090         (
00091             const pointField&,
00092             labelList& sampleCellProcs,
00093             labelList& sampleCells
00094         ) const;
00095 
00096         //- Calculate matching
00097         void calcMapping() const;
00098 
00099 
00100 protected:
00101 
00102         void clearOut();
00103 
00104         //- Initialise the calculation of the patch geometry
00105         virtual void initGeometry()
00106         {
00107             clearOut();
00108         }
00109 
00110         //- Calculate the patch geometry
00111         virtual void calcGeometry()
00112         {
00113             clearOut();
00114         }
00115 
00116         //- Initialise the patches for moving points
00117         virtual void initMovePoints(const pointField&)
00118         {
00119             clearOut();
00120         }
00121 
00122         //- Correct patches after moving points
00123         virtual void movePoints(const pointField& p)
00124         {
00125             clearOut();
00126         }
00127 
00128         //- Initialise the update of the patch topology
00129         virtual void initUpdateMesh()
00130         {
00131             clearOut();
00132         }
00133 
00134         //- Update of the patch topology
00135         virtual void updateMesh()
00136         {
00137             clearOut();
00138         }
00139 
00140 
00141 public:
00142 
00143     //- Runtime type information
00144     TypeName("directMappedPatch");
00145 
00146 
00147     // Constructors
00148 
00149         //- Construct from components
00150         directMappedPolyPatch
00151         (
00152             const word& name,
00153             const label size,
00154             const label start,
00155             const label index,
00156             const polyBoundaryMesh& bm
00157         );
00158 
00159         //- Construct from Istream
00160         directMappedPolyPatch
00161         (
00162             Istream&,
00163             const label index,
00164             const polyBoundaryMesh&
00165         );
00166 
00167         //- Construct from dictionary
00168         directMappedPolyPatch
00169         (
00170             const word& name,
00171             const dictionary& dict,
00172             const label index,
00173             const polyBoundaryMesh& bm
00174         );
00175 
00176         //- Construct as copy, resetting the boundary mesh
00177         directMappedPolyPatch
00178         (
00179             const directMappedPolyPatch&,
00180             const polyBoundaryMesh&
00181         );
00182 
00183         //- Construct given the original patch and resetting the
00184         //  face list and boundary mesh information
00185         directMappedPolyPatch
00186         (
00187             const directMappedPolyPatch& pp,
00188             const polyBoundaryMesh& bm,
00189             const label index,
00190             const label newSize,
00191             const label newStart
00192         );
00193 
00194         //- Construct and return a clone, resetting the boundary mesh
00195         virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
00196         {
00197             return autoPtr<polyPatch>(new directMappedPolyPatch(*this, bm));
00198         }
00199 
00200         //- Construct and return a clone, resetting the face list
00201         //  and boundary mesh
00202         virtual autoPtr<polyPatch> clone
00203         (
00204             const polyBoundaryMesh& bm,
00205             const label index,
00206             const label newSize,
00207             const label newStart
00208         ) const
00209         {
00210             return autoPtr<polyPatch>
00211             (
00212                 new directMappedPolyPatch(*this, bm, index, newSize, newStart)
00213             );
00214         }
00215 
00216 
00217     // Destructor
00218 
00219         ~directMappedPolyPatch();
00220 
00221 
00222     // Member functions
00223 
00224         //- Offset vector (from patch faces to internal cells)
00225         const vector& offset() const
00226         {
00227             return offset_;
00228         }
00229 
00230         //- Access to communication.
00231         const List<labelPair>& schedule() const
00232         {
00233             if (!schedulePtr_.valid())
00234             {
00235                 calcMapping();
00236             }
00237             return schedulePtr_();
00238         }
00239 
00240         //- Cells to sample per processor
00241         const labelListList& sendCellLabels() const
00242         {
00243             if (!sendCellLabelsPtr_.valid())
00244             {
00245                 calcMapping();
00246             }
00247             return sendCellLabelsPtr_();
00248         }
00249 
00250         //- Patch faces to receive per processor
00251         const labelListList& receiveFaceLabels() const
00252         {
00253             if (!receiveFaceLabelsPtr_.valid())
00254             {
00255                 calcMapping();
00256             }
00257             return receiveFaceLabelsPtr_();
00258         }
00259 };
00260 
00261 
00262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00263 
00264 } // End namespace Foam
00265 
00266 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00267 
00268 #endif
00269 
00270 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd