mappedPatchBaseBase.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-2025 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::mappedPatchBaseBase
26 
27 Description
28  Base class for engines and poly patches which provide mapping between two
29  poly patches
30 
31  Example:
32  \verbatim
33  // The name of the region to map from. Optional. Defaults to the same
34  // region as the patch.
35  neighbourRegion region0;
36 
37  // The name of the patch to map from
38  neighbourPatch movingWall;
39 
40  // Couple group to specify the region and patch to map from. This is an
41  // alternative to specifying neighbourRegion and neighbourPatch
42  // directly, as shown above.
43  coupleGroup baffleGroup;
44 
45  // The condition that triggers re-calculation following motion. Setting
46  // 'always' will re-calculate the mapping, 'never' will not, and
47  // 'detect' will compare the new and old points and re-calculate if
48  // there is any difference.
49  moveUpdate always;
50  \endverbatim
51 
52 SourceFiles
53  mappedPatchBaseBase.C
54 
55 \*---------------------------------------------------------------------------*/
56 
57 #ifndef mappedPatchBaseBase_H
58 #define mappedPatchBaseBase_H
59 
60 #include "coupleGroupIdentifier.H"
61 #include "cyclicTransform.H"
62 #include "polyMesh.H"
63 
64 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 
66 namespace Foam
67 {
68 
69 /*---------------------------------------------------------------------------*\
70  Class mappedPatchBaseBase Declaration
71 \*---------------------------------------------------------------------------*/
72 
74 {
75 public:
76 
77  // Public types
78 
79  //- The type of the transformation permitted/required by this patch
80  enum class transformType
81  {
82  none,
84  specified
85  };
86 
87  //- Enumeration for the condition that triggers re-calculation of the
88  // mapping following mesh motion.
89  //
90  // 'always' will re-calculate the mapping, 'never' will not, and
91  // 'detect' will compare the new and old points and re-calculate if
92  // there is any difference.
93  //
94  // The comparison that 'detect' does has an expense associated with it,
95  // so it should only really be used if the patch is both moving and
96  // static at different times. If the patch is always in motion or is
97  // fully stationary, then it is more efficient to specify 'always' or
98  // 'never'.
99  //
100  // 'always' is the default, as it is safest to assume that motion
101  // always affects the mapping.
102  enum class moveUpdate
103  {
104  always,
105  detect,
106  never
107  };
108 
109  //- Names of the move-update conditions
111 
112 
113 protected:
114 
115  // Protected data
116 
117  //- Patch to map to
118  const polyPatch& patch_;
119 
120  //- Couple group for the region/patch to map from
122 
123  //- Name of the region to map from
124  mutable word nbrRegionName_;
125 
126  //- Name of the patch to map from
127  mutable word nbrPatchName_;
128 
129  //- The transformation between the patches
130  mutable cyclicTransform transform_;
131 
132  //- The condition that triggers re-calculation following motion
133  const moveUpdate moveUpdate_;
134 
135 
136 public:
137 
138  //- Runtime type information
139  TypeName("mappedPatchBaseBase");
140 
141 
142  // Constructors
143 
144  //- Construct from patch
146 
147  //- Construct from components
149  (
150  const polyPatch& pp,
151  const word& nbrRegionName,
152  const word& nbrPatchName,
154  );
155 
156  //- Construct from dictionary
158  (
159  const polyPatch& pp,
160  const dictionary& dict,
161  const transformType tt
162  );
163 
164  //- Construct as copy, resetting patch
166 
167 
168  //- Destructor
169  virtual ~mappedPatchBaseBase();
170 
171 
172  // Member Functions
173 
174  // Access
175 
176  //- Name of the region to map from
177  inline const word& nbrRegionName() const;
178 
179  //- Name of the patch to map from
180  inline const word& nbrPatchName() const;
181 
182  //- The transformation between the patches
183  inline const transformer& transform() const;
184 
185  //- Is the neighbour region the same as for this patch?
186  inline bool sameRegion() const;
187 
188  //- Is the neighbour patch the same as this patch?
189  inline bool samePatch() const;
190 
191  //- Is the neighbour patch the same as this patch with no transform?
192  inline bool sameUntransformedPatch() const;
193 
194  //- Is the neighbour available?
195  bool haveNbr() const;
196 
197  //- Get the mesh for the region to map from
198  const polyMesh& nbrMesh() const;
199 
200  //- Get the patch to map from
201  const polyPatch& nbrPolyPatch() const;
202 
203 
204  // Casting
205 
206  //- Restrict use of the mapper to certain configurations
207  struct from
208  {
209  static const label any = 0;
210  static const label sameRegion = 1;
211  static const label differentRegion = 2;
212  static const label differentPatch = 4;
213  };
214 
215  //- Validate that the map exists and is appropriate for the given
216  // set of permitted configurations
217  template<class PatchField, class FieldType>
218  static void validateMapForField
219  (
220  const PatchField& field,
221  const FieldType& iF,
222  const dictionary& context,
223  const label froms = from::any
224  );
225 
226  //- Validate that the map is appropriate for the given
227  // set of permitted configurations
228  template<class PatchField, class FieldType>
229  void validateForField
230  (
231  const PatchField& field,
232  const FieldType& iF,
233  const dictionary& context,
234  const label froms = from::any
235  ) const;
236 
237 
238  //- Return whether or not the patches have moved
239  static bool moving
240  (
241  const polyPatch& patch,
242  const polyPatch& nbrPatch
243  );
244 
245 
246  // I/O
247 
248  //- Return whether or not the given dictionary contains a
249  // mappedPatchBaseBase specification
250  static bool specified(const dictionary& dict);
251 
252  //- Write as a dictionary
253  virtual void write(Ostream&) const;
254 };
255 
256 
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 
259 } // End namespace Foam
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 #include "mappedPatchBaseBaseI.H"
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 #ifdef NoRepository
269 #endif
270 
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 
273 #endif
274 
275 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Encapsulates using patchGroups to specify coupled patch.
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 polyPatch & nbrPolyPatch() const
Get the patch to map from.
word nbrRegionName_
Name of the region to map from.
word nbrPatchName_
Name of the patch to map from.
bool samePatch() const
Is the neighbour patch the same as this patch?
const polyPatch & patch_
Patch to map to.
virtual void write(Ostream &) const
Write as a dictionary.
const polyMesh & nbrMesh() const
Get the mesh for the region to map from.
const word & nbrPatchName() const
Name of the patch to map from.
cyclicTransform transform_
The transformation between the patches.
virtual ~mappedPatchBaseBase()
Destructor.
void validateForField(const PatchField &field, const FieldType &iF, const dictionary &context, const label froms=from::any) const
Validate that the map is appropriate for the given.
const word & nbrRegionName() const
Name of the region to map from.
bool haveNbr() const
Is the neighbour available?
transformType
The type of the transformation permitted/required by this patch.
TypeName("mappedPatchBaseBase")
Runtime type information.
static const NamedEnum< moveUpdate, 3 > moveUpdateNames_
Names of the move-update conditions.
bool sameUntransformedPatch() const
Is the neighbour patch the same as this patch with no transform?
bool sameRegion() const
Is the neighbour region the same as for this patch?
const moveUpdate moveUpdate_
The condition that triggers re-calculation following motion.
static bool specified(const dictionary &dict)
Return whether or not the given dictionary contains a.
static bool moving(const polyPatch &patch, const polyPatch &nbrPatch)
Return whether or not the patches have moved.
const coupleGroupIdentifier coupleGroup_
Couple group for the region/patch to map from.
static void validateMapForField(const PatchField &field, const FieldType &iF, const dictionary &context, const label froms=from::any)
Validate that the map exists and is appropriate for the given.
moveUpdate
Enumeration for the condition that triggers re-calculation of the.
mappedPatchBaseBase(const polyPatch &)
Construct from patch.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:71
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
A class for handling words, derived from string.
Definition: word.H:63
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
Restrict use of the mapper to certain configurations.