nonConformalCyclicPolyPatch.C
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) 2021-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 \*---------------------------------------------------------------------------*/
25 
29 #include "polyBoundaryMesh.H"
30 #include "polyMesh.H"
31 #include "SubField.H"
32 #include "nonConformalBoundary.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(nonConformalCyclicPolyPatch, 0);
39 
40  addToRunTimeSelectionTable(polyPatch, nonConformalCyclicPolyPatch, word);
42  (
43  polyPatch,
44  nonConformalCyclicPolyPatch,
45  dictionary
46  );
47 }
48 
49 
50 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
51 
53 {
55  intersectionIsValid_ = false;
56  raysIsValid_ = false;
57 }
58 
59 
61 {
62  static_cast<cyclicTransform&>(*this) =
64  (
65  name(),
66  origPatch().faceAreas(),
67  *this,
68  nbrPatchName(),
69  nbrPatch(),
70  matchTolerance()
71  );
72 }
73 
74 
76 (
77  PstreamBuffers& pBufs,
78  const pointField& p
79 )
80 {
82  intersectionIsValid_ = false;
83  raysIsValid_ = false;
84 }
85 
86 
88 {
90  intersectionIsValid_ = false;
91  raysIsValid_ = false;
92 }
93 
94 
96 {
98  intersectionIsValid_ = false;
99  raysIsValid_ = false;
100 }
101 
102 
104 {
105  cyclicPolyPatch::rename(newNames);
107 }
108 
109 
111 {
112  cyclicPolyPatch::reorder(newToOldIndex);
114 }
115 
116 
117 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
118 
120 (
121  const word& name,
122  const label size,
123  const label start,
124  const label index,
125  const polyBoundaryMesh& bm,
126  const word& patchType
127 )
128 :
129  cyclicPolyPatch(name, size, start, index, bm, patchType),
130  nonConformalCoupledPolyPatch(static_cast<const polyPatch&>(*this)),
131  intersectionIsValid_(false),
132  intersection_(false),
133  raysIsValid_(false),
134  rays_(false)
135 {}
136 
137 
139 (
140  const word& name,
141  const label size,
142  const label start,
143  const label index,
144  const polyBoundaryMesh& bm,
145  const word& patchType,
146  const word& nbrPatchName,
147  const word& origPatchName,
148  const cyclicTransform& transform
149 )
150 :
152  (
153  name,
154  size,
155  start,
156  index,
157  bm,
158  patchType,
159  nbrPatchName,
160  transform
161  ),
162  nonConformalCoupledPolyPatch(*this, origPatchName),
163  intersectionIsValid_(false),
164  intersection_(false),
165  raysIsValid_(false),
166  rays_(false)
167 {}
168 
169 
171 (
172  const word& name,
173  const dictionary& dict,
174  const label index,
175  const polyBoundaryMesh& bm,
176  const word& patchType
177 )
178 :
179  cyclicPolyPatch(name, dict, index, bm, patchType, true),
180  nonConformalCoupledPolyPatch(*this, dict),
181  intersectionIsValid_(false),
182  intersection_(false),
183  raysIsValid_(false),
184  rays_(false)
185 {}
186 
187 
189 (
190  const nonConformalCyclicPolyPatch& pp,
191  const polyBoundaryMesh& bm
192 )
193 :
194  cyclicPolyPatch(pp, bm),
195  nonConformalCoupledPolyPatch(*this, pp),
196  intersectionIsValid_(false),
197  intersection_(false),
198  raysIsValid_(false),
199  rays_(false)
200 {}
201 
202 
204 (
205  const nonConformalCyclicPolyPatch& pp,
206  const polyBoundaryMesh& bm,
207  const label index,
208  const label newSize,
209  const label newStart,
210  const word& nbrPatchName,
211  const word& origPatchName
212 )
213 :
214  cyclicPolyPatch(pp, bm, index, newSize, newStart, nbrPatchName),
215  nonConformalCoupledPolyPatch(*this, origPatchName),
216  intersectionIsValid_(false),
217  intersection_(false),
218  raysIsValid_(false),
219  rays_(false)
220 {}
221 
222 
224 (
225  const nonConformalCyclicPolyPatch& pp,
226  const polyBoundaryMesh& bm,
227  const label index,
228  const labelUList& mapAddressing,
229  const label newStart
230 )
231 :
232  cyclicPolyPatch(pp, bm, index, mapAddressing, newStart),
233  nonConformalCoupledPolyPatch(*this, pp),
234  intersectionIsValid_(false),
235  intersection_(false),
236  raysIsValid_(false),
237  rays_(false)
238 {}
239 
240 
241 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
242 
244 {}
245 
246 
247 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
248 
251 {
252  return
253  refCast<const nonConformalCyclicPolyPatch>
254  (
256  );
257 }
258 
259 
261 {
262  return false;
263 }
264 
265 
268 {
269  if (!owner())
270  {
272  << "The non-conformal cyclic intersection is only available to "
273  << "the owner patch" << abort(FatalError);
274  }
275 
276  if (!intersectionIsValid_)
277  {
278  const polyMesh& mesh = boundaryMesh().mesh();
279 
281 
282  intersection_.update
283  (
284  origPatch(),
285  ncb.patchPointNormals(origPatchID()),
286  nbrPatch().origPatch(),
287  transform()
288  );
289 
290  intersectionIsValid_ = true;
291  }
292 
293  return intersection_;
294 }
295 
296 
299 {
300  if (!owner())
301  {
303  << "The non-conformal cyclic rays is only available to "
304  << "the owner patch" << abort(FatalError);
305  }
306 
307  if (!raysIsValid_)
308  {
309  const polyMesh& mesh = boundaryMesh().mesh();
310 
312 
313  rays_.update
314  (
316  (
317  origPatch(),
318  mesh.points(),
319  mesh.oldPoints()
320  ),
321  ncb.patchPointNormals(origPatchID()),
322  ncb.patchPointNormals0(origPatchID()),
324  (
325  nbrPatch().origPatch(),
326  mesh.points(),
327  mesh.oldPoints()
328  ),
329  transform()
330  );
331 
332  raysIsValid_ = true;
333  }
334 
335  return rays_;
336 }
337 
338 
340 (
341  const scalar fraction,
342  const label origFacei,
343  const vector& p,
344  const vector& n,
345  point& nbrP
346 ) const
347 {
348  const polyMesh& mesh = boundaryMesh().mesh();
349 
350  const nonConformalCyclicPolyPatch& ownerPatch =
351  owner() ? *this : nbrPatch();
352 
353  auto ownerRaysMethod =
354  owner()
357 
358  return
359  (ownerPatch.rays().*ownerRaysMethod)
360  (
362  (
363  nbrPatch().origPatch(),
364  mesh.points(),
365  mesh.oldPoints()
366  ),
367  fraction,
368  origFacei,
369  transform().invTransformPosition(p),
370  transform().invTransform(n),
371  nbrP
372  );
373 }
374 
375 
377 {
380 }
381 
382 
383 // ************************************************************************* //
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
virtual void initTopoChange(PstreamBuffers &)
Initialise the update of the patch topology.
Non-conformal coupled poly patch. As nonConformalPolyPatch, but this patch is coupled to another non-...
Mesh object that stores an all boundary patch and mapping to and from it and the mesh and the individ...
tmp< vectorField > patchPointNormals0(const label patchi) const
Get parallel consistent old-time point normals for the patch.
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Structure to conveniently store processor and face indices.
Definition: patchToPatch.H:60
const patchToPatches::intersection & intersection() const
Access the intersection engine.
virtual void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
virtual void rename(const wordList &newNames)
Reset the patch name.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
const cyclicPolyPatch & nbrPatch() const
Class to generate patchToPatch coupling geometry. A full geometric intersection is done between a fac...
fvMesh & mesh
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
virtual void reorder(const labelUList &newToOldIndex)
Reset the patch index.
virtual void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Macros for easy insertion into run-time selection tables.
virtual void clearGeom()
Clear geometry.
Definition: polyPatch.C:76
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1211
virtual void rename(const wordList &newNames)
Reset the patch name.
PrimitiveOldTimePatch< SubList< face >, const pointField & > primitiveOldTimePatch
Addressing for a faceList slice.
A class for handling words, derived from string.
Definition: word.H:59
Cyclic plane patch.
patchToPatch::procFace ray(const scalar fraction, const label origFacei, const vector &p, const vector &n, point &nbrP) const
Compute a ray intersection across the coupling.
virtual void clearGeom()
Clear geometry.
virtual const pointField & oldPoints() const
Return old points for mesh motion.
Definition: polyMesh.C:1249
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Non-conformal cyclic poly patch. As nonConformalCoupledPolyPatch, but the neighbouring patch is local...
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
Foam::polyBoundaryMesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
virtual void reorder(const labelUList &newToOldIndex)
Reset the patch index.
defineTypeNameAndDebug(combustionModel, 0)
static nonConformalBoundary & New(polyMesh &mesh)
Definition: MeshObject.C:54
Buffers for inter-processor communications streams (UOPstream, UIPstream).
procFace tgtToSrcRay(const primitiveOldTimePatch &srcPatch, const scalar fraction, const label tgtFacei, const vector &tgtP, const vector &tgtN, point &srcP) const
Compute a ray intersection from the target side to the source.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
virtual void initMovePoints(PstreamBuffers &pBufs, const pointField &)
Initialise the patches for moving points.
virtual void initTopoChange(PstreamBuffers &)
Initialise the update of the patch topology.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
const nonConformalCyclicPolyPatch & nbrPatch() const
Neighbour patch.
virtual bool coupled() const
Is this patch coupled? Returns false. For NCC patches the poly.
procFace srcToTgtRay(const primitiveOldTimePatch &tgtPatch, const scalar fraction, const label srcFacei, const vector &srcP, const vector &srcN, point &tgtP) const
Compute a ray intersection from the source side to the target.
virtual void rename(const wordList &newNames)
Reset the patch name.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
tmp< vectorField > patchPointNormals(const label patchi) const
Get parallel consistent point normals for the patch.
Cyclic plane transformation.
virtual void reorder(const labelUList &newToOldIndex)
Reset the patch index.
virtual void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
nonConformalCyclicPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const word &patchType)
Construct from components.
Namespace for OpenFOAM.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:483
const patchToPatches::rays & rays() const
Access the rays engine.