1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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
26 Foam::directMappedPatchBase
29 Determines a mapping between patch face centres and mesh cell or face
30 centres and processors they're on.
33 Storage is not optimal. It temporary collects all (patch)face centres
34 on all processors to keep the addressing calculation simple.
37 directMappedPatchBase.C
39 \*---------------------------------------------------------------------------*/
41 #ifndef directMappedPatchBase_H
42 #define directMappedPatchBase_H
44 #include "pointField.H"
46 #include "pointIndexHit.H"
47 #include "mapDistribute.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 /*---------------------------------------------------------------------------*\
59 Class directMappedPatchBase Declaration
60 \*---------------------------------------------------------------------------*/
62 class directMappedPatchBase
67 //- Mesh items to sample
79 static const NamedEnum<sampleMode, 3> sampleModeNames_;
82 const polyPatch& patch_;
85 const word sampleRegion_;
88 const sampleMode mode_;
90 //- Patch (only if NEARESTBOUNDARY)
91 const word samplePatch_;
97 const bool sameRegion_;
100 // Derived information
102 //- Communication schedule:
103 // - Cells/faces to sample per processor
104 // - Patch faces to receive per processor
106 mutable autoPtr<mapDistribute> mapPtr_;
109 // Private Member Functions
111 //- Collect single list of samples and originating processor+face.
115 labelList& patchFaceProcs,
116 labelList& patchFaces,
120 //- Find cells/faces containing samples
124 labelList& sampleProcs, // processor containing sample
125 labelList& sampleIndices, // local index of cell/face
126 pointField& sampleLocations // actual representative location
129 //- Calculate matching
130 void calcMapping() const;
135 //- Private class for finding nearest
136 // - point+local index
139 typedef Tuple2<pointIndexHit, Tuple2<scalar, label> > nearInfo;
146 void operator()(nearInfo& x, const nearInfo& y) const
150 if (!x.first().hit())
154 else if (y.second().first() < x.second().first())
165 //- Runtime type information
166 TypeName("directMappedPatchBase");
171 //- Construct from components
172 directMappedPatchBase(const polyPatch&);
174 //- Construct from dictionary
175 directMappedPatchBase(const polyPatch&, const dictionary&);
177 //- Construct as copy, resetting patch
178 directMappedPatchBase(const polyPatch&, const directMappedPatchBase&);
182 virtual ~directMappedPatchBase();
190 const sampleMode& mode() const
196 const word& sampleRegion() const
198 return sampleRegion_;
201 //- Patch (only if NEARESTBOUNDARY)
202 const word& samplePatch() const
207 //- Offset vector (from patch faces to destination mesh objects)
208 const vector& offset() const
213 //- Return reference to the parallel distribution map
214 const mapDistribute& map() const
223 //- Cached sampleRegion != mesh.name()
224 bool sameRegion() const
229 //- Get the region mesh
230 const polyMesh& sampleMesh() const;
232 //- Get the patch on the region
233 const polyPatch& samplePolyPatch() const;
235 //- Write as a dictionary
236 virtual void write(Ostream&) const;
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 } // End namespace Foam
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 // ************************************************************************* //