mappedPatchBase.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-2024 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::mappedPatchBase
26 
27 Description
28  Engine and base class for poly patches which provides interpolative mapping
29  between two globally conforming poly patches
30 
31  Example:
32  \verbatim
33  // (Settings inherited from mappedPatchBaseBase to identify the
34  // neighbouring region and patch)
35  ...
36 
37  // Patch-to-patch mapping method. How the interpolation addressing and
38  // weights are constructed. Likely to be "matching" if the patches are
39  // conformal, or "intersection" if they are not. Optional. If omitted,
40  // then it will be assumed that the patches are conformal, and an
41  // octree-based method will be used to construct the connections.
42  method matching; // nearest, intersection, inverseDistance
43 
44  // Tolerance used to check the patches' global conformance (i.e., the
45  // conformance of the patches' entire surfaces, not of each pair of
46  // faces). Optional. Defaults to a small value.
47  matchTol 1e-4;
48 
49  // Switch to control whether the mapping is re-calculated after mesh
50  // motion. Optional. Defaults to true, which is the safest option. This
51  // should only be set to false if it is known that the patches do not
52  // move, or that they move consistently.
53  reMapAfterMove true;
54  \endverbatim
55 
56 SourceFiles
57  mappedPatchBase.C
58 
59 \*---------------------------------------------------------------------------*/
60 
61 #ifndef mappedPatchBase_H
62 #define mappedPatchBase_H
63 
64 #include "mappedPatchBaseBase.H"
65 #include "patchToPatch.H"
66 
67 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
68 
69 namespace Foam
70 {
71 
72 /*---------------------------------------------------------------------------*\
73  Class mappedPatchBase Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 class mappedPatchBase
77 :
78  public mappedPatchBaseBase
79 {
80 protected:
81 
82  // Protected data
83 
84  //- Are we using the tree mapping method, or a patch-to-patch
85  // intersection engine? The former is typically faster on small,
86  // pairs of patches with identical meshes. The latter is better
87  // parallelised and provides options for connecting patches with
88  // differing surface meshes.
89  const bool usingTree_;
90 
91  //- Distributor (if using tree)
93 
94  //- Indices of the neighbouring patch faces who's values
95  // have to be supplied to the distribution map (if using tree)
97 
98  //- Is the patch-to-patch intersection engine up to date? (if using
99  // patch-to-patch)
100  mutable bool patchToPatchIsValid_;
101 
102  //- Patch-to-patch intersection engine (if using patch-to-patch)
104 
105  //- Default Matching tolerance
106  static const scalar defaultMatchTol_;
107 
108  //- Matching tolerance
109  const scalar matchTol_;
110 
111  //- Do we need to re-calculate the mapping if mesh motion takes place?
112  // Defaults to true.
113  const bool reMapAfterMove_;
114 
115  //- Do we need to re-map the neighbour because this patch moved?
116  mutable bool reMapNbr_;
117 
118 
119  // Protected Member Functions
120 
121  //- Get the face-areas for this patch
122  virtual tmp<vectorField> patchFaceAreas() const;
123 
124  //- Get the face-centres for this patch
125  virtual tmp<pointField> patchFaceCentres() const;
126 
127  //- Get the local points for this patch
128  virtual tmp<pointField> patchLocalPoints() const;
129 
130  //- Get the face-areas for the neighbour patch
132 
133  //- Get the face-centres for the neighbour patch
135 
136  //- Get the local points for the neighbour patch
138 
139  //- Calculate mapping
140  void calcMapping() const;
141 
142  //- Return whether or not the neighbour patch is of mapped type
143  inline bool nbrPatchIsMapped() const;
144 
145  //- Get the mapped neighbouring patch
146  inline const mappedPatchBase& nbrMappedPatch() const;
147 
148  //- Determine whether the neighbouring patch maps from this patch in
149  // the same way as this patch maps from its neighbour
150  inline bool symmetric() const;
151 
152 
153 public:
154 
155  //- Runtime type information
156  TypeName("mappedPatchBase");
157 
158 
159  // Constructors
160 
161  //- Construct from patch
162  mappedPatchBase(const polyPatch&);
163 
164  //- Construct from components
166  (
167  const polyPatch& pp,
168  const word& nbrRegionName,
169  const word& nbrPatchName,
171  );
172 
173  //- Construct from dictionary
175  (
176  const polyPatch& pp,
177  const dictionary& dict,
178  const bool defaultTransformIsNone
179  );
180 
181  //- Construct as copy, resetting patch
182  mappedPatchBase(const polyPatch&, const mappedPatchBase&);
183 
184 
185  //- Destructor
186  virtual ~mappedPatchBase();
187 
188 
189  // Member Functions
190 
191  // Casting
192 
193  //- Cast the given polyPatch to a mappedPatchBase. Handle errors.
194  static const mappedPatchBase& getMap(const polyPatch& patch);
195 
196 
197  // Edit
198 
199  //- Clear out data on mesh change
200  virtual void clearOut();
201 
202 
203  // Distribute
204 
205  //- Map/interpolate the neighbour patch field to this patch
206  template<class Type>
207  tmp<Field<Type>> fromNeighbour(const Field<Type>& nbrFld) const;
208 
209  //- Map/interpolate the neighbour patch field to this patch
210  template<class Type>
212  (
213  const tmp<Field<Type>>& nbrFld
214  ) const;
215 
216  //- Map/interpolate patch field to the neighbour patch
217  template<class Type>
219 
220  //- Map/interpolate patch field to the neighbour patch
221  template<class Type>
223  (
224  const tmp<Field<Type>>& fld
225  ) const;
226 
227 
228  // I/O
229 
230  //- Write as a dictionary
231  virtual void write(Ostream&) const;
232 };
233 
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 } // End namespace Foam
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 #include "mappedPatchBaseI.H"
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 #ifdef NoRepository
246  #include "mappedPatchBaseTemplates.C"
247 #endif
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 #endif
252 
253 // ************************************************************************* //
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
Cyclic plane transformation.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Base class for engines and poly patches which provide mapping between two poly patches.
const transformer & transform() const
The transformation between the patches.
const word & nbrPatchName() const
Name of the patch to map from.
const word & nbrRegionName() const
Name of the region to map from.
Engine and base class for poly patches which provides interpolative mapping between two globally conf...
tmp< Field< Type > > toNeighbour(const Field< Type > &fld) const
Map/interpolate patch field to the neighbour patch.
bool symmetric() const
Determine whether the neighbouring patch maps from this patch in.
tmp< pointField > nbrPatchLocalPoints() const
Get the local points for the neighbour patch.
const bool reMapAfterMove_
Do we need to re-calculate the mapping if mesh motion takes place?
static const mappedPatchBase & getMap(const polyPatch &patch)
Cast the given polyPatch to a mappedPatchBase. Handle errors.
TypeName("mappedPatchBase")
Runtime type information.
virtual void write(Ostream &) const
Write as a dictionary.
virtual tmp< vectorField > patchFaceAreas() const
Get the face-areas for this patch.
virtual tmp< pointField > patchLocalPoints() const
Get the local points for this patch.
bool patchToPatchIsValid_
Is the patch-to-patch intersection engine up to date? (if using.
const scalar matchTol_
Matching tolerance.
autoPtr< patchToPatch > patchToPatchPtr_
Patch-to-patch intersection engine (if using patch-to-patch)
static const scalar defaultMatchTol_
Default Matching tolerance.
labelList treeNbrPatchFaceIndices_
Indices of the neighbouring patch faces who's values.
autoPtr< distributionMap > treeMapPtr_
Distributor (if using tree)
bool reMapNbr_
Do we need to re-map the neighbour because this patch moved?
mappedPatchBase(const polyPatch &)
Construct from patch.
tmp< vectorField > nbrPatchFaceAreas() const
Get the face-areas for the neighbour patch.
const mappedPatchBase & nbrMappedPatch() const
Get the mapped neighbouring patch.
tmp< pointField > nbrPatchFaceCentres() const
Get the face-centres for the neighbour patch.
virtual ~mappedPatchBase()
Destructor.
void calcMapping() const
Calculate mapping.
tmp< Field< Type > > fromNeighbour(const Field< Type > &nbrFld) const
Map/interpolate the neighbour patch field to this patch.
const bool usingTree_
Are we using the tree mapping method, or a patch-to-patch.
bool nbrPatchIsMapped() const
Return whether or not the neighbour patch is of mapped type.
virtual tmp< pointField > patchFaceCentres() const
Get the face-centres for this patch.
virtual void clearOut()
Clear out data on mesh change.
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