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