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-2018 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 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53  defineTypeNameAndDebug(mappedPatchBase, 0);
54 }
55 
56 
57 const Foam::Enum
58 <
60 >
62 ({
63  { sampleMode::NEARESTCELL, "nearestCell" },
64  { sampleMode::NEARESTPATCHFACE, "nearestPatchFace" },
65  { sampleMode::NEARESTPATCHFACEAMI, "nearestPatchFaceAMI" },
66  { sampleMode::NEARESTPATCHPOINT, "nearestPatchPoint" },
67  { sampleMode::NEARESTFACE, "nearestFace" },
68  { sampleMode::NEARESTONLYCELL, "nearestOnlyCell" },
69 });
70 
71 
72 const Foam::Enum
73 <
75 >
77 ({
78  { offsetMode::UNIFORM, "uniform" },
79  { offsetMode::NONUNIFORM, "nonuniform" },
80  { offsetMode::NORMAL, "normal" },
81 });
82 
83 
84 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
85 
87 (
88  const polyPatch& pp
89 ) const
90 {
91  const polyMesh& mesh = pp.boundaryMesh().mesh();
92 
93  // Force construction of min-tet decomp
94  (void)mesh.tetBasePtIs();
95 
96  // Initialise to face-centre
97  tmp<pointField> tfacePoints(new pointField(patch_.size()));
98  pointField& facePoints = tfacePoints.ref();
99 
100  forAll(pp, facei)
101  {
102  facePoints[facei] = facePoint
103  (
104  mesh,
105  pp.start()+facei,
106  polyMesh::FACE_DIAG_TRIS
107  ).rawPoint();
108  }
109 
110  return tfacePoints;
111 }
112 
113 
115 (
116  const pointField& facePoints,
118  labelList& patchFaceProcs,
119  labelList& patchFaces,
120  pointField& patchFc
121 ) const
122 {
123  // Collect all sample points and the faces they come from.
124  {
125  List<pointField> globalFc(Pstream::nProcs());
126  globalFc[Pstream::myProcNo()] = facePoints;
127  Pstream::gatherList(globalFc);
128  Pstream::scatterList(globalFc);
129  // Rework into straight list
130  patchFc = ListListOps::combine<pointField>
131  (
132  globalFc,
134  );
135  }
136 
137  {
138  List<pointField> globalSamples(Pstream::nProcs());
139  globalSamples[Pstream::myProcNo()] = samplePoints(facePoints);
140  Pstream::gatherList(globalSamples);
141  Pstream::scatterList(globalSamples);
142  // Rework into straight list
143  samples = ListListOps::combine<pointField>
144  (
145  globalSamples,
147  );
148  }
149 
150  {
151  labelListList globalFaces(Pstream::nProcs());
152  globalFaces[Pstream::myProcNo()] = identity(patch_.size());
153  // Distribute to all processors
154  Pstream::gatherList(globalFaces);
155  Pstream::scatterList(globalFaces);
156 
157  patchFaces = ListListOps::combine<labelList>
158  (
159  globalFaces,
161  );
162  }
163 
164  {
165  labelList nPerProc(Pstream::nProcs());
166  nPerProc[Pstream::myProcNo()] = patch_.size();
167  Pstream::gatherList(nPerProc);
168  Pstream::scatterList(nPerProc);
169 
170  patchFaceProcs.setSize(patchFaces.size());
171 
172  label sampleI = 0;
173  forAll(nPerProc, proci)
174  {
175  for (label i = 0; i < nPerProc[proci]; i++)
176  {
177  patchFaceProcs[sampleI++] = proci;
178  }
179  }
180  }
181 }
182 
183 
184 // Find the processor/cell containing the samples. Does not account
185 // for samples being found in two processors.
187 (
188  const sampleMode mode,
189  const pointField& samples,
190  labelList& sampleProcs,
191  labelList& sampleIndices,
192  pointField& sampleLocations
193 ) const
194 {
195  // Lookup the correct region
196  const polyMesh& mesh = sampleMesh();
197 
198  // All the info for nearest. Construct to miss
199  List<nearInfo> nearest(samples.size());
200 
201  switch (mode)
202  {
203  case NEARESTCELL:
204  {
205  if (samplePatch_.size() && samplePatch_ != "none")
206  {
208  << "No need to supply a patch name when in "
209  << sampleModeNames_[mode] << " mode." << exit(FatalError);
210  }
211 
212  //- Note: face-diagonal decomposition
213  const indexedOctree<Foam::treeDataCell>& tree = mesh.cellTree();
214 
215  forAll(samples, sampleI)
216  {
217  const point& sample = samples[sampleI];
218 
219  label celli = tree.findInside(sample);
220 
221  if (celli == -1)
222  {
223  nearest[sampleI].second().first() = Foam::sqr(GREAT);
224  nearest[sampleI].second().second() = Pstream::myProcNo();
225  }
226  else
227  {
228  const point& cc = mesh.cellCentres()[celli];
229 
230  nearest[sampleI].first() = pointIndexHit
231  (
232  true,
233  cc,
234  celli
235  );
236  nearest[sampleI].second().first() = magSqr(cc-sample);
237  nearest[sampleI].second().second() = Pstream::myProcNo();
238  }
239  }
240  break;
241  }
242 
243  case NEARESTONLYCELL:
244  {
245  if (samplePatch_.size() && samplePatch_ != "none")
246  {
248  << "No need to supply a patch name when in "
249  << sampleModeNames_[mode] << " mode." << exit(FatalError);
250  }
251 
252  //- Note: face-diagonal decomposition
253  const indexedOctree<Foam::treeDataCell>& tree = mesh.cellTree();
254 
255  forAll(samples, sampleI)
256  {
257  const point& sample = samples[sampleI];
258 
259  nearest[sampleI].first() = tree.findNearest(sample, sqr(GREAT));
260  nearest[sampleI].second().first() = magSqr
261  (
262  nearest[sampleI].first().hitPoint()
263  -sample
264  );
265  nearest[sampleI].second().second() = Pstream::myProcNo();
266  }
267  break;
268  }
269 
270  case NEARESTPATCHFACE:
271  {
272  Random rndGen(123456);
273 
274  const polyPatch& pp = samplePolyPatch();
275 
276  if (pp.empty())
277  {
278  forAll(samples, sampleI)
279  {
280  nearest[sampleI].second().first() = Foam::sqr(GREAT);
281  nearest[sampleI].second().second() = Pstream::myProcNo();
282  }
283  }
284  else
285  {
286  // patch faces
287  const labelList patchFaces(identity(pp.size(), pp.start()));
288 
289  treeBoundBox patchBb
290  (
291  treeBoundBox(pp.points(), pp.meshPoints()).extend
292  (
293  rndGen,
294  1e-4
295  )
296  );
297  patchBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
298  patchBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
299 
300  indexedOctree<treeDataFace> boundaryTree
301  (
302  treeDataFace // all information needed to search faces
303  (
304  false, // do not cache bb
305  mesh,
306  patchFaces // boundary faces only
307  ),
308  patchBb, // overall search domain
309  8, // maxLevel
310  10, // leafsize
311  3.0 // duplicity
312  );
313 
314  forAll(samples, sampleI)
315  {
316  const point& sample = samples[sampleI];
317 
318  pointIndexHit& nearInfo = nearest[sampleI].first();
319  nearInfo = boundaryTree.findNearest
320  (
321  sample,
322  magSqr(patchBb.span())
323  );
324 
325  if (!nearInfo.hit())
326  {
327  nearest[sampleI].second().first() = Foam::sqr(GREAT);
328  nearest[sampleI].second().second() =
329  Pstream::myProcNo();
330  }
331  else
332  {
333  point fc(pp[nearInfo.index()].centre(pp.points()));
334  nearInfo.setPoint(fc);
335  nearest[sampleI].second().first() = magSqr(fc-sample);
336  nearest[sampleI].second().second() =
337  Pstream::myProcNo();
338  }
339  }
340  }
341  break;
342  }
343 
344  case NEARESTPATCHPOINT:
345  {
346  Random rndGen(123456);
347 
348  const polyPatch& pp = samplePolyPatch();
349 
350  if (pp.empty())
351  {
352  forAll(samples, sampleI)
353  {
354  nearest[sampleI].second().first() = Foam::sqr(GREAT);
355  nearest[sampleI].second().second() = Pstream::myProcNo();
356  }
357  }
358  else
359  {
360  // patch (local) points
361  treeBoundBox patchBb
362  (
363  treeBoundBox(pp.points(), pp.meshPoints()).extend
364  (
365  rndGen,
366  1e-4
367  )
368  );
369  patchBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
370  patchBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
371 
372  indexedOctree<treeDataPoint> boundaryTree
373  (
374  treeDataPoint // all information needed to search faces
375  (
376  mesh.points(),
377  pp.meshPoints() // selection of points to search on
378  ),
379  patchBb, // overall search domain
380  8, // maxLevel
381  10, // leafsize
382  3.0 // duplicity
383  );
384 
385  forAll(samples, sampleI)
386  {
387  const point& sample = samples[sampleI];
388 
389  pointIndexHit& nearInfo = nearest[sampleI].first();
390  nearInfo = boundaryTree.findNearest
391  (
392  sample,
393  magSqr(patchBb.span())
394  );
395 
396  if (!nearInfo.hit())
397  {
398  nearest[sampleI].second().first() = Foam::sqr(GREAT);
399  nearest[sampleI].second().second() =
400  Pstream::myProcNo();
401  }
402  else
403  {
404  const point& pt = nearInfo.hitPoint();
405 
406  nearest[sampleI].second().first() = magSqr(pt-sample);
407  nearest[sampleI].second().second() =
408  Pstream::myProcNo();
409  }
410  }
411  }
412  break;
413  }
414 
415  case NEARESTFACE:
416  {
417  if (samplePatch().size() && samplePatch() != "none")
418  {
420  << "No need to supply a patch name when in "
421  << sampleModeNames_[mode] << " mode." << exit(FatalError);
422  }
423 
424  //- Note: face-diagonal decomposition
425  const meshSearchMeshObject& meshSearchEngine =
427 
428  forAll(samples, sampleI)
429  {
430  const point& sample = samples[sampleI];
431 
432  label facei = meshSearchEngine.findNearestFace(sample);
433 
434  if (facei == -1)
435  {
436  nearest[sampleI].second().first() = Foam::sqr(GREAT);
437  nearest[sampleI].second().second() = Pstream::myProcNo();
438  }
439  else
440  {
441  const point& fc = mesh.faceCentres()[facei];
442 
443  nearest[sampleI].first() = pointIndexHit
444  (
445  true,
446  fc,
447  facei
448  );
449  nearest[sampleI].second().first() = magSqr(fc-sample);
450  nearest[sampleI].second().second() = Pstream::myProcNo();
451  }
452  }
453  break;
454  }
455 
456  case NEARESTPATCHFACEAMI:
457  {
458  // nothing to do here
459  return;
460  }
461 
462  default:
463  {
465  << "problem." << abort(FatalError);
466  }
467  }
468 
469 
470  // Find nearest. Combine on master.
471  Pstream::listCombineGather(nearest, nearestEqOp());
472  Pstream::listCombineScatter(nearest);
473 
474 
475  if (debug)
476  {
478  << "mesh " << sampleRegion() << " : " << endl;
479 
480  forAll(nearest, sampleI)
481  {
482  label proci = nearest[sampleI].second().second();
483  label localI = nearest[sampleI].first().index();
484 
485  Info<< " " << sampleI << " coord:"<< samples[sampleI]
486  << " found on processor:" << proci
487  << " in local cell/face/point:" << localI
488  << " with location:" << nearest[sampleI].first().rawPoint()
489  << endl;
490  }
491  }
492 
493  // Convert back into proc+local index
494  sampleProcs.setSize(samples.size());
495  sampleIndices.setSize(samples.size());
496  sampleLocations.setSize(samples.size());
497 
498  forAll(nearest, sampleI)
499  {
500  if (!nearest[sampleI].first().hit())
501  {
502  sampleProcs[sampleI] = -1;
503  sampleIndices[sampleI] = -1;
504  sampleLocations[sampleI] = vector::max;
505  }
506  else
507  {
508  sampleProcs[sampleI] = nearest[sampleI].second().second();
509  sampleIndices[sampleI] = nearest[sampleI].first().index();
510  sampleLocations[sampleI] = nearest[sampleI].first().hitPoint();
511  }
512  }
513 }
514 
515 
517 {
518  static bool hasWarned = false;
519  if (mapPtr_.valid())
520  {
522  << "Mapping already calculated" << exit(FatalError);
523  }
524 
525  // Get points on face (since cannot use face-centres - might be off
526  // face-diagonal decomposed tets.
527  tmp<pointField> patchPoints(facePoints(patch_));
528 
529  // Get offsetted points
530  const pointField offsettedPoints(samplePoints(patchPoints()));
531 
532  // Do a sanity check - am I sampling my own patch?
533  // This only makes sense for a non-zero offset.
534  bool sampleMyself =
535  (
538  && samplePatch() == patch_.name()
539  );
540 
541  // Check offset
542  vectorField d(offsettedPoints-patchPoints());
543  bool coincident = (gAverage(mag(d)) <= ROOTVSMALL);
544 
545  if (sampleMyself && coincident)
546  {
548  << "Invalid offset " << d << endl
549  << "Offset is the vector added to the patch face centres to"
550  << " find the patch face supplying the data." << endl
551  << "Setting it to " << d
552  << " on the same patch, on the same region"
553  << " will find the faces themselves which does not make sense"
554  << " for anything but testing." << endl
555  << "patch_:" << patch_.name() << endl
556  << "sampleRegion_:" << sampleRegion() << endl
557  << "mode_:" << sampleModeNames_[mode_] << endl
558  << "samplePatch_:" << samplePatch() << endl
559  << "offsetMode_:" << offsetModeNames_[offsetMode_] << endl;
560  }
561 
562  // Get global list of all samples and the processor and face they come from.
564  labelList patchFaceProcs;
565  labelList patchFaces;
566  pointField patchFc;
568  (
569  patchPoints,
570  samples,
571  patchFaceProcs,
572  patchFaces,
573  patchFc
574  );
575 
576  // Find processor and cell/face samples are in and actual location.
577  labelList sampleProcs;
578  labelList sampleIndices;
579  pointField sampleLocations;
580  findSamples(mode_, samples, sampleProcs, sampleIndices, sampleLocations);
581 
582  // Check for samples that were not found. This will only happen for
583  // NEARESTCELL since finds cell containing a location
584  if (mode_ == NEARESTCELL)
585  {
586  label nNotFound = 0;
587  forAll(sampleProcs, sampleI)
588  {
589  if (sampleProcs[sampleI] == -1)
590  {
591  nNotFound++;
592  }
593  }
594  reduce(nNotFound, sumOp<label>());
595 
596  if (nNotFound > 0)
597  {
598  if (!hasWarned)
599  {
601  << "Did not find " << nNotFound
602  << " out of " << sampleProcs.size() << " total samples."
603  << " Sampling these on owner cell centre instead." << endl
604  << "On patch " << patch_.name()
605  << " on region " << sampleRegion()
606  << " in mode " << sampleModeNames_[mode_] << endl
607  << "with offset mode " << offsetModeNames_[offsetMode_]
608  << ". Suppressing further warnings from " << type() << endl;
609 
610  hasWarned = true;
611  }
612 
613  // Collect the samples that cannot be found
614  DynamicList<label> subMap;
615  DynamicField<point> subSamples;
616 
617  forAll(sampleProcs, sampleI)
618  {
619  if (sampleProcs[sampleI] == -1)
620  {
621  subMap.append(sampleI);
622  subSamples.append(samples[sampleI]);
623  }
624  }
625 
626  // And re-search for pure nearest (should not fail)
627  labelList subSampleProcs;
628  labelList subSampleIndices;
629  pointField subSampleLocations;
631  (
633  subSamples,
634  subSampleProcs,
635  subSampleIndices,
636  subSampleLocations
637  );
638 
639  // Insert
640  labelUIndList(sampleProcs, subMap) = subSampleProcs;
641  labelUIndList(sampleIndices, subMap) = subSampleIndices;
642  UIndirectList<point>(sampleLocations, subMap) = subSampleLocations;
643  }
644  }
645 
646  // Now we have all the data we need:
647  // - where sample originates from (so destination when mapping):
648  // patchFaces, patchFaceProcs.
649  // - cell/face sample is in (so source when mapping)
650  // sampleIndices, sampleProcs.
651 
652  //forAll(samples, i)
653  //{
654  // Info<< i << " need data in region "
655  // << patch_.boundaryMesh().mesh().name()
656  // << " for proc:" << patchFaceProcs[i]
657  // << " face:" << patchFaces[i]
658  // << " at:" << patchFc[i] << endl
659  // << "Found data in region " << sampleRegion()
660  // << " at proc:" << sampleProcs[i]
661  // << " face:" << sampleIndices[i]
662  // << " at:" << sampleLocations[i]
663  // << nl << endl;
664  //}
665 
666 
667 
668  if (debug && Pstream::master())
669  {
670  OFstream str
671  (
673  / patch_.name()
674  + "_mapped.obj"
675  );
676  Pout<< "Dumping mapping as lines from patch faceCentres to"
677  << " sampled cell/faceCentres/points to file " << str.name()
678  << endl;
679 
680  label vertI = 0;
681 
682  forAll(patchFc, i)
683  {
684  meshTools::writeOBJ(str, patchFc[i]);
685  vertI++;
686  meshTools::writeOBJ(str, sampleLocations[i]);
687  vertI++;
688  str << "l " << vertI-1 << ' ' << vertI << nl;
689  }
690  }
691 
692  // Determine schedule.
693  mapPtr_.reset(new mapDistribute(sampleProcs, patchFaceProcs));
694 
695  // Rework the schedule from indices into samples to cell data to send,
696  // face data to receive.
697 
698  labelListList& subMap = mapPtr_().subMap();
699  labelListList& constructMap = mapPtr_().constructMap();
700 
701  forAll(subMap, proci)
702  {
703  subMap[proci] = labelUIndList(sampleIndices, subMap[proci]);
704  constructMap[proci] = labelUIndList(patchFaces, constructMap[proci]);
705 
706  //if (debug)
707  //{
708  // Pout<< "To proc:" << proci << " sending values of cells/faces:"
709  // << subMap[proci] << endl;
710  // Pout<< "From proc:" << proci
711  // << " receiving values of patch faces:"
712  // << constructMap[proci] << endl;
713  //}
714  }
715 
716  // Redo constructSize
717  mapPtr_().constructSize() = patch_.size();
718 
719  if (debug)
720  {
721  // Check that all elements get a value.
722  bitSet used(patch_.size());
723  forAll(constructMap, proci)
724  {
725  const labelList& map = constructMap[proci];
726 
727  forAll(map, i)
728  {
729  label facei = map[i];
730 
731  if (used.test(facei))
732  {
734  << "On patch " << patch_.name()
735  << " patchface " << facei
736  << " is assigned to more than once."
737  << abort(FatalError);
738  }
739  else
740  {
741  used.set(facei);
742  }
743  }
744  }
745  forAll(used, facei)
746  {
747  if (!used.test(facei))
748  {
750  << "On patch " << patch_.name()
751  << " patchface " << facei
752  << " is never assigned to."
753  << abort(FatalError);
754  }
755  }
756  }
757 }
758 
759 
761 const
762 {
763  const word surfType(surfDict_.lookupOrDefault<word>("type", "none"));
764 
765  if (!surfPtr_.valid() && surfType != "none")
766  {
767  word surfName(surfDict_.lookupOrDefault("name", patch_.name()));
768 
769  const polyMesh& mesh = patch_.boundaryMesh().mesh();
770 
771  surfPtr_ =
773  (
774  surfType,
775  IOobject
776  (
777  surfName,
778  mesh.time().constant(),
779  "triSurface",
780  mesh,
783  ),
784  surfDict_
785  );
786  }
787 
788  return surfPtr_;
789 }
790 
791 
793 {
794  if (AMIPtr_.valid())
795  {
797  << "AMI already calculated" << exit(FatalError);
798  }
799 
800  AMIPtr_.clear();
801 
802 
803  const polyPatch& nbr = samplePolyPatch();
804 
805  // Transform neighbour patch to local system
806  pointField nbrPoints(samplePoints(nbr.localPoints()));
807 
808  primitivePatch nbrPatch0
809  (
811  (
812  nbr.localFaces(),
813  nbr.size()
814  ),
815  nbrPoints
816  );
817 
818 
819  if (debug)
820  {
821  OFstream os(patch_.name() + "_neighbourPatch-org.obj");
822  meshTools::writeOBJ(os, samplePolyPatch().localFaces(), nbrPoints);
823 
824  OFstream osN(patch_.name() + "_neighbourPatch-trans.obj");
825  meshTools::writeOBJ(osN, nbrPatch0, nbrPoints);
826 
827  OFstream osO(patch_.name() + "_ownerPatch.obj");
828  meshTools::writeOBJ(osO, patch_.localFaces(), patch_.localPoints());
829  }
830 
831  // Construct/apply AMI interpolation to determine addressing and weights
832  AMIPtr_.reset
833  (
835  (
836  patch_,
837  nbrPatch0,
838  surfPtr(),
840  true,
842  -1,
843  AMIReverse_
844  )
845  );
846 }
847 
848 
849 // Hack to read old (List-based) format. See Field.C. The difference
850 // is only that in case of falling back to old format it expects a non-uniform
851 // list instead of a single vector.
853 (
854  const word& keyword,
855  const dictionary& dict,
856  const label size
857 )
858 {
859  tmp<pointField> tfld(new pointField());
860  pointField& fld = tfld.ref();
861 
862  if (size)
863  {
864  ITstream& is = dict.lookup(keyword);
865 
866  // Read first token
867  token firstToken(is);
868 
869  if (firstToken.isWord())
870  {
871  if (firstToken.wordToken() == "uniform")
872  {
873  fld.setSize(size);
874  fld = pTraits<vector>(is);
875  }
876  else if (firstToken.wordToken() == "nonuniform")
877  {
878  is >> static_cast<List<vector>&>(fld);
879  if (fld.size() != size)
880  {
882  << "size " << fld.size()
883  << " is not equal to the given value of " << size
884  << exit(FatalIOError);
885  }
886  }
887  else
888  {
890  << "Expected keyword 'uniform' or 'nonuniform', found "
891  << firstToken.wordToken()
892  << exit(FatalIOError);
893  }
894  }
895  else if (is.version() == IOstream::versionNumber(2,0))
896  {
898  << "Expected keyword 'uniform' or 'nonuniform', "
899  "assuming List format for backwards compatibility."
900  "Foam version 2.0." << endl;
901 
902  is.putBack(firstToken);
903  is >> static_cast<List<vector>&>(fld);
904  }
905  }
906  return tfld;
907 }
908 
909 
910 // * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * * * //
911 
913 (
914  const polyPatch& pp
915 )
916 :
917  patch_(pp),
918  sampleRegion_(patch_.boundaryMesh().mesh().name()),
919  mode_(NEARESTPATCHFACE),
920  samplePatch_(""),
921  coupleGroup_(),
922  offsetMode_(UNIFORM),
923  offset_(Zero),
924  offsets_(pp.size(), offset_),
925  distance_(0),
926  sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
927  mapPtr_(nullptr),
928  AMIPtr_(nullptr),
929  AMIReverse_(false),
930  surfPtr_(nullptr),
931  surfDict_(fileName("surface"))
932 {}
933 
934 
936 (
937  const polyPatch& pp,
938  const word& sampleRegion,
939  const sampleMode mode,
940  const word& samplePatch,
941  const vectorField& offsets
942 )
943 :
944  patch_(pp),
945  sampleRegion_(sampleRegion),
946  mode_(mode),
947  samplePatch_(samplePatch),
948  coupleGroup_(),
949  offsetMode_(NONUNIFORM),
950  offset_(Zero),
951  offsets_(offsets),
952  distance_(0),
953  sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
954  mapPtr_(nullptr),
955  AMIPtr_(nullptr),
956  AMIReverse_(false),
957  surfPtr_(nullptr),
958  surfDict_(fileName("surface"))
959 {}
960 
961 
963 (
964  const polyPatch& pp,
965  const word& sampleRegion,
966  const sampleMode mode,
967  const word& samplePatch,
968  const vector& offset
969 )
970 :
971  patch_(pp),
972  sampleRegion_(sampleRegion),
973  mode_(mode),
974  samplePatch_(samplePatch),
975  coupleGroup_(),
976  offsetMode_(UNIFORM),
977  offset_(offset),
978  offsets_(0),
979  distance_(0),
980  sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
981  mapPtr_(nullptr),
982  AMIPtr_(nullptr),
983  AMIReverse_(false),
984  surfPtr_(nullptr),
985  surfDict_(fileName("surface"))
986 {}
987 
988 
990 (
991  const polyPatch& pp,
992  const word& sampleRegion,
993  const sampleMode mode,
994  const word& samplePatch,
995  const scalar distance
996 )
997 :
998  patch_(pp),
999  sampleRegion_(sampleRegion),
1000  mode_(mode),
1001  samplePatch_(samplePatch),
1002  coupleGroup_(),
1003  offsetMode_(NORMAL),
1004  offset_(Zero),
1005  offsets_(0),
1006  distance_(distance),
1007  sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1008  mapPtr_(nullptr),
1009  AMIPtr_(nullptr),
1010  AMIReverse_(false),
1011  surfPtr_(nullptr),
1012  surfDict_(fileName("surface"))
1013 {}
1014 
1015 
1018  const polyPatch& pp,
1019  const dictionary& dict
1020 )
1021 :
1022  patch_(pp),
1023  sampleRegion_(dict.lookupOrDefault<word>("sampleRegion", "")),
1024  mode_(sampleModeNames_.get("sampleMode", dict)),
1025  samplePatch_(dict.lookupOrDefault<word>("samplePatch", "")),
1026  coupleGroup_(dict),
1027  offsetMode_(UNIFORM),
1028  offset_(Zero),
1029  offsets_(0),
1030  distance_(0.0),
1031  sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1032  mapPtr_(nullptr),
1033  AMIPtr_(nullptr),
1034  AMIReverse_(dict.lookupOrDefault("flipNormals", false)),
1035  surfPtr_(nullptr),
1036  surfDict_(dict.subOrEmptyDict("surface"))
1037 {
1038  if (!coupleGroup_.valid())
1039  {
1040  if (sampleRegion_.empty())
1041  {
1042  // If no coupleGroup and no sampleRegion assume local region
1043  sampleRegion_ = patch_.boundaryMesh().mesh().name();
1044  sameRegion_ = true;
1045  }
1046  }
1047 
1048  if (offsetModeNames_.readIfPresent("offsetMode", dict, offsetMode_))
1049  {
1050  switch (offsetMode_)
1051  {
1052  case UNIFORM:
1053  {
1054  dict.readEntry("offset", offset_);
1055  }
1056  break;
1057 
1058  case NONUNIFORM:
1059  {
1060  //offsets_ = pointField(dict.lookup("offsets"));
1061  offsets_ = readListOrField("offsets", dict, patch_.size());
1062  }
1063  break;
1064 
1065  case NORMAL:
1066  {
1067  dict.readEntry("distance", distance_);
1068  }
1069  break;
1070  }
1071  }
1072  else if (dict.readIfPresent("offset", offset_))
1073  {
1074  offsetMode_ = UNIFORM;
1075  }
1076  else if (dict.found("offsets"))
1077  {
1078  offsetMode_ = NONUNIFORM;
1079  //offsets_ = pointField(dict.lookup("offsets"));
1080  offsets_ = readListOrField("offsets", dict, patch_.size());
1081  }
1082  else if (mode_ != NEARESTPATCHFACE && mode_ != NEARESTPATCHFACEAMI)
1083  {
1085  << "Please supply the offsetMode as one of "
1086  << offsetModeNames_
1087  << exit(FatalIOError);
1088  }
1089 }
1090 
1091 
1094  const polyPatch& pp,
1095  const sampleMode mode,
1096  const dictionary& dict
1097 )
1098 :
1099  patch_(pp),
1100  sampleRegion_(dict.lookupOrDefault<word>("sampleRegion", "")),
1101  mode_(mode),
1102  samplePatch_(dict.lookupOrDefault<word>("samplePatch", "")),
1103  coupleGroup_(dict), //dict.lookupOrDefault<word>("coupleGroup", "")),
1104  offsetMode_(UNIFORM),
1105  offset_(Zero),
1106  offsets_(0),
1107  distance_(0.0),
1108  sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
1109  mapPtr_(nullptr),
1110  AMIPtr_(nullptr),
1111  AMIReverse_(dict.lookupOrDefault("flipNormals", false)),
1112  surfPtr_(nullptr),
1113  surfDict_(dict.subOrEmptyDict("surface"))
1114 {
1115  if (mode != NEARESTPATCHFACE && mode != NEARESTPATCHFACEAMI)
1116  {
1118  << "Construct from sampleMode and dictionary only applicable for "
1119  << " collocated patches in modes "
1120  << sampleModeNames_[NEARESTPATCHFACE] << ','
1121  << sampleModeNames_[NEARESTPATCHFACEAMI]
1122  << exit(FatalIOError);
1123  }
1124 
1125 
1126  if (!coupleGroup_.valid())
1127  {
1128  if (sampleRegion_.empty())
1129  {
1130  // If no coupleGroup and no sampleRegion assume local region
1131  sampleRegion_ = patch_.boundaryMesh().mesh().name();
1132  sameRegion_ = true;
1133  }
1134  }
1135 }
1136 
1137 
1140  const polyPatch& pp,
1141  const mappedPatchBase& mpb
1142 )
1143 :
1144  patch_(pp),
1145  sampleRegion_(mpb.sampleRegion_),
1146  mode_(mpb.mode_),
1147  samplePatch_(mpb.samplePatch_),
1148  coupleGroup_(mpb.coupleGroup_),
1149  offsetMode_(mpb.offsetMode_),
1150  offset_(mpb.offset_),
1151  offsets_(mpb.offsets_),
1152  distance_(mpb.distance_),
1153  sameRegion_(mpb.sameRegion_),
1154  mapPtr_(nullptr),
1155  AMIPtr_(nullptr),
1156  AMIReverse_(mpb.AMIReverse_),
1157  surfPtr_(nullptr),
1158  surfDict_(mpb.surfDict_)
1159 {}
1160 
1161 
1164  const polyPatch& pp,
1165  const mappedPatchBase& mpb,
1166  const labelUList& mapAddressing
1167 )
1168 :
1169  patch_(pp),
1170  sampleRegion_(mpb.sampleRegion_),
1171  mode_(mpb.mode_),
1172  samplePatch_(mpb.samplePatch_),
1173  coupleGroup_(mpb.coupleGroup_),
1174  offsetMode_(mpb.offsetMode_),
1175  offset_(mpb.offset_),
1176  offsets_
1177  (
1178  offsetMode_ == NONUNIFORM
1179  ? vectorField(mpb.offsets_, mapAddressing)
1180  : vectorField(0)
1181  ),
1182  distance_(mpb.distance_),
1183  sameRegion_(mpb.sameRegion_),
1184  mapPtr_(nullptr),
1185  AMIPtr_(nullptr),
1186  AMIReverse_(mpb.AMIReverse_),
1187  surfPtr_(nullptr),
1188  surfDict_(mpb.surfDict_)
1189 {}
1190 
1191 
1192 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
1193 
1195 {
1196  clearOut();
1197 }
1198 
1199 
1201 {
1202  mapPtr_.clear();
1203  AMIPtr_.clear();
1204  surfPtr_.clear();
1205 }
1206 
1207 
1208 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
1209 
1211 {
1212  const polyMesh& thisMesh = patch_.boundaryMesh().mesh();
1213 
1214  return
1215  (
1216  sameRegion_
1217  ? thisMesh
1218  : thisMesh.time().lookupObject<polyMesh>(sampleRegion())
1219  );
1220 }
1221 
1222 
1224 {
1225  const polyMesh& nbrMesh = sampleMesh();
1226 
1227  const label patchi = nbrMesh.boundaryMesh().findPatchID(samplePatch());
1228 
1229  if (patchi == -1)
1230  {
1232  << "Cannot find patch " << samplePatch()
1233  << " in region " << sampleRegion_ << endl
1234  << "Valid patches are " << nbrMesh.boundaryMesh().names()
1235  << exit(FatalError);
1236  }
1237 
1238  return nbrMesh.boundaryMesh()[patchi];
1239 }
1240 
1241 
1244  const pointField& fc
1245 ) const
1246 {
1247  tmp<pointField> tfld(new pointField(fc));
1248  pointField& fld = tfld.ref();
1249 
1250  switch (offsetMode_)
1251  {
1252  case UNIFORM:
1253  {
1254  fld += offset_;
1255  break;
1256  }
1257  case NONUNIFORM:
1258  {
1259  fld += offsets_;
1260  break;
1261  }
1262  case NORMAL:
1263  {
1264  // Get outwards pointing normal
1265  vectorField n(patch_.faceAreas());
1266  n /= mag(n);
1267 
1268  fld += distance_*n;
1269  break;
1270  }
1271  }
1272 
1273  return tfld;
1274 }
1275 
1276 
1278 {
1279  return samplePoints(facePoints(patch_));
1280 }
1281 
1282 
1285  const polyMesh& mesh,
1286  const label facei,
1287  const polyMesh::cellDecomposition decompMode
1288 )
1289 {
1290  const point& fc = mesh.faceCentres()[facei];
1291 
1292  switch (decompMode)
1293  {
1294  case polyMesh::FACE_PLANES:
1296  {
1297  // For both decompositions the face centre is guaranteed to be
1298  // on the face
1299  return pointIndexHit(true, fc, facei);
1300  }
1301  break;
1302 
1304  case polyMesh::CELL_TETS:
1305  {
1306  // Find the intersection of a ray from face centre to cell centre
1307  // Find intersection of (face-centre-decomposition) centre to
1308  // cell-centre with face-diagonal-decomposition triangles.
1309 
1310  const pointField& p = mesh.points();
1311  const face& f = mesh.faces()[facei];
1312 
1313  if (f.size() <= 3)
1314  {
1315  // Return centre of triangle.
1316  return pointIndexHit(true, fc, 0);
1317  }
1318 
1319  label celli = mesh.faceOwner()[facei];
1320  const point& cc = mesh.cellCentres()[celli];
1321  vector d = fc-cc;
1322 
1323  const label fp0 = mesh.tetBasePtIs()[facei];
1324  const point& basePoint = p[f[fp0]];
1325 
1326  label fp = f.fcIndex(fp0);
1327  for (label i = 2; i < f.size(); i++)
1328  {
1329  const point& thisPoint = p[f[fp]];
1330  label nextFp = f.fcIndex(fp);
1331  const point& nextPoint = p[f[nextFp]];
1332 
1333  const triPointRef tri(basePoint, thisPoint, nextPoint);
1334  pointHit hitInfo = tri.intersection
1335  (
1336  cc,
1337  d,
1339  );
1340 
1341  if (hitInfo.hit() && hitInfo.distance() > 0)
1342  {
1343  return pointIndexHit(true, hitInfo.hitPoint(), i-2);
1344  }
1345 
1346  fp = nextFp;
1347  }
1348 
1349  // Fall-back
1350  return pointIndexHit(false, fc, -1);
1351  }
1352  break;
1353 
1354  default:
1355  {
1357  << "problem" << abort(FatalError);
1358  return pointIndexHit();
1359  }
1360  }
1361 }
1362 
1363 
1365 {
1366  os.writeEntry("sampleMode", sampleModeNames_[mode_]);
1367  if (!sampleRegion_.empty())
1368  {
1369  os.writeEntry("sampleRegion", sampleRegion_);
1370  }
1371  if (!samplePatch_.empty())
1372  {
1373  os.writeEntry("samplePatch", samplePatch_);
1374  }
1375  coupleGroup_.write(os);
1376 
1377  if
1378  (
1379  offsetMode_ == UNIFORM
1380  && offset_ == vector::zero
1381  && (mode_ == NEARESTPATCHFACE || mode_ == NEARESTPATCHFACEAMI)
1382  )
1383  {
1384  // Collocated mode. No need to write offset data
1385  }
1386  else
1387  {
1388  os.writeEntry("offsetMode", offsetModeNames_[offsetMode_]);
1389 
1390  switch (offsetMode_)
1391  {
1392  case UNIFORM:
1393  {
1394  os.writeEntry("offset", offset_);
1395  break;
1396  }
1397  case NONUNIFORM:
1398  {
1399  offsets_.writeEntry("offsets", os);
1400  break;
1401  }
1402  case NORMAL:
1403  {
1404  os.writeEntry("distance", distance_);
1405  break;
1406  }
1407  }
1408 
1409  if (mode_ == NEARESTPATCHFACEAMI)
1410  {
1411  if (AMIReverse_)
1412  {
1413  os.writeEntry("flipNormals", AMIReverse_);
1414  }
1415 
1416  if (!surfDict_.empty())
1417  {
1418  surfDict_.writeEntry(surfDict_.dictName(), os);
1419  }
1420  }
1421  }
1422 }
1423 
1424 
1425 // ************************************************************************* //
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:1364
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:316
Foam::mappedPatchBase::clearOut
void clearOut()
Definition: mappedPatchBase.C:1200
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:51
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:607
Foam::mappedPatchBase::AMIReverse_
const bool AMIReverse_
Flag to indicate that slave patch should be reversed for AMI.
Definition: mappedPatchBase.H:237
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobjectI.H:46
Foam::PrimitivePatch::points
const Field< PointType > & points() const
Return reference to global points.
Definition: PrimitivePatch.H:300
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.
Definition: zero.H:128
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:359
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::PrimitivePatch::localPoints
const Field< PointType > & localPoints() const
Return pointField of points in patch.
Definition: PrimitivePatch.C:458
Foam::AMIInterpolation::imFaceAreaWeight
Definition: AMIInterpolation.H:94
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:1223
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:913
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:115
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::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:337
Foam::token
A token holds an item read from Istream.
Definition: token.H:69
Foam::mappedPatchBase::readListOrField
static tmp< pointField > readListOrField(const word &keyword, const dictionary &dict, const label size)
Helper to read field or non-uniform list from dictionary.
Definition: mappedPatchBase.C:853
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.H:1241
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::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:1194
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:290
Foam::mappedPatchBase::surfPtr
const autoPtr< Foam::searchableSurface > & surfPtr() const
Return a pointer to the AMI projection surface.
Definition: mappedPatchBase.C:760
OFstream.H
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: blockMeshMergeFast.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:1277
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:1210
Foam::meshSearch::findNearestFace
label findNearestFace(const point &location, const label seedFacei=-1, const bool useTreeSearch=true) const
Definition: meshSearch.C:728
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::label
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:62
Foam::IOstreamOption::versionNumber
Representation of a major/minor version number.
Definition: IOstreamOption.H:79
Foam::Field< vector >
treeDataPoint.H
Foam::polyPatch::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:305
Foam::ITstream
An input stream of tokens.
Definition: ITstream.H:55
Foam::polyMesh::FACE_CENTRE_TRIS
Definition: polyMesh.H:105
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::OSstream::name
virtual const fileName & name() const
Return the name of the stream.
Definition: OSstream.H:91
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
Foam::IOstreamOption::version
versionNumber version() const noexcept
Get the stream version.
Definition: IOstreamOption.H:321
Foam::dictionary::lookup
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.C:419
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::token::isWord
bool isWord() const
Token is WORD.
Definition: tokenI.H:552
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::mappedPatchBase::calcAMI
void calcAMI() const
Calculate AMI interpolator.
Definition: mappedPatchBase.C:792
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:311
Foam::mappedPatchBase::sampleRegion
const word & sampleRegion() const
Region to sample.
Definition: mappedPatchBaseI.H:35
Foam::token::wordToken
const word & wordToken() const
Return const reference to the word contents.
Definition: tokenI.H:558
Foam::dictionary::subOrEmptyDict
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
Definition: dictionary.C:603
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::OFstream
Output to file stream, using an OSstream.
Definition: OFstream.H:99
Foam::UPstream::master
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:438
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:516
Time.H
Foam::autoPtr< Foam::searchableSurface >
Foam::primitiveMesh::cellCentres
const vectorField & cellCentres() const
Definition: primitiveMeshCellCentresAndVols.C:176
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:355
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:372
Foam::Time::path
fileName path() const
Return path.
Definition: Time.H:303
mapDistribute.H
f
labelList f(nPoints)
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::pTraits
Traits class for primitives.
Definition: pTraits.H:52
Foam::treeDataFace
Encapsulation of data needed to search for faces.
Definition: treeDataFace.H:59
Foam::Istream::putBack
void putBack(const token &tok)
Put back token.
Definition: Istream.C:53
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::primitiveMesh::faceCentres
const vectorField & faceCentres() const
Definition: primitiveMeshFaceCentresAndAreas.C:145
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::AMIInterpolation
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
Definition: AMIInterpolation.H:81
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:219
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:246
Foam::VectorSpace< Vector< scalar >, scalar, 3 >::zero
static const Vector< scalar > zero
Definition: VectorSpace.H:115
Foam::PrimitivePatch::localFaces
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
Definition: PrimitivePatch.C:398
Foam::UIndirectList
A List with indirect addressing.
Definition: fvMatrix.H:109
Foam::HashSet::test
bool test(const Key &key) const
Same as found() - return true if key exists in the set.
Definition: HashSet.H:171
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:187
Foam::mappedPatchBase::facePoints
tmp< pointField > facePoints(const polyPatch &) const
Get the points from face-centre-decomposition face centres.
Definition: mappedPatchBase.C:87
Foam::polyMesh::FACE_PLANES
Definition: polyMesh.H:103
Foam::mappedPatchBase::surfDict_
dictionary surfDict_
Dictionary storing projection surface description.
Definition: mappedPatchBase.H:243
Foam::face
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:74
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:375
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
IOWarningInFunction
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
Definition: messageStream.H:306
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::point
vector point
Point is a vector.
Definition: point.H:43
Foam::PrimitivePatch::meshPoints
const labelList & meshPoints() const
Return labelList of mesh points in patch.
Definition: PrimitivePatch.C:418
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::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:1284
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::patchIdentifier::name
const word & name() const
Return the patch name.
Definition: patchIdentifier.H:109
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:294
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:188
Foam::faceAreaIntersect::tmMesh
Definition: faceAreaIntersect.H:65
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:90
Foam::IOobject::MUST_READ
Definition: IOobject.H:120
Foam::labelUIndList
UIndirectList< label > labelUIndList
UIndirectList of labels.
Definition: UIndirectList.H:59
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