ENH: splitMeshRegions now fills in coupling information in directMapped patch.
[OpenFOAM-1.6.x.git] / src / meshTools / directMapped / directMappedPolyPatch / directMappedPatchBase.H
blobc7a4b16f1666d65169328396b01347dfcf5a584c
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::directMappedPatchBase
28 Description
29     Determines a mapping between patch face centres and mesh cell or face
30     centres and processors they're on.
32 Note
33     Storage is not optimal. It temporary collects all (patch)face centres
34     on all processors to keep the addressing calculation simple.
36 SourceFiles
37     directMappedPatchBase.C
39 \*---------------------------------------------------------------------------*/
41 #ifndef directMappedPatchBase_H
42 #define directMappedPatchBase_H
44 #include "pointField.H"
45 #include "Tuple2.H"
46 #include "pointIndexHit.H"
47 #include "mapDistribute.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 namespace Foam
55 class polyPatch;
56 class polyMesh;
58 /*---------------------------------------------------------------------------*\
59                       Class directMappedPatchBase Declaration
60 \*---------------------------------------------------------------------------*/
62 class directMappedPatchBase
65 public:
67         //- Mesh items to sample
68         enum sampleMode
69         {
70             NEARESTCELL,
71             NEARESTPATCHFACE,
72             NEARESTFACE
73         };
75 private:
77     // Private data
79         static const NamedEnum<sampleMode, 3> sampleModeNames_;
81         //- Patch to sample
82         const polyPatch& patch_;
84         //- Region to sample
85         const word sampleRegion_;
87         //- What to sample
88         const sampleMode mode_;
90         //- Patch (only if NEARESTPATCHFACE)
91         const word samplePatch_;
93         //- For backwards compatibility : reading/writing of uniform offset.
94         const bool uniformOffset_;
96         //- Offset vector (uniform)
97         const vector offset_;
99         //- Offset vector
100         const vectorField offsets_;
102         //- Same region
103         const bool sameRegion_;
106         // Derived information
108             //- Communication schedule:
109             //  - Cells/faces to sample per processor
110             //  - Patch faces to receive per processor
111             //  - schedule
112             mutable autoPtr<mapDistribute> mapPtr_;
115     // Private Member Functions
117         //- Collect single list of samples and originating processor+face.
118         void collectSamples
119         (
120             pointField&,
121             labelList& patchFaceProcs,
122             labelList& patchFaces,
123             pointField& patchFc
124         ) const;
126         //- Find cells/faces containing samples
127         void findSamples
128         (
129             const pointField&,
130             labelList& sampleProcs,     // processor containing sample
131             labelList& sampleIndices,   // local index of cell/face
132             pointField& sampleLocations // actual representative location
133         ) const;
135         //- Calculate matching
136         void calcMapping() const;
139 public:
141     //- Runtime type information
142     TypeName("directMappedPatchBase");
145     // Constructors
147         //- Construct from patch
148         directMappedPatchBase(const polyPatch&);
150         //- Construct from components
151         directMappedPatchBase
152         (
153             const polyPatch& pp,
154             const word& sampleRegion,
155             const sampleMode sampleMode,
156             const word& samplePatch,
157             const vectorField& offset
158         );
160         //- Construct from components
161         directMappedPatchBase
162         (
163             const polyPatch& pp,
164             const word& sampleRegion,
165             const sampleMode sampleMode,
166             const word& samplePatch,
167             const vector& offset
168         );
170         //- Construct from dictionary
171         directMappedPatchBase(const polyPatch&, const dictionary&);
173         //- Construct as copy, resetting patch
174         directMappedPatchBase(const polyPatch&, const directMappedPatchBase&);
177     //- Destructor
178     virtual ~directMappedPatchBase();
181     // Member functions
183         void clearOut();
185         //- What to sample
186         const sampleMode& mode() const
187         {
188             return mode_;
189         }
191         //- Region to sample
192         const word& sampleRegion() const
193         {
194             return sampleRegion_;
195         }
197         //- Patch (only if NEARESTBOUNDARY)
198         const word& samplePatch() const
199         {
200             return samplePatch_;
201         }
203         //- Offset vector (from patch faces to destination mesh objects)
204         const vectorField& offsets() const
205         {
206             return offsets_;
207         }
209         //- Return reference to the parallel distribution map
210         const mapDistribute& map() const
211         {
212             if (mapPtr_.empty())
213             {
214                 calcMapping();
215             }
216             return mapPtr_();
217         }
219         //- Cached sampleRegion != mesh.name()
220         bool sameRegion() const
221         {
222             return sameRegion_;
223         }
225         //- Get the region mesh
226         const polyMesh& sampleMesh() const;
228         //- Get the patch on the region
229         const polyPatch& samplePolyPatch() const;
231         //- Write as a dictionary
232         virtual void write(Ostream&) const;
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 } // End namespace Foam
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 #endif
244 // ************************************************************************* //