mappedInternalPatchBase.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::mappedInternalPatchBase
26 
27 Description
28  Engine which provides mapping from cells to patch faces
29 
30  Example:
31  \verbatim
32  // The name of the region to map from. Optional. Defaults to the same
33  // region as the patch.
34  neighbourRegion region0;
35 
36  // How to offset the patch face centres to the sampling locations.
37  // Optional. This will be inferred if there is a single entry of either
38  // "distance" or "offset".
39  // - normal : distance along the patch face normals
40  // - direction : specified offset vector
41  offsetMode direction;
42 
43  // If offsetMode is normal : The normal distance to offset
44  distance 1;
45 
46  // If offsetMode is direction : The offset vector
47  offset (1 0 0);
48  \endverbatim
49 
50  Note that patch normals point outward, so if offsetMode is \c normal then a
51  negative distance will be required in order to map values from inside the
52  region.
53 
54 SourceFiles
55  mappedInternalPatchBase.C
56 
57 \*---------------------------------------------------------------------------*/
58 
59 #ifndef mappedInternalPatchBase_H
60 #define mappedInternalPatchBase_H
61 
62 #include "polyBoundaryMesh.H"
63 #include "distributionMap.H"
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 
70 /*---------------------------------------------------------------------------*\
71  Class mappedInternalPatchBase Declaration
72 \*---------------------------------------------------------------------------*/
73 
75 {
76 public:
77 
78  // Type enumerations
79 
80  //- How to project face centres
81  enum offsetMode
82  {
83  NORMAL, // offset a distance in the face-normal direction
84  DIRECTION // offset with a specified vector
85  };
86 
88 
89 
90 protected:
91 
92  // Protected data
93 
94  //- Patch to map to
95  const polyPatch& patch_;
96 
97  //- Name of the region to map from
99 
100  //- How to offset the patch face centres to the sampling locations
102 
103  //- Offset distance
104  scalar distance_;
105 
106  //- Offset vector
107  vector offset_;
108 
109  //- Distributor
111 
112  //- Indices of the cells who's values have to be supplied to the
113  // distribution map
114  mutable labelList cellIndices_;
115 
116 
117  // Protected Member Functions
118 
119  //- Read the offset mode from a dictionary
121 
122  //- Calculate mapping
123  void calcMapping() const;
124 
125 
126 public:
127 
128  //- Runtime type information
129  TypeName("mappedInternalPatchBase");
130 
131 
132  // Constructors
133 
134  //- Construct from patch
136 
137  //- Construct with no offset
139  (
140  const polyPatch& pp,
141  const word& nbrRegion
142  );
143 
144  //- Construct from dictionary
146 
147  //- Construct as copy, resetting patch
149  (
150  const polyPatch&,
152  );
153 
154 
155  //- Destructor
156  virtual ~mappedInternalPatchBase();
157 
158 
159  // Member Functions
160 
161  // Access
162 
163  //- Name of the region to map from
164  inline const word& nbrRegionName() const;
165 
166  //- Is the neighbour region the same as for this patch?
167  inline bool sameRegion() const;
168 
169  //- Return reference to the parallel distribution map
170  inline const distributionMap& map() const;
171 
172  //- Return the indices of the cells who's values have to be
173  // supplied to the distribution map
174  inline const labelList& cellIndices() const;
175 
176  //- Get the region mesh
177  const polyMesh& nbrMesh() const;
178 
179  //- Get the sample points
181 
182 
183  // Edit
184 
185  //- Clear out data on mesh change
186  void clearOut();
187 
188 
189  // Distribute
190 
191  //- Wrapper around map/interpolate data distribution
192  template<class Type>
193  tmp<Field<Type>> distribute(const Field<Type>& fld) const;
194 
195  //- Wrapper around map/interpolate data distribution
196  template<class Type>
197  tmp<Field<Type>> distribute(const tmp<Field<Type>>& fld) const;
198 
199 
200  // I/O
201 
202  //- Return whether or not the given dictionary contains a
203  // mappedInternalPatchBase specification
204  static bool specified(const dictionary& dict);
205 
206  //- Write as a dictionary
207  virtual void write(Ostream&) const;
208 };
209 
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 } // End namespace Foam
214 
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
216 
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #ifdef NoRepository
223 #endif
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 #endif
228 
229 // ************************************************************************* //
Pre-declare SubField and related Field type.
Definition: Field.H:83
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Class containing processor-to-processor mapping information.
Engine which provides mapping from cells to patch faces.
TypeName("mappedInternalPatchBase")
Runtime type information.
word nbrRegionName_
Name of the region to map from.
const polyPatch & patch_
Patch to map to.
virtual void write(Ostream &) const
Write as a dictionary.
const polyMesh & nbrMesh() const
Get the region mesh.
const distributionMap & map() const
Return reference to the parallel distribution map.
autoPtr< distributionMap > mapPtr_
Distributor.
const word & nbrRegionName() const
Name of the region to map from.
tmp< pointField > samplePoints() const
Get the sample points.
virtual ~mappedInternalPatchBase()
Destructor.
bool sameRegion() const
Is the neighbour region the same as for this patch?
static const NamedEnum< offsetMode, 2 > offsetModeNames_
labelList cellIndices_
Indices of the cells who's values have to be supplied to the.
offsetMode
How to project face centres.
static bool specified(const dictionary &dict)
Return whether or not the given dictionary contains a.
tmp< Field< Type > > distribute(const Field< Type > &fld) const
Wrapper around map/interpolate data distribution.
void calcMapping() const
Calculate mapping.
const labelList & cellIndices() const
Return the indices of the cells who's values have to be.
mappedInternalPatchBase(const polyPatch &)
Construct from patch.
offsetMode readOffsetMode(const dictionary &dict) const
Read the offset mode from a dictionary.
offsetMode offsetMode_
How to offset the patch face centres to the sampling locations.
void clearOut()
Clear out data on mesh change.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(Cloud< passiveParticle >, particles, iter) { positions[particlei++]=iter().position(mesh);} for(i=0;i< pTraits< point >::nComponents;i++) { forAll(positions, particlei) { gmvFile<< component(positions[particlei], i)<< ' ';} gmvFile<< nl;}}forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
dictionary dict