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  \endverbatim
49 
50 See also
51  Foam::mappedPatchBaseBase
52 
53 SourceFiles
54  mappedPatchBase.C
55 
56 \*---------------------------------------------------------------------------*/
57 
58 #ifndef mappedPatchBase_H
59 #define mappedPatchBase_H
60 
61 #include "mappedPatchBaseBase.H"
62 #include "patchToPatch.H"
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 namespace Foam
67 {
68 
69 /*---------------------------------------------------------------------------*\
70  Class mappedPatchBase Declaration
71 \*---------------------------------------------------------------------------*/
72 
73 class mappedPatchBase
74 :
75  public mappedPatchBaseBase
76 {
77 protected:
78 
79  // Protected data
80 
81  //- Are we using the tree mapping method, or a patch-to-patch
82  // intersection engine? The former is typically faster on small,
83  // pairs of patches with identical meshes. The latter is better
84  // parallelised and provides options for connecting patches with
85  // differing surface meshes.
86  const bool usingTree_;
87 
88  //- Distributor (if using tree)
90 
91  //- Indices of the neighbouring patch faces who's values
92  // have to be supplied to the distribution map (if using tree)
94 
95  //- Patch-to-patch intersection engine (if using patch-to-patch)
97 
98  //- Default Matching tolerance
99  static const scalar defaultMatchTol_;
100 
101  //- Matching tolerance
102  const scalar matchTol_;
103 
104  //- Is the mapping engine up to date? Zero if out of date. One if out
105  // of date (or potentially not out of date) because of motion. Two if
106  // up to date.
107  mutable label mappingIsValid_;
108 
109  //- If the neighbour's mapping engine (if there is one) up to date?
110  mutable label nbrMappingIsValid_;
111 
112 
113  // Protected Member Functions
114 
115  //- Get the face-areas for this patch
116  virtual tmp<vectorField> patchFaceAreas() const;
117 
118  //- Get the face-centres for this patch
119  virtual tmp<pointField> patchFaceCentres() const;
120 
121  //- Get the local points for this patch
122  virtual tmp<pointField> patchLocalPoints() const;
123 
124  //- Get the face-areas for the neighbour patch
126 
127  //- Get the face-centres for the neighbour patch
129 
130  //- Get the local points for the neighbour patch
132 
133  //- Return whether or not the mapping is valid
134  bool mappingIsValid() const;
135 
136  //- Calculate mapping
137  void calcMapping() const;
138 
139  //- Clear out data on mesh change
140  virtual void clearOut() 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 transformType tt
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  void clearOut(const bool move);
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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.
transformType
The type of the transformation permitted/required by this patch.
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.
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.
virtual void clearOut() const
Clear out data on mesh change.
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.
label nbrMappingIsValid_
If the neighbour's mapping engine (if there is one) up to date?
labelList treeNbrPatchFaceIndices_
Indices of the neighbouring patch faces who's values.
autoPtr< distributionMap > treeMapPtr_
Distributor (if using tree)
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.
bool mappingIsValid() const
Return whether or not the mapping is valid.
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.
label mappingIsValid_
Is the mapping engine up to date? Zero if out of date. One if out.
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.
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(lagrangian::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(), lagrangian::cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
dictionary dict