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