mappedPatchBase.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2015-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "mappedPatchBase.H"
31 #include "ListListOps.H"
32 #include "meshSearchMeshObject.H"
33 #include "meshTools.H"
34 #include "OFstream.H"
35 #include "Random.H"
36 #include "treeDataFace.H"
37 #include "treeDataPoint.H"
38 #include "indexedOctree.H"
39 #include "polyMesh.H"
40 #include "polyPatch.H"
41 #include "Time.H"
42 #include "mapDistribute.H"
43 #include "SubField.H"
44 #include "triPointRef.H"
45 #include "syncTools.H"
46 #include "treeDataCell.H"
47 #include "DynamicField.H"
48 #include "faceAreaWeightAMI.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54  defineTypeNameAndDebug(mappedPatchBase, 0);
55 }
56 
57 
58 const Foam::Enum
59 <
61 >
63 ({
64  { sampleMode::NEARESTCELL, "nearestCell" },
65  { sampleMode::NEARESTPATCHFACE, "nearestPatchFace" },
66  { sampleMode::NEARESTPATCHFACEAMI, "nearestPatchFaceAMI" },
67  { sampleMode::NEARESTPATCHPOINT, "nearestPatchPoint" },
68  { sampleMode::NEARESTFACE, "nearestFace" },
69  { sampleMode::NEARESTONLYCELL, "nearestOnlyCell" },
70 });
71 
72 
73 const Foam::Enum
74 <
76 >
78 ({
79  { offsetMode::UNIFORM, "uniform" },
80  { offsetMode::NONUNIFORM, "nonuniform" },
81  { offsetMode::NORMAL, "normal" },
82 });
83 
84 
85 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
86 
88 (
89  const polyPatch& pp
90 ) const
91 {
92  const polyMesh& mesh = pp.boundaryMesh().mesh();
93 
94  // Force construction of min-tet decomp
95  (void)mesh.tetBasePtIs();
96 
97  // Initialise to face-centre
98  tmp<pointField> tfacePoints(new pointField(patch_.size()));
99  pointField& facePoints = tfacePoints.ref();
100 
101  forAll(pp, facei)
102  {
103  facePoints[facei] = facePoint
104  (
105  mesh,
106  pp.start()+facei,
107  polyMesh::FACE_DIAG_TRIS
108  ).rawPoint();
109  }
110 
111  return tfacePoints;
112 }
113 
114 
116 (
117  const pointField& facePoints,
119  labelList& patchFaceProcs,
120  labelList& patchFaces,
121  pointField& patchFc
122 ) const
123 {
124  // Collect all sample points and the faces they come from.
125  {
126  List<pointField> globalFc(Pstream::nProcs());
127  globalFc[Pstream::myProcNo()] = facePoints;
128  Pstream::gatherList(globalFc);
129  Pstream::scatterList(globalFc);
130  // Rework into straight list
131  patchFc = ListListOps::combine<pointField>
132  (
133  globalFc,
135  );
136  }
137 
138  {
139  List<pointField> globalSamples(Pstream::nProcs());
140  globalSamples[Pstream::myProcNo()] = samplePoints(facePoints);
141  Pstream::gatherList(globalSamples);
142  Pstream::scatterList(globalSamples);
143  // Rework into straight list
144  samples = ListListOps::combine<pointField>
145  (
146  globalSamples,
148  );
149  }
150 
151  {
152  labelListList globalFaces(Pstream::nProcs());
153  globalFaces[Pstream::myProcNo()] = identity(patch_.size());
154  // Distribute to all processors
155  Pstream::gatherList(globalFaces);
156  Pstream::scatterList(globalFaces);
157 
158  patchFaces = ListListOps::combine<labelList>
159  (
160  globalFaces,
162  );
163  }
164 
165  {
166  labelList nPerProc(Pstream::nProcs());
167  nPerProc[Pstream::myProcNo()] = patch_.size();
168  Pstream::gatherList(nPerProc);
169  Pstream::scatterList(nPerProc);
170 
171  patchFaceProcs.setSize(patchFaces.size());
172 
173  label sampleI = 0;
174  forAll(nPerProc, proci)
175  {
176  for (label i = 0; i < nPerProc[proci]; i++)
177  {
178  patchFaceProcs[sampleI++] = proci;
179  }
180  }
181  }
182 }
183 
184 
185 // Find the processor/cell containing the samples. Does not account
186 // for samples being found in two processors.
188 (
189  const sampleMode mode,
190  const pointField& samples,
191  labelList& sampleProcs,
192  labelList& sampleIndices,
193  pointField& sampleLocations
194 ) const
195 {
196  // Lookup the correct region
197  const polyMesh& mesh = sampleMesh();
198 
199  // All the info for nearest. Construct to miss
200  List<nearInfo> nearest(samples.size());
201 
202  switch (mode)
203  {
204  case NEARESTCELL:
205  {
206  if (samplePatch_.size() && samplePatch_ != "none")
207  {
209  << "No need to supply a patch name when in "
210  << sampleModeNames_[mode] << " mode." << exit(FatalError);
211  }
212 
213  //- Note: face-diagonal decomposition
214  const indexedOctree<Foam::treeDataCell>& tree = mesh.cellTree();
215 
216  forAll(samples, sampleI)
217  {
218  const point& sample = samples[sampleI];
219 
220  label celli = tree.findInside(sample);
221 
222  if (celli == -1)
223  {
224  nearest[sampleI].second().first() = Foam::sqr(GREAT);
225  nearest[sampleI].second().second() = Pstream::myProcNo();
226  }
227  else
228  {
229  const point& cc = mesh.cellCentres()[celli];
230 
231  nearest[sampleI].first() = pointIndexHit
232  (
233  true,
234  cc,
235  celli
236  );
237  nearest[sampleI].second().first() = magSqr(cc-sample);
238  nearest[sampleI].second().second() = Pstream::myProcNo();
239  }
240  }
241  break;
242  }
243 
244  case NEARESTONLYCELL:
245  {
246  if (samplePatch_.size() && samplePatch_ != "none")
247  {
249  << "No need to supply a patch name when in "
250  << sampleModeNames_[mode] << " mode." << exit(FatalError);
251  }
252 
253  //- Note: face-diagonal decomposition
254  const indexedOctree<Foam::treeDataCell>& tree = mesh.cellTree();
255 
256  forAll(samples, sampleI)
257  {
258  const point& sample = samples[sampleI];
259 
260  nearest[sampleI].first() = tree.findNearest(sample, sqr(GREAT));
261  nearest[sampleI].second().first() = magSqr
262  (
263  nearest[sampleI].first().hitPoint()
264  -sample
265  );
266  nearest[sampleI].second().second() = Pstream::myProcNo();
267  }
268  break;
269  }
270 
271  case NEARESTPATCHFACE:
272  {
273  Random rndGen(123456);
274 
275  const polyPatch& pp = samplePolyPatch();
276 
277  if (pp.empty())
278  {
279  forAll(samples, sampleI)
280  {
281  nearest[sampleI].second().first() = Foam::sqr(GREAT);
282  nearest[sampleI].second().second() = Pstream::myProcNo();
283  }
284  }
285  else
286  {
287  // patch faces
288  const labelList patchFaces(identity(pp.size(), pp.start()));
289 
290  treeBoundBox patchBb
291  (
292  treeBoundBox(pp.points(), pp.meshPoints()).extend
293  (
294  rndGen,
295  1e-4
296  )
297  );
298  patchBb.min() -= point::uniform(ROOTVSMALL);
299  patchBb.max() += point::uniform(ROOTVSMALL);
300 
301  indexedOctree<treeDataFace> boundaryTree
302  (
303  treeDataFace // all information needed to search faces
304  (
305  false, // do not cache bb
306  mesh,
307  patchFaces // boundary faces only
308  ),
309  patchBb, // overall search domain
310  8, // maxLevel
311  10, // leafsize
312  3.0 // duplicity
313  );
314 
315  forAll(samples, sampleI)
316  {
317  const point& sample = samples[sampleI];
318 
319  pointIndexHit& nearInfo = nearest[sampleI].first();
320  nearInfo = boundaryTree.findNearest
321  (
322  sample,
323  magSqr(patchBb.span())
324  );
325 
326  if (!nearInfo.hit())
327  {
328  nearest[sampleI].second().first() = Foam::sqr(GREAT);
329  nearest[sampleI].second().second() =
330  Pstream::myProcNo();
331  }
332  else
333  {
334  point fc(pp[nearInfo.index()].centre(pp.points()));
335  nearInfo.setPoint(fc);
336  nearest[sampleI].second().first() = magSqr(fc-sample);
337  nearest[sampleI].second().second() =
338  Pstream::myProcNo();
339  }
340  }
341  }
342  break;
343  }
344 
345  case NEARESTPATCHPOINT:
346  {
347  Random rndGen(123456);
348 
349  const polyPatch& pp = samplePolyPatch();
350 
351  if (pp.empty())
352  {
353  forAll(samples, sampleI)
354  {
355  nearest[sampleI].second().first() = Foam::sqr(GREAT);
356  nearest[sampleI].second().second() = Pstream::myProcNo();
357  }
358  }
359  else
360  {
361  // patch (local) points
362  treeBoundBox patchBb
363  (
364  treeBoundBox(pp.points(), pp.meshPoints()).extend
365  (
366  rndGen,
367  1e-4
368  )
369  );
370  patchBb.min() -= point::uniform(ROOTVSMALL);
371  patchBb.max() += point::uniform(ROOTVSMALL);
372 
373  indexedOctree<treeDataPoint> boundaryTree
374  (
375  treeDataPoint // all information needed to search faces
376  (
377  mesh.points(),
378  pp.meshPoints() // selection of points to search on
379  ),
380  patchBb, // overall search domain
381  8, // maxLevel
382  10, // leafsize
383  3.0 // duplicity
384  );
385 
386  forAll(samples, sampleI)
387  {
388  const point& sample = samples[sampleI];
389 
390  pointIndexHit& nearInfo = nearest[sampleI].first();
391  nearInfo = boundaryTree.findNearest
392  (
393  sample,
394  magSqr(patchBb.span())
395  );
396 
397  if (!nearInfo.hit())
398  {
399  nearest[sampleI].second().first() = Foam::sqr(GREAT);
400  nearest[sampleI].second().second() =
401  Pstream::myProcNo();
402  }
403  else
404  {
405  const point& pt = nearInfo.hitPoint();
406 
407  nearest[sampleI].second().first() = magSqr(pt-sample);
408  nearest[sampleI].second().second() =
409  Pstream::myProcNo();
410  }
411  }
412  }
413  break;
414  }
415 
416  case NEARESTFACE:
417  {
418  if (samplePatch().size() && samplePatch() != "none")
419  {
421  << "No need to supply a patch name when in "
422  << sampleModeNames_[mode] << " mode." << exit(FatalError);
423  }
424 
425  //- Note: face-diagonal decomposition
426  const meshSearchMeshObject& meshSearchEngine =
428 
429  forAll(samples, sampleI)
430  {
431  const point& sample = samples[sampleI];
432 
433  label facei = meshSearchEngine.findNearestFace(sample);
434 
435  if (facei == -1)
436  {
437  nearest[sampleI].second().first() = Foam::sqr(GREAT);
438  nearest[sampleI].second().second() = Pstream::myProcNo();
439  }
440  else
441  {
442  const point& fc = mesh.faceCentres()[facei];
443 
444  nearest[sampleI].first() = pointIndexHit
445  (
446  true,
447  fc,
448  facei
449  );
450  nearest[sampleI].second().first() = magSqr(fc-sample);
451  nearest[sampleI].second().second() = Pstream::myProcNo();
452  }
453  }
454  break;
455  }
456 
457  case NEARESTPATCHFACEAMI:
458  {
459  // nothing to do here
460  return;
461  }
462 
463  default:
464  {
466  << "problem." << abort(FatalError);
467  }
468  }
469 
470 
471  // Find nearest. Combine on master.
472  Pstream::listCombineGather(nearest, nearestEqOp());
473  Pstream::listCombineScatter(nearest);
474 
475 
476  if (debug)
477  {
479  << "mesh " << sampleRegion() << " : " << endl;
480 
481  forAll(nearest, sampleI)
482  {
483  label proci = nearest[sampleI].second().second();
484  label localI = nearest[sampleI].first().index();
485 
486  Info<< " " << sampleI << " coord:"<< samples[sampleI]
487  << " found on processor:" << proci
488  << " in local cell/face/point:" << localI
489  << " with location:" << nearest[sampleI].first().rawPoint()
490  << endl;
491  }
492  }
493 
494  // Convert back into proc+local index
495  sampleProcs.setSize(samples.size());
496  sampleIndices.setSize(samples.size());
497  sampleLocations.setSize(samples.size());
498 
499  forAll(nearest, sampleI)
500  {
501  if (!nearest[sampleI].first().hit())
502  {
503  sampleProcs[sampleI] = -1;
504  sampleIndices[sampleI] = -1;
505  sampleLocations[sampleI] = vector::max;
506  }
507  else
508  {
509  sampleProcs[sampleI] = nearest[sampleI].second().second();
510  sampleIndices[sampleI] = nearest[sampleI].first().index();
511  sampleLocations[sampleI] = nearest[sampleI].first().hitPoint();
512  }
513  }
514 }
515 
516 
518 {
519  static bool hasWarned = false;
520  if (mapPtr_.valid())
521  {
523  << "Mapping already calculated" << exit(FatalError);
524  }
525 
526  // Get points on face (since cannot use face-centres - might be off
527  // face-diagonal decomposed tets.
528  tmp<pointField> patchPoints(facePoints(patch_));
529 
530  // Get offsetted points
531  const pointField offsettedPoints(samplePoints(patchPoints()));
532 
533  // Do a sanity check - am I sampling my own patch?
534  // This only makes sense for a non-zero offset.
535  bool sampleMyself =
536  (
539  && samplePatch() == patch_.name()
540  );
541 
542  // Check offset
543  vectorField d(offsettedPoints-patchPoints());
544  bool coincident = (gAverage(mag(d)) <= ROOTVSMALL);
545 
546  if (sampleMyself && coincident)
547  {
549  << "Invalid offset " << d << endl
550  << "Offset is the vector added to the patch face centres to"
551  << " find the patch face supplying the data." << endl
552  << "Setting it to " << d
553  << " on the same patch, on the same region"
554  << " will find the faces themselves which does not make sense"
555  << " for anything but testing." << endl
556  << "patch_:" << patch_.name() << endl
557  << "sampleRegion_:" << sampleRegion() << endl
558  << "mode_:" << sampleModeNames_[mode_] << endl
559  << "samplePatch_:" << samplePatch() << endl
560  << "offsetMode_:" << offsetModeNames_[offsetMode_] << endl;
561  }
562 
563  // Get global list of all samples and the processor and face they come from.
565  labelList patchFaceProcs;
566  labelList patchFaces;
567  pointField patchFc;
569  (
570  patchPoints,
571  samples,
572  patchFaceProcs,
573  patchFaces,
574  patchFc
575  );
576 
577  // Find processor and cell/face samples are in and actual location.
578  labelList sampleProcs;
579  labelList sampleIndices;
580  pointField sampleLocations;
581  findSamples(mode_, samples, sampleProcs, sampleIndices, sampleLocations);
582 
583  // Check for samples that were not found. This will only happen for
584  // NEARESTCELL since finds cell containing a location
585  if (mode_ == NEARESTCELL)
586  {
587  label nNotFound = 0;
588  forAll(sampleProcs, sampleI)
589  {
590  if (sampleProcs[sampleI] == -1)
591  {
592  nNotFound++;
593  }
594  }
595  reduce(nNotFound, sumOp<label>());
596 
597  if (nNotFound > 0)
598  {
599  if (!hasWarned)
600  {
602  << "Did not find " << nNotFound
603  << " out of " << sampleProcs.size() << " total samples."
604  << " Sampling these on owner cell centre instead." << endl
605  << "On patch " << patch_.name()
606  << " on region " << sampleRegion()
607  << " in mode " << sampleModeNames_[mode_] << endl
608  << "with offset mode " << offsetModeNames_[offsetMode_]
609  << ". Suppressing further warnings from " << type() << endl;
610 
611  hasWarned = true;
612  }
613 
614  // Collect the samples that cannot be found
615  DynamicList<label> subMap;
616  DynamicField<point> subSamples;
617 
618  forAll(sampleProcs, sampleI)
619  {
620  if (sampleProcs[sampleI] == -1)
621  {
622  subMap.append(sampleI);
623  subSamples.append(samples[sampleI]);
624  }
625  }
626 
627  // And re-search for pure nearest (should not fail)
628  labelList subSampleProcs;
629  labelList subSampleIndices;
630  pointField subSampleLocations;
632  (
634  subSamples,
635  subSampleProcs,
636  subSampleIndices,
637  subSampleLocations
638  );
639 
640  // Insert
641  labelUIndList(sampleProcs, subMap) = subSampleProcs;
642  labelUIndList(sampleIndices, subMap) = subSampleIndices;
643  UIndirectList<point>(sampleLocations, subMap) = subSampleLocations;
644  }
645  }
646 
647  // Now we have all the data we need:
648  // - where sample originates from (so destination when mapping):
649  // patchFaces, patchFaceProcs.
650  // - cell/face sample is in (so source when mapping)
651  // sampleIndices, sampleProcs.
652 
653  //forAll(samples, i)
654  //{
655  // Info<< i << " need data in region "
656  // << patch_.boundaryMesh().mesh().name()
657  // << " for proc:" << patchFaceProcs[i]
658  // << " face:" << patchFaces[i]
659  // << " at:" << patchFc[i] << endl
660  // << "Found data in region " << sampleRegion()
661  // << " at proc:" << sampleProcs[i]
662  // << " face:" << sampleIndices[i]
663  // << " at:" << sampleLocations[i]
664  // << nl << endl;
665  //}
666 
667 
668 
669  if (debug && Pstream::master())
670  {
671  OFstream str
672  (
674  / patch_.name()
675  + "_mapped.obj"
676  );
677  Pout<< "Dumping mapping as lines from patch faceCentres to"
678  << " sampled cell/faceCentres/points to file " << str.name()
679  << endl;
680 
681  label vertI = 0;
682 
683  forAll(patchFc, i)
684  {
685  meshTools::writeOBJ(str, patchFc[i]);
686  vertI++;
687  meshTools::writeOBJ(str, sampleLocations[i]);
688  vertI++;
689  str << "l " << vertI-1 << ' ' << vertI << nl;
690  }
691  }
692 
693  // Determine schedule.
694  mapPtr_.reset(new mapDistribute(sampleProcs, patchFaceProcs));
695 
696  // Rework the schedule from indices into samples to cell data to send,
697  // face data to receive.
698 
699  labelListList& subMap = mapPtr_().subMap();
700  labelListList& constructMap = mapPtr_().constructMap();
701 
702  forAll(subMap, proci)
703  {
704  subMap[proci] = labelUIndList(sampleIndices, subMap[proci]);
705  constructMap[proci] = labelUIndList(patchFaces, constructMap[proci]);
706 
707  //if (debug)
708  //{
709  // Pout<< "To proc:" << proci << " sending values of cells/faces:"
710  // << subMap[proci] << endl;
711  // Pout<< "From proc:" << proci
712  // << " receiving values of patch faces:"
713  // << constructMap[proci] << endl;
714  //}
715  }
716 
717  // Redo constructSize
718  mapPtr_().constructSize() = patch_.size();
719 
720  if (debug)
721  {
722  // Check that all elements get a value.
723  bitSet used(patch_.size());
724  forAll(constructMap, proci)
725  {
726  const labelList& map = constructMap[proci];
727 
728  forAll(map, i)
729  {
730  label facei = map[i];
731 
732  if (used.test(facei))
733  {
735  << "On patch " << patch_.name()
736  << " patchface " << facei
737  << " is assigned to more than once."
738  << abort(FatalError);
739  }
740  else
741  {
742  used.set(facei);
743  }
744  }
745  }
746  forAll(used, facei)
747  {
748  if (!used.test(facei))
749  {
751  << "On patch " << patch_.name()
752  << " patchface " << facei
753  << " is never assigned to."
754  << abort(FatalError);
755  }
756  }
757  }
758 }
759 
760 
762 const
763 {
764  const word surfType(surfDict_.getOrDefault<word>("type", "none"));
765 
766  if (!surfPtr_.valid() && surfType != "none")
767  {
768  word surfName(surfDict_.getOrDefault("name", patch_.name()));
769 
770  const polyMesh& mesh = patch_.boundaryMesh().mesh();
771 
772  surfPtr_ =
774  (
775  surfType,
776  IOobject
777  (
778  surfName,
779  mesh.time().constant(),
780  "triSurface",
781  mesh,
784  ),
785  surfDict_
786  );
787  }
788 
789  return surfPtr_;
790 }
791 
792 
794 {
795  if (AMIPtr_->upToDate())
796  {
798  << "AMI already up-to-date"
799  << endl;
800 
801  return;
802  }
803 
804  const polyPatch& nbr = samplePolyPatch();
805 
806  // Transform neighbour patch to local system
807  pointField nbrPoints(samplePoints(nbr.localPoints()));
808 
809  primitivePatch nbrPatch0
810  (
812  (
813  nbr.localFaces(),
814  nbr.size()
815  ),
816  nbrPoints
817  );
818 
819 
820  if (debug)
821  {
822  OFstream os(patch_.name() + "_neighbourPatch-org.obj");
823  meshTools::writeOBJ(os, samplePolyPatch().localFaces(), nbrPoints);
824 
825  OFstream osN(patch_.name() + "_neighbourPatch-trans.obj");
826  meshTools::writeOBJ(osN, nbrPatch0, nbrPoints);
827 
828  OFstream osO(patch_.name() + "_ownerPatch.obj");
829  meshTools::writeOBJ(osO, patch_.localFaces(), patch_.localPoints());
830  }
831 
832  // Construct/apply AMI interpolation to determine addressing and weights
833  AMIPtr_->calculate(patch_, nbrPatch0, surfPtr());
834 }
835 
836 
837 // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
838 
840 :
841  patch_(pp),
842  sampleRegion_(patch_.boundaryMesh().mesh().name()),
843  mode_(NEARESTPATCHFACE),
844  samplePatch_(""),
845  coupleGroup_(),
846  offsetMode_(UNIFORM),
847  offset_(Zero),
848  offsets_(pp.size(), offset_),
849  distance_(0),
850  sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
851  mapPtr_(nullptr),
852  AMIReverse_(false),
853  AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)),
854  surfPtr_(nullptr),
855  surfDict_(fileName("surface"))
856 {}
857 
858 
860 (
861  const polyPatch& pp,
862  const word& sampleRegion,
863  const sampleMode mode,
864  const word& samplePatch,
865  const vectorField& offsets
866 )
867 :
868  patch_(pp),
869  sampleRegion_(sampleRegion),
870  mode_(mode),
871  samplePatch_(samplePatch),
872  coupleGroup_(),
873  offsetMode_(NONUNIFORM),
874  offset_(Zero),
875  offsets_(offsets),
876  distance_(0),
877  sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
878  mapPtr_(nullptr),
879  AMIReverse_(false),
880  AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)),
881  surfPtr_(nullptr),
882  surfDict_(fileName("surface"))
883 {}
884 
885 
887 (
888  const polyPatch& pp,
889  const word& sampleRegion,
890  const sampleMode mode,
891  const word& samplePatch,
892  const vector& offset
893 )
894 :
895  patch_(pp),
896  sampleRegion_(sampleRegion),
897  mode_(mode),
898  samplePatch_(samplePatch),
899  coupleGroup_(),
900  offsetMode_(UNIFORM),
901  offset_(offset),
902  offsets_(0),
903  distance_(0),
904  sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
905  mapPtr_(nullptr),
906  AMIReverse_(false),
907  AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)),
908  surfPtr_(nullptr),
909  surfDict_(fileName("surface"))
910 {}
911 
912 
914 (
915  const polyPatch& pp,
916  const word& sampleRegion,
917  const sampleMode mode,
918  const word& samplePatch,
919  const scalar distance
920 )
921 :
922  patch_(pp),
923  sampleRegion_(sampleRegion),
924  mode_(mode),
925  samplePatch_(samplePatch),
926  coupleGroup_(),
927  offsetMode_(NORMAL),
928  offset_(Zero),
929  offsets_(0),
930  distance_(distance),
931  sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
932  mapPtr_(nullptr),
933  AMIReverse_(false),
934  AMIPtr_(new faceAreaWeightAMI(true, AMIReverse_)),
935  surfPtr_(nullptr),
936  surfDict_(fileName("surface"))
937 {}
938 
939 
941 (
942  const polyPatch& pp,
943  const dictionary& dict
944 )
945 :
946  patch_(pp),
947  sampleRegion_(dict.getOrDefault<word>("sampleRegion", "")),
948  mode_(sampleModeNames_.get("sampleMode", dict)),
949  samplePatch_(dict.getOrDefault<word>("samplePatch", "")),
950  coupleGroup_(dict),
951  offsetMode_(UNIFORM),
952  offset_(Zero),
953  offsets_(),
954  distance_(0),
955  sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
956  mapPtr_(nullptr),
957  AMIReverse_(dict.getOrDefault("flipNormals", false)),
958  AMIPtr_
959  (
961  (
962  dict.getOrDefault("AMIMethod", faceAreaWeightAMI::typeName),
963  dict,
964  AMIReverse_
965  )
966  ),
967  surfPtr_(nullptr),
968  surfDict_(dict.subOrEmptyDict("surface"))
969 {
970  if (!coupleGroup_.valid())
971  {
972  if (sampleRegion_.empty())
973  {
974  // If no coupleGroup and no sampleRegion assume local region
975  sampleRegion_ = patch_.boundaryMesh().mesh().name();
976  sameRegion_ = true;
977  }
978  }
979 
980  if (offsetModeNames_.readIfPresent("offsetMode", dict, offsetMode_))
981  {
982  switch (offsetMode_)
983  {
984  case UNIFORM:
985  {
986  dict.readEntry("offset", offset_);
987  }
988  break;
989 
990  case NONUNIFORM:
991  {
992  offsets_ = pointField("offsets", dict, patch_.size());
993  }
994  break;
995 
996  case NORMAL:
997  {
998  dict.readEntry("distance", distance_);
999  }
1000  break;
1001  }
1002  }
1003  else if (dict.readIfPresent("offset", offset_))
1004  {
1005  offsetMode_ = UNIFORM;
1006  }
1007  else if (dict.found("offsets"))
1008  {
1009  offsetMode_ = NONUNIFORM;
1010  offsets_ = pointField("offsets", dict, patch_.size());
1011  }
1012  else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI)
1013  {
1015  << "Please supply the offsetMode as one of "
1016  << offsetModeNames_
1017  << exit(FatalIOError);
1018  }
1019 }
1020 
1021 
1024  const polyPatch& pp,
1025  const sampleMode mode,
1026  const dictionary& dict
1027 )
1028 :
1029  patch_(pp),
1030  sampleRegion_(dict.getOrDefault<word>("sampleRegion", "")),
1031  mode_(mode),
1032  samplePatch_(dict.getOrDefault<word>("samplePatch", "")),
1033  coupleGroup_(dict), //dict.getOrDefault<word>("coupleGroup", "")),
1034  offsetMode_(UNIFORM),
1035  offset_(Zero),
1036  offsets_(0),
1037  distance_(0),
1038  sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1039  mapPtr_(nullptr),
1040  AMIReverse_(dict.getOrDefault("flipNormals", false)),
1041  AMIPtr_
1042  (
1044  (
1045  dict.getOrDefault("AMIMethod", faceAreaWeightAMI::typeName),
1046  dict,
1047  AMIReverse_
1048  )
1049  ),
1050  surfPtr_(nullptr),
1051  surfDict_(dict.subOrEmptyDict("surface"))
1052 {
1053  if (mode != NEARESTPATCHFACE && mode != NEARESTPATCHFACEAMI)
1054  {
1056  << "Construct from sampleMode and dictionary only applicable for "
1057  << " collocated patches in modes "
1058  << sampleModeNames_[NEARESTPATCHFACE] << ','
1059  << sampleModeNames_[NEARESTPATCHFACEAMI]
1060  << exit(FatalIOError);
1061  }
1062 
1063 
1064  if (!coupleGroup_.valid())
1065  {
1066  if (sampleRegion_.empty())
1067  {
1068  // If no coupleGroup and no sampleRegion assume local region
1069  sampleRegion_ = patch_.boundaryMesh().mesh().name();
1070  sameRegion_ = true;
1071  }
1072  }
1073 }
1074 
1075 
1078  const polyPatch& pp,
1079  const mappedPatchBase& mpb
1080 )
1081 :
1082  patch_(pp),
1083  sampleRegion_(mpb.sampleRegion_),
1084  mode_(mpb.mode_),
1085  samplePatch_(mpb.samplePatch_),
1086  coupleGroup_(mpb.coupleGroup_),
1087  offsetMode_(mpb.offsetMode_),
1088  offset_(mpb.offset_),
1089  offsets_(mpb.offsets_),
1090  distance_(mpb.distance_),
1091  sameRegion_(mpb.sameRegion_),
1092  mapPtr_(nullptr),
1093  AMIReverse_(mpb.AMIReverse_),
1094  AMIPtr_(mpb.AMIPtr_->clone()),
1095  surfPtr_(nullptr),
1096  surfDict_(mpb.surfDict_)
1097 {}
1098 
1099 
1102  const polyPatch& pp,
1103  const mappedPatchBase& mpb,
1104  const labelUList& mapAddressing
1105 )
1106 :
1107  patch_(pp),
1108  sampleRegion_(mpb.sampleRegion_),
1109  mode_(mpb.mode_),
1110  samplePatch_(mpb.samplePatch_),
1111  coupleGroup_(mpb.coupleGroup_),
1112  offsetMode_(mpb.offsetMode_),
1113  offset_(mpb.offset_),
1114  offsets_
1115  (
1116  offsetMode_ == NONUNIFORM
1117  ? vectorField(mpb.offsets_, mapAddressing)
1118  : vectorField()
1119  ),
1120  distance_(mpb.distance_),
1121  sameRegion_(mpb.sameRegion_),
1122  mapPtr_(nullptr),
1123  AMIReverse_(mpb.AMIReverse_),
1124  AMIPtr_(mpb.AMIPtr_->clone()),
1125  surfPtr_(nullptr),
1126  surfDict_(mpb.surfDict_)
1127 {}
1128 
1129 
1130 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
1131 
1133 {
1134  clearOut();
1135 }
1136 
1137 
1139 {
1140  mapPtr_.clear();
1141  surfPtr_.clear();
1142  AMIPtr_->upToDate() = false;
1143 }
1144 
1145 
1146 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
1147 
1149 {
1150  const polyMesh& thisMesh = patch_.boundaryMesh().mesh();
1151 
1152  return
1153  (
1154  sameRegion_
1155  ? thisMesh
1156  : thisMesh.time().lookupObject<polyMesh>(sampleRegion())
1157  );
1158 }
1159 
1160 
1162 {
1163  const polyMesh& nbrMesh = sampleMesh();
1164 
1165  const label patchi = nbrMesh.boundaryMesh().findPatchID(samplePatch());
1166 
1167  if (patchi == -1)
1168  {
1170  << "Cannot find patch " << samplePatch()
1171  << " in region " << sampleRegion_ << endl
1172  << "Valid patches are " << nbrMesh.boundaryMesh().names()
1173  << exit(FatalError);
1174  }
1175 
1176  return nbrMesh.boundaryMesh()[patchi];
1177 }
1178 
1179 
1182  const pointField& fc
1183 ) const
1184 {
1185  tmp<pointField> tfld(new pointField(fc));
1186  pointField& fld = tfld.ref();
1187 
1188  switch (offsetMode_)
1189  {
1190  case UNIFORM:
1191  {
1192  fld += offset_;
1193  break;
1194  }
1195  case NONUNIFORM:
1196  {
1197  fld += offsets_;
1198  break;
1199  }
1200  case NORMAL:
1201  {
1202  // Get outwards pointing normal
1203  vectorField n(patch_.faceAreas());
1204  n /= mag(n);
1205 
1206  fld += distance_*n;
1207  break;
1208  }
1209  }
1210 
1211  return tfld;
1212 }
1213 
1214 
1216 {
1217  return samplePoints(facePoints(patch_));
1218 }
1219 
1220 
1223  const polyMesh& mesh,
1224  const label facei,
1225  const polyMesh::cellDecomposition decompMode
1226 )
1227 {
1228  const point& fc = mesh.faceCentres()[facei];
1229 
1230  switch (decompMode)
1231  {
1232  case polyMesh::FACE_PLANES:
1234  {
1235  // For both decompositions the face centre is guaranteed to be
1236  // on the face
1237  return pointIndexHit(true, fc, facei);
1238  }
1239  break;
1240 
1242  case polyMesh::CELL_TETS:
1243  {
1244  // Find the intersection of a ray from face centre to cell centre
1245  // Find intersection of (face-centre-decomposition) centre to
1246  // cell-centre with face-diagonal-decomposition triangles.
1247 
1248  const pointField& p = mesh.points();
1249  const face& f = mesh.faces()[facei];
1250 
1251  if (f.size() <= 3)
1252  {
1253  // Return centre of triangle.
1254  return pointIndexHit(true, fc, 0);
1255  }
1256 
1257  label celli = mesh.faceOwner()[facei];
1258  const point& cc = mesh.cellCentres()[celli];
1259  vector d = fc-cc;
1260 
1261  const label fp0 = mesh.tetBasePtIs()[facei];
1262  const point& basePoint = p[f[fp0]];
1263 
1264  label fp = f.fcIndex(fp0);
1265  for (label i = 2; i < f.size(); i++)
1266  {
1267  const point& thisPoint = p[f[fp]];
1268  label nextFp = f.fcIndex(fp);
1269  const point& nextPoint = p[f[nextFp]];
1270 
1271  const triPointRef tri(basePoint, thisPoint, nextPoint);
1272  pointHit hitInfo = tri.intersection
1273  (
1274  cc,
1275  d,
1277  );
1278 
1279  if (hitInfo.hit() && hitInfo.distance() > 0)
1280  {
1281  return pointIndexHit(true, hitInfo.hitPoint(), i-2);
1282  }
1283 
1284  fp = nextFp;
1285  }
1286 
1287  // Fall-back
1288  return pointIndexHit(false, fc, -1);
1289  }
1290  break;
1291 
1292  default:
1293  {
1295  << "problem" << abort(FatalError);
1296  return pointIndexHit();
1297  }
1298  }
1299 }
1300 
1301 
1303 {
1304  os.writeEntry("sampleMode", sampleModeNames_[mode_]);
1305  if (!sampleRegion_.empty())
1306  {
1307  os.writeEntry("sampleRegion", sampleRegion_);
1308  }
1309  if (!samplePatch_.empty())
1310  {
1311  os.writeEntry("samplePatch", samplePatch_);
1312  }
1313  coupleGroup_.write(os);
1314 
1315  if
1316  (
1317  offsetMode_ == UNIFORM
1318  && offset_ == vector::zero
1319  && (mode_ == NEARESTPATCHFACE || mode_ == NEARESTPATCHFACEAMI)
1320  )
1321  {
1322  // Collocated mode. No need to write offset data
1323  }
1324  else
1325  {
1326  os.writeEntry("offsetMode", offsetModeNames_[offsetMode_]);
1327 
1328  switch (offsetMode_)
1329  {
1330  case UNIFORM:
1331  {
1332  os.writeEntry("offset", offset_);
1333  break;
1334  }
1335  case NONUNIFORM:
1336  {
1337  offsets_.writeEntry("offsets", os);
1338  break;
1339  }
1340  case NORMAL:
1341  {
1342  os.writeEntry("distance", distance_);
1343  break;
1344  }
1345  }
1346 
1347  if (mode_ == NEARESTPATCHFACEAMI)
1348  {
1349  if (AMIReverse_)
1350  {
1351  os.writeEntry("flipNormals", AMIReverse_);
1352  }
1353 
1354  if (!surfDict_.empty())
1355  {
1356  surfDict_.writeEntry(surfDict_.dictName(), os);
1357  }
1358  }
1359  }
1360 }
1361 
1362 
1363 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::IOobject::NO_WRITE
Definition: IOobject.H:130
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Foam::Random
Random number generator.
Definition: Random.H:59
Foam::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1038
Foam::mappedPatchBase::write
virtual void write(Ostream &) const
Write as a dictionary.
Definition: mappedPatchBase.C:1302
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
meshTools.H
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:320
Foam::mappedPatchBase::clearOut
void clearOut()
Definition: mappedPatchBase.C:1138
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Enum
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: IOstreamOption.H:57
Foam::polyMesh::FACE_DIAG_TRIS
Definition: polyMesh.H:108
Foam::polyMesh::cellDecomposition
cellDecomposition
Enumeration defining the decomposition of the cell for.
Definition: polyMesh.H:101
Foam::accessOp
Definition: UList.H:614
Foam::mappedPatchBase::AMIReverse_
const bool AMIReverse_
Flag to indicate that slave patch should be reversed for AMI.
Definition: mappedPatchBase.H:234
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobjectI.H:70
Foam::PointHit::hit
bool hit() const
Is there a hit.
Definition: PointHit.H:124
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
SubField.H
Foam::intersection::HALF_RAY
Definition: intersection.H:75
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:64
polyPatch.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::PointHit< point >
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
meshSearchMeshObject.H
Foam::DynamicList< label >
Foam::dictionary::found
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionary.C:364
Foam::mappedPatchBase::map
const mapDistribute & map() const
Return reference to the parallel distribution map.
Definition: mappedPatchBaseI.H:146
Foam::gAverage
Type gAverage(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:604
Foam::meshTools::writeOBJ
void writeOBJ(Ostream &os, const point &pt)
Write obj representation of a point.
Definition: meshTools.C:203
ListListOps.H
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
Foam::mappedPatchBase::samplePolyPatch
const polyPatch & samplePolyPatch() const
Get the patch on the region.
Definition: mappedPatchBase.C:1161
Foam::treeBoundBox
Standard boundBox with extra functionality for use in octree.
Definition: treeBoundBox.H:87
Foam::objectRegistry::time
const Time & time() const
Return time.
Definition: objectRegistry.H:186
indexedOctree.H
Foam::mappedPatchBase::mappedPatchBase
mappedPatchBase(const polyPatch &)
Construct from patch.
Definition: mappedPatchBase.C:839
Foam::mappedPatchBase::collectSamples
void collectSamples(const pointField &facePoints, pointField &, labelList &patchFaceProcs, labelList &patchFaces, pointField &patchFc) const
Collect single list of samples and originating processor+face.
Definition: mappedPatchBase.C:116
Foam::mappedPatchBase::offset_
vector offset_
Offset vector (uniform)
Definition: mappedPatchBase.H:209
Foam::mappedPatchBase::mode_
const sampleMode mode_
What to sample.
Definition: mappedPatchBase.H:197
Foam::HashSet::test
bool test(const Key &key) const noexcept
Same as found() - return true if key exists in the set.
Definition: HashSet.H:170
Foam::mappedPatchBase::offsetModeNames_
static const Enum< offsetMode > offsetModeNames_
Definition: mappedPatchBase.H:133
Foam::FatalIOError
IOerror FatalIOError
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:435
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::Pout
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
Foam::mappedPatchBase::samplePatch_
word samplePatch_
Patch (if in sampleMode NEARESTPATCH*)
Definition: mappedPatchBase.H:200
triPointRef.H
Foam::AMIInterpolation::New
static autoPtr< AMIInterpolation > New(const word &modelName, const dictionary &dict, const bool reverseTarget=false)
Selector for dictionary.
Definition: AMIInterpolationNew.C:33
Foam::mappedPatchBase
Determines a mapping between patch face centres and mesh cell or face centres and processors they're ...
Definition: mappedPatchBase.H:105
Foam::mappedPatchBase::nearestEqOp
Definition: mappedPatchBase.H:143
polyMesh.H
Foam::mappedPatchBase::NEARESTONLYCELL
nearest cell (even if not containing cell)
Definition: mappedPatchBase.H:120
syncTools.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::mappedPatchBase::coupleGroup_
const coupleGroupIdentifier coupleGroup_
PatchGroup (if in sampleMode NEARESTPATCH*)
Definition: mappedPatchBase.H:203
Foam::polyBoundaryMesh::names
wordList names() const
Return a list of patch names.
Definition: polyBoundaryMesh.C:593
Foam::boundBox::min
const point & min() const
Minimum describing the bounding box.
Definition: boundBoxI.H:91
Foam::sumOp
Definition: ops.H:213
Foam::mappedPatchBase::~mappedPatchBase
virtual ~mappedPatchBase()
Destructor.
Definition: mappedPatchBase.C:1132
Foam::treeDataPoint
Holds (reference to) pointField. Encapsulation of data needed for octree searches....
Definition: treeDataPoint.H:62
Foam::mappedPatchBase::sampleModeNames_
static const Enum< sampleMode > sampleModeNames_
Definition: mappedPatchBase.H:131
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::mappedPatchBase::surfPtr
const autoPtr< Foam::searchableSurface > & surfPtr() const
Return a pointer to the AMI projection surface.
Definition: mappedPatchBase.C:761
OFstream.H
Foam::faceAreaWeightAMI
Face area weighted Arbitrary Mesh Interface (AMI) method.
Definition: faceAreaWeightAMI.H:51
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::meshSearchMeshObject
MeshObject wrapper around meshSearch(mesh).
Definition: meshSearchMeshObject.H:51
Foam::magSqr
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
treeDataFace.H
Foam::DynamicField
Dynamically sized Field.
Definition: DynamicField.H:51
Foam::facePoint
label facePoint(const int facei, const block &block, const label i, const label j)
Definition: blockMeshMergeTopological.C:212
Foam::mode
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Definition: MSwindows.C:564
Foam::mappedPatchBase::mapPtr_
autoPtr< mapDistribute > mapPtr_
Communication schedule:
Definition: mappedPatchBase.H:228
Foam::mappedPatchBase::sampleRegion_
word sampleRegion_
Region to sample.
Definition: mappedPatchBase.H:194
Foam::mappedPatchBase::samplePoints
tmp< pointField > samplePoints() const
Get the sample points.
Definition: mappedPatchBase.C:1215
Foam::triangle
A triangle primitive used to calculate face normals and swept volumes.
Definition: triangle.H:62
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::mappedPatchBase::sampleMesh
const polyMesh & sampleMesh() const
Get the region mesh.
Definition: mappedPatchBase.C:1148
Foam::meshSearch::findNearestFace
label findNearestFace(const point &location, const label seedFacei=-1, const bool useTreeSearch=true) const
Definition: meshSearch.C:758
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:51
Foam::PointIndexHit
This class describes the interaction of (usually) a face and a point. It carries the info of a succes...
Definition: PointIndexHit.H:55
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
Foam::PointHit::distance
scalar distance() const
Return distance to hit.
Definition: PointHit.H:143
Foam::Field< vector >
treeDataPoint.H
Foam::polyPatch::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:307
Foam::polyMesh::FACE_CENTRE_TRIS
Definition: polyMesh.H:105
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:360
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:67
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::OSstream::name
virtual const fileName & name() const
Return the name of the stream.
Definition: OSstream.H:107
Foam::DynamicList::append
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
Definition: DynamicListI.H:472
Foam::mapDistribute
Class containing processor-to-processor mapping information.
Definition: mapDistribute.H:163
Foam::polyMesh::faceOwner
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1076
Foam::indexedOctree< Foam::treeDataCell >
Foam::dictionary::readEntry
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Definition: dictionaryTemplates.C:314
samples
scalarField samples(nIntervals, Zero)
Foam::polyBoundaryMesh::mesh
const polyMesh & mesh() const
Return the mesh reference.
Definition: polyBoundaryMesh.H:144
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:434
Foam::polyBoundaryMesh::findPatchID
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
Definition: polyBoundaryMesh.C:766
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
Foam::indexedOctree::findInside
label findInside(const point &) const
Find shape containing point. Only implemented for certain.
Definition: indexedOctree.C:2629
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::mappedPatchBase::offsets_
vectorField offsets_
Offset vector (nonuniform)
Definition: mappedPatchBase.H:212
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::PrimitivePatch::points
const Field< point_type > & points() const
Return reference to global points.
Definition: PrimitivePatch.H:305
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::mappedPatchBase::distance_
scalar distance_
Offset distance (normal)
Definition: mappedPatchBase.H:215
Foam::PrimitivePatch::localFaces
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
Definition: PrimitivePatch.C:297
Foam::mappedPatchBase::calcAMI
void calcAMI() const
Calculate AMI interpolator.
Definition: mappedPatchBase.C:793
Foam::Ostream::write
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
treeDataCell.H
Foam::searchableSurface::New
static autoPtr< searchableSurface > New(const word &surfaceType, const IOobject &io, const dictionary &dict)
Return a reference to the selected searchableSurface.
Definition: searchableSurface.C:43
Foam::polyPatch::start
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:312
Foam::mappedPatchBase::sampleRegion
const word & sampleRegion() const
Region to sample.
Definition: mappedPatchBaseI.H:35
Foam::dictionary::subOrEmptyDict
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
Definition: dictionary.C:608
Foam::distance
scalar distance(const vector &p1, const vector &p2)
Definition: curveTools.C:12
Random.H
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::PrimitivePatch::localPoints
const Field< point_type > & localPoints() const
Return pointField of points in patch.
Definition: PrimitivePatch.C:339
Foam::OFstream
Output to file stream, using an OSstream.
Definition: OFstream.H:87
Foam::UPstream::master
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:439
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::mappedPatchBase::calcMapping
void calcMapping() const
Calculate mapping.
Definition: mappedPatchBase.C:517
Time.H
Foam::autoPtr< Foam::searchableSurface >
Foam::primitiveMesh::cellCentres
const vectorField & cellCentres() const
Definition: primitiveMeshCellCentresAndVols.C:175
Foam::polyMesh::CELL_TETS
Definition: polyMesh.H:110
Foam::polyMesh::faces
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1063
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:372
DynamicField.H
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::pointIndexHit
PointIndexHit< point > pointIndexHit
Definition: pointIndexHit.H:45
Foam::nl
constexpr char nl
Definition: Ostream.H:385
Foam::Time::path
fileName path() const
Return path.
Definition: Time.H:358
mapDistribute.H
f
labelList f(nPoints)
faceAreaWeightAMI.H
Foam::mappedPatchBase::NEARESTPATCHFACE
nearest face on selected patch
Definition: mappedPatchBase.H:116
Foam::Vector< scalar >
Foam::List< label >
Foam::HashSetOps::used
labelHashSet used(const bitSet &select)
Convert a bitset to a labelHashSet of the indices used.
Definition: HashOps.C:35
Foam::treeDataFace
Encapsulation of data needed to search for faces.
Definition: treeDataFace.H:59
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::primitiveMesh::faceCentres
const vectorField & faceCentres() const
Definition: primitiveMeshFaceCentresAndAreas.C:144
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::UList< label >
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::identity
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
Definition: labelList.C:38
Foam::mappedPatchBase::offsetMode_
offsetMode offsetMode_
How to obtain samples.
Definition: mappedPatchBase.H:206
Foam::triangle::intersection
pointHit intersection(const point &p, const vector &q, const intersection::algorithm alg, const scalar tol=0.0) const
Fast intersection with a ray.
Definition: triangleI.H:439
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:232
Foam::mappedPatchBase::NEARESTCELL
nearest cell containing sample
Definition: mappedPatchBase.H:115
Foam::Tuple2::second
const T2 & second() const noexcept
Return second.
Definition: Tuple2.H:130
Foam::mappedPatchBase::offsetMode
offsetMode
How to project face centres.
Definition: mappedPatchBase.H:124
rndGen
Random rndGen
Definition: createFields.H:23
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:248
Foam::VectorSpace< Vector< scalar >, scalar, 3 >::zero
static const Vector< scalar > zero
Definition: VectorSpace.H:115
Foam::UIndirectList
A List with indirect addressing.
Definition: fvMatrix.H:109
Foam::boundaryMesh
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
Definition: boundaryMesh.H:62
Foam::mappedPatchBase::findSamples
void findSamples(const sampleMode mode, const pointField &, labelList &sampleProcs, labelList &sampleIndices, pointField &sampleLocations) const
Find cells/faces containing samples.
Definition: mappedPatchBase.C:188
Foam::mappedPatchBase::facePoints
tmp< pointField > facePoints(const polyPatch &) const
Get the points from face-centre-decomposition face centres.
Definition: mappedPatchBase.C:88
Foam::polyMesh::FACE_PLANES
Definition: polyMesh.H:103
Foam::mappedPatchBase::surfDict_
dictionary surfDict_
Dictionary storing projection surface description.
Definition: mappedPatchBase.H:243
Foam::mappedPatchBase::AMIPtr_
autoPtr< AMIPatchToPatchInterpolation > AMIPtr_
Pointer to AMI interpolator.
Definition: mappedPatchBase.H:237
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:72
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:392
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::mappedPatchBase::patch_
const polyPatch & patch_
Patch to sample.
Definition: mappedPatchBase.H:191
Foam::mappedPatchBase::sameRegion_
bool sameRegion_
Same region.
Definition: mappedPatchBase.H:218
Foam::Tuple2
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:57
Foam::PrimitivePatch::meshPoints
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Definition: PrimitivePatch.C:310
Foam::List::setSize
void setSize(const label newSize)
Alias for resize(const label)
Definition: ListI.H:146
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:88
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:122
Foam::DynamicField::append
DynamicField< T, SizeMin > & append(const T &val)
Append an element at the end of the list.
Definition: DynamicFieldI.H:475
Foam::mappedPatchBase::facePoint
static pointIndexHit facePoint(const polyMesh &, const label facei, const polyMesh::cellDecomposition)
Get a point on the face given a face decomposition method:
Definition: mappedPatchBase.C:1222
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::patchIdentifier::name
const word & name() const
The patch name.
Definition: patchIdentifier.H:134
Foam::Tuple2::first
const T1 & first() const noexcept
Return first.
Definition: Tuple2.H:118
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:298
Foam::PointHit::hitPoint
const Point & hitPoint() const
Return hit point.
Definition: PointHit.H:130
Foam::mappedPatchBase::sampleMode
sampleMode
Mesh items to sample.
Definition: mappedPatchBase.H:113
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:417
Foam::HashSet::set
bool set(const Key &key)
Same as insert (no value to overwrite)
Definition: HashSet.H:187
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:85
Foam::IOobject::MUST_READ
Definition: IOobject.H:120
Foam::labelUIndList
UIndirectList< label > labelUIndList
UIndirectList of labels.
Definition: UIndirectList.H:58
mappedPatchBase.H
Foam::polyMesh::tetBasePtIs
const labelIOList & tetBasePtIs() const
Return the tetBasePtIs.
Definition: polyMesh.C:861
Foam::mappedPatchBase::samplePatch
const word & samplePatch() const
Patch (only if NEARESTPATCHFACE)
Definition: mappedPatchBaseI.H:61