triSurfaceMesh.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 "triSurfaceMesh.H"
27 #include "Random.H"
29 #include "EdgeMap.H"
30 #include "triSurfaceFields.H"
31 #include "Time.H"
32 #include "PatchTools.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 defineTypeNameAndDebug(triSurfaceMesh, 0);
40 addToRunTimeSelectionTable(searchableSurface, triSurfaceMesh, dict);
41 
42 word triSurfaceMesh::meshSubDir = "triSurface";
43 
44 }
45 
46 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 
50 //Foam::word Foam::triSurfaceMesh::findRawInstance
51 //(
52 // const Time& runTime,
53 // const fileName& dir,
54 // const word& name
55 //)
56 //{
57 // // Check current time first
58 // if (isFile(runTime.path()/runTime.timeName()/dir/name))
59 // {
60 // return runTime.timeName();
61 // }
62 // instantList ts = runTime.times();
63 // label instanceI;
64 //
65 // for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
66 // {
67 // if (ts[instanceI].value() <= runTime.timeOutputValue())
68 // {
69 // break;
70 // }
71 // }
72 //
73 // // continue searching from here
74 // for (; instanceI >= 0; --instanceI)
75 // {
76 // if (isFile(runTime.path()/ts[instanceI].name()/dir/name))
77 // {
78 // return ts[instanceI].name();
79 // }
80 // }
81 //
82 //
83 // // not in any of the time directories, try constant
84 //
85 // // Note. This needs to be a hard-coded constant, rather than the
86 // // constant function of the time, because the latter points to
87 // // the case constant directory in parallel cases
88 //
89 // if (isFile(runTime.path()/runTime.constant()/dir/name))
90 // {
91 // return runTime.constant();
92 // }
93 //
94 // FatalErrorInFunction
95 // << "Cannot find file \"" << name << "\" in directory "
96 // << runTime.constant()/dir
97 // << exit(FatalError);
98 //
99 // return runTime.constant();
100 //}
101 
102 
103 //- Check file existence
105 (
106  const fileName& fName,
107  const fileName& objectName
108 )
109 {
110  if (fName.empty())
111  {
113  << "Cannot find triSurfaceMesh starting from "
114  << objectName << exit(FatalError);
115  }
116  return fName;
117 }
118 
119 
121 (
122  const edge& e,
123  EdgeMap<label>& facesPerEdge
124 )
125 {
126  EdgeMap<label>::iterator eFnd = facesPerEdge.find(e);
127  if (eFnd != facesPerEdge.end())
128  {
129  if (eFnd() == 2)
130  {
131  return false;
132  }
133  eFnd()++;
134  }
135  else
136  {
137  facesPerEdge.insert(e, 1);
138  }
139  return true;
140 }
141 
142 
144 {
145  const pointField& pts = triSurface::points();
146 
147  // Construct pointFaces. Let's hope surface has compact point
148  // numbering ...
150  invertManyToMany(pts.size(), *this, pointFaces);
151 
152  // Loop over all faces surrounding point. Count edges emanating from point.
153  // Every edge should be used by two faces exactly.
154  // To prevent doing work twice per edge only look at edges to higher
155  // point
156  EdgeMap<label> facesPerEdge(100);
157  forAll(pointFaces, pointI)
158  {
159  const labelList& pFaces = pointFaces[pointI];
160 
161  facesPerEdge.clear();
162  forAll(pFaces, i)
163  {
164  const triSurface::FaceType& f = triSurface::operator[](pFaces[i]);
165  label fp = findIndex(f, pointI);
166 
167  // Something weird: if I expand the code of addFaceToEdge in both
168  // below instances it gives a segmentation violation on some
169  // surfaces. Compiler (4.3.2) problem?
170 
171 
172  // Forward edge
173  label nextPointI = f[f.fcIndex(fp)];
174 
175  if (nextPointI > pointI)
176  {
177  bool okFace = addFaceToEdge
178  (
179  edge(pointI, nextPointI),
180  facesPerEdge
181  );
182 
183  if (!okFace)
184  {
185  return false;
186  }
187  }
188  // Reverse edge
189  label prevPointI = f[f.rcIndex(fp)];
190 
191  if (prevPointI > pointI)
192  {
193  bool okFace = addFaceToEdge
194  (
195  edge(pointI, prevPointI),
196  facesPerEdge
197  );
198 
199  if (!okFace)
200  {
201  return false;
202  }
203  }
204  }
205 
206  // Check for any edges used only once.
207  forAllConstIter(EdgeMap<label>, facesPerEdge, iter)
208  {
209  if (iter() != 2)
210  {
211  return false;
212  }
213  }
214  }
215 
216  return true;
217 }
218 
219 
220 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
221 
223 :
224  searchableSurface(io),
226  (
227  IOobject
228  (
229  io.name(),
230  io.instance(),
231  io.local(), //"triSurfaceFields",
232  io.db(),
233  io.readOpt(),
234  io.writeOpt(),
235  false // searchableSurface already registered under name
236  )
237  ),
238  triSurface(s),
239  triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
240  minQuality_(-1),
241  surfaceClosed_(-1),
242  outsideVolType_(volumeType::UNKNOWN)
243 {
244  const pointField& pts = triSurface::points();
245 
246  bounds() = boundBox(pts, false);
247 }
248 
249 
251 :
252  // Find instance for triSurfaceMesh
253  searchableSurface(io),
254  //(
255  // IOobject
256  // (
257  // io.name(),
258  // io.time().findInstance(io.local(), word::null),
259  // io.local(),
260  // io.db(),
261  // io.readOpt(),
262  // io.writeOpt(),
263  // io.registerObject()
264  // )
265  //),
266  // Reused found instance in objectRegistry
268  (
269  IOobject
270  (
271  io.name(),
272  static_cast<const searchableSurface&>(*this).instance(),
273  io.local(), //"triSurfaceFields",
274  io.db(),
275  io.readOpt(),
276  io.writeOpt(),
277  false // searchableSurface already registered under name
278  )
279  ),
280  triSurface
281  (
282  checkFile
283  (
284  searchableSurface::filePath(),
285  searchableSurface::objectPath()
286  )
287  ),
288  triSurfaceRegionSearch(static_cast<const triSurface&>(*this)),
289  minQuality_(-1),
290  surfaceClosed_(-1),
291  outsideVolType_(volumeType::UNKNOWN)
292 {
293  const pointField& pts = triSurface::points();
294 
295  bounds() = boundBox(pts, false);
296 }
297 
298 
300 (
301  const IOobject& io,
302  const dictionary& dict
303 )
304 :
305  searchableSurface(io),
306  //(
307  // IOobject
308  // (
309  // io.name(),
310  // io.time().findInstance(io.local(), word::null),
311  // io.local(),
312  // io.db(),
313  // io.readOpt(),
314  // io.writeOpt(),
315  // io.registerObject()
316  // )
317  //),
318  // Reused found instance in objectRegistry
320  (
321  IOobject
322  (
323  io.name(),
324  static_cast<const searchableSurface&>(*this).instance(),
325  io.local(), //"triSurfaceFields",
326  io.db(),
327  io.readOpt(),
328  io.writeOpt(),
329  false // searchableSurface already registered under name
330  )
331  ),
332  triSurface
333  (
334  checkFile
335  (
338  )
339  ),
340  triSurfaceRegionSearch(static_cast<const triSurface&>(*this), dict),
341  minQuality_(-1),
342  surfaceClosed_(-1),
343  outsideVolType_(volumeType::UNKNOWN)
344 {
345  scalar scaleFactor = 0;
346 
347  // allow rescaling of the surface points
348  // eg, CAD geometries are often done in millimeters
349  if (dict.readIfPresent("scale", scaleFactor) && scaleFactor > 0)
350  {
351  Info<< searchableSurface::name() << " : using scale " << scaleFactor
352  << endl;
353  triSurface::scalePoints(scaleFactor);
354  }
355 
356  const pointField& pts = triSurface::points();
357 
358  bounds() = boundBox(pts, false);
359 
360  // Have optional minimum quality for normal calculation
361  if (dict.readIfPresent("minQuality", minQuality_) && minQuality_ > 0)
362  {
364  << " : ignoring triangles with quality < "
365  << minQuality_ << " for normals calculation." << endl;
366  }
367 }
368 
369 
370 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
371 
373 {
374  clearOut();
375 }
376 
377 
379 {
380  outsideVolType_ = volumeType::UNKNOWN;
382  edgeTree_.clear();
384 }
385 
386 
387 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
388 
390 {
391  tmp<pointField> tPts(new pointField(8));
392  pointField& pt = tPts();
393 
394  // Use copy to calculate face centres so they don't get stored
396  (
399  ).faceCentres();
400 
401  return tPts;
402 }
403 
404 
406 (
407  pointField& centres,
408  scalarField& radiusSqr
409 ) const
410 {
411  centres = coordinates();
412  radiusSqr.setSize(size());
413  radiusSqr = 0.0;
414 
415  const pointField& pts = triSurface::points();
416 
417  forAll(*this, faceI)
418  {
419  const labelledTri& f = triSurface::operator[](faceI);
420  const point& fc = centres[faceI];
421  forAll(f, fp)
422  {
423  const point& pt = pts[f[fp]];
424  radiusSqr[faceI] = max(radiusSqr[faceI], Foam::magSqr(fc-pt));
425  }
426  }
427 
428  // Add a bit to make sure all points are tested inside
429  radiusSqr += Foam::sqr(SMALL);
430 }
431 
432 
434 {
435  return triSurface::points();
436 }
437 
438 
440 {
441  const indexedOctree<treeDataTriSurface>& octree = tree();
442 
443  labelList indices = octree.findBox(treeBoundBox(bb));
444 
445  return !indices.empty();
446 }
447 
448 
450 {
451  outsideVolType_ = volumeType::UNKNOWN;
452 
453  // Update local information (instance, event number)
456 
457  label event = getEvent();
458  searchableSurface::eventNo() = event;
460 
461  // Clear additional addressing
463  edgeTree_.clear();
464  triSurface::movePoints(newPoints);
465 
466  bounds() = boundBox(triSurface::points(), false);
467 }
468 
469 
472 {
473  if (edgeTree_.empty())
474  {
475  // Boundary edges
476  labelList bEdges
477  (
478  identity
479  (
480  nEdges()
481  -nInternalEdges()
482  )
483  + nInternalEdges()
484  );
485 
487 
488  if (bEdges.size())
489  {
490  label nPoints;
492  (
493  static_cast<const triSurface&>(*this),
494  bb,
495  nPoints
496  );
497 
498  // Random number generator. Bit dodgy since not exactly random ;-)
499  Random rndGen(65431);
500 
501  // Slightly extended bb. Slightly off-centred just so on symmetric
502  // geometry there are less face/edge aligned items.
503 
504  bb = bb.extend(rndGen, 1e-4);
505  bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
506  bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
507  }
508 
509  scalar oldTol = indexedOctree<treeDataEdge>::perturbTol();
511 
512  edgeTree_.reset
513  (
515  (
517  (
518  false, // cachebb
519  edges(), // edges
520  localPoints(), // points
521  bEdges // selected edges
522  ),
523  bb, // bb
524  maxTreeDepth(), // maxLevel
525  10, // leafsize
526  3.0 // duplicity
527  )
528  );
529 
531  }
532  return edgeTree_();
533 }
534 
535 
537 {
538  if (regions_.empty())
539  {
540  regions_.setSize(patches().size());
541  forAll(regions_, regionI)
542  {
543  regions_[regionI] = patches()[regionI].name();
544  }
545  }
546  return regions_;
547 }
548 
549 
550 // Find out if surface is closed.
552 {
553  if (surfaceClosed_ == -1)
554  {
555  if (isSurfaceClosed())
556  {
557  surfaceClosed_ = 1;
558  }
559  else
560  {
561  surfaceClosed_ = 0;
562  }
563  }
564 
565  return surfaceClosed_ == 1;
566 }
567 
568 
570 (
571  const pointField& samples,
572  const scalarField& nearestDistSqr,
573  List<pointIndexHit>& info
574 ) const
575 {
576  triSurfaceSearch::findNearest(samples, nearestDistSqr, info);
577 }
578 
579 
581 (
582  const pointField& samples,
583  const scalarField& nearestDistSqr,
584  const labelList& regionIndices,
585  List<pointIndexHit>& info
586 ) const
587 {
589  (
590  samples,
591  nearestDistSqr,
592  regionIndices,
593  info
594  );
595 }
596 
597 
599 (
600  const pointField& start,
601  const pointField& end,
602  List<pointIndexHit>& info
603 ) const
604 {
605  triSurfaceSearch::findLine(start, end, info);
606 }
607 
608 
610 (
611  const pointField& start,
612  const pointField& end,
613  List<pointIndexHit>& info
614 ) const
615 {
616  triSurfaceSearch::findLineAny(start, end, info);
617 }
618 
619 
621 (
622  const pointField& start,
623  const pointField& end,
624  List<List<pointIndexHit> >& info
625 ) const
626 {
627  triSurfaceSearch::findLineAll(start, end, info);
628 }
629 
630 
632 (
633  const List<pointIndexHit>& info,
634  labelList& region
635 ) const
636 {
637  region.setSize(info.size());
638  forAll(info, i)
639  {
640  if (info[i].hit())
641  {
642  region[i] = triSurface::operator[](info[i].index()).region();
643  }
644  else
645  {
646  region[i] = -1;
647  }
648  }
649 }
650 
651 
653 (
654  const List<pointIndexHit>& info,
656 ) const
657 {
658  const triSurface& s = static_cast<const triSurface&>(*this);
659  const pointField& pts = s.points();
660 
661  normal.setSize(info.size());
662 
663  if (minQuality_ >= 0)
664  {
665  // Make sure we don't use triangles with low quality since
666  // normal is not reliable.
667 
668  const labelListList& faceFaces = s.faceFaces();
669 
670  forAll(info, i)
671  {
672  if (info[i].hit())
673  {
674  label faceI = info[i].index();
675  normal[i] = s[faceI].normal(pts);
676 
677  scalar qual = s[faceI].tri(pts).quality();
678 
679  if (qual < minQuality_)
680  {
681  // Search neighbouring triangles
682  const labelList& fFaces = faceFaces[faceI];
683 
684  forAll(fFaces, j)
685  {
686  label nbrI = fFaces[j];
687  scalar nbrQual = s[nbrI].tri(pts).quality();
688  if (nbrQual > qual)
689  {
690  qual = nbrQual;
691  normal[i] = s[nbrI].normal(pts);
692  }
693  }
694  }
695 
696  normal[i] /= mag(normal[i]) + VSMALL;
697  }
698  else
699  {
700  // Set to what?
701  normal[i] = vector::zero;
702  }
703  }
704  }
705  else
706  {
707  forAll(info, i)
708  {
709  if (info[i].hit())
710  {
711  label faceI = info[i].index();
712  //- Cached:
713  //normal[i] = faceNormals()[faceI];
714 
715  //- Uncached
716  normal[i] = s[faceI].normal(pts);
717  normal[i] /= mag(normal[i]) + VSMALL;
718  }
719  else
720  {
721  // Set to what?
722  normal[i] = vector::zero;
723  }
724  }
725  }
726 }
727 
728 
730 {
731  if (foundObject<triSurfaceLabelField>("values"))
732  {
734  (
735  lookupObject<triSurfaceLabelField>
736  (
737  "values"
738  )
739  );
740  fld.field() = values;
741  }
742  else
743  {
745  (
747  (
748  IOobject
749  (
750  "values",
751  objectRegistry::time().timeName(), // instance
752  meshSubDir, // local
753  *this,
756  ),
757  *this,
758  dimless,
759  labelField(values)
760  )
761  );
762 
763  // Store field on triMesh
764  fldPtr.ptr()->store();
765  }
766 }
767 
768 
770 (
771  const List<pointIndexHit>& info,
772  labelList& values
773 ) const
774 {
775  if (foundObject<triSurfaceLabelField>("values"))
776  {
777  values.setSize(info.size());
778 
779  const triSurfaceLabelField& fld = lookupObject<triSurfaceLabelField>
780  (
781  "values"
782  );
783 
784  forAll(info, i)
785  {
786  if (info[i].hit())
787  {
788  values[i] = fld[info[i].index()];
789  }
790  }
791  }
792 }
793 
794 
796 (
797  const pointField& points,
798  List<volumeType>& volType
799 ) const
800 {
801  volType.setSize(points.size());
802 
805 
806  forAll(points, pointI)
807  {
808  const point& pt = points[pointI];
809 
810  if (!tree().bb().contains(pt))
811  {
812  if (hasVolumeType())
813  {
814  // Precalculate and cache value for this outside point
815  if (outsideVolType_ == volumeType::UNKNOWN)
816  {
817  outsideVolType_ = tree().shapes().getVolumeType(tree(), pt);
818  }
819  volType[pointI] = outsideVolType_;
820  }
821  else
822  {
823  // Have to calculate directly as outside the octree
824  volType[pointI] = tree().shapes().getVolumeType(tree(), pt);
825  }
826  }
827  else
828  {
829  // - use cached volume type per each tree node
830  volType[pointI] = tree().getVolumeType(pt);
831  }
832  }
833 
835 }
836 
837 
838 //- Write using given format, version and compression
840 (
844 ) const
845 {
846  const Time& runTime = searchableSurface::time();
847  const fileName& instance = searchableSurface::instance();
848 
849  if
850  (
851  instance != runTime.timeName()
852  && instance != runTime.system()
853  && instance != runTime.caseSystem()
854  && instance != runTime.constant()
855  && instance != runTime.caseConstant()
856  )
857  {
858  const_cast<triSurfaceMesh&>(*this).searchableSurface::instance() =
859  runTime.timeName();
860  const_cast<triSurfaceMesh&>(*this).objectRegistry::instance() =
861  runTime.timeName();
862  }
863 
865 
866  if (!mkDir(fullPath.path()))
867  {
868  return false;
869  }
870 
871  triSurface::write(fullPath);
872 
873  if (!isFile(fullPath))
874  {
875  return false;
876  }
877 
878  //return objectRegistry::writeObject(fmt, ver, cmp);
879  return true;
880 }
881 
882 
883 // ************************************************************************* //
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
Foam::Random
Simple random number generator.
Definition: Random.H:49
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::searchableSurface::bounds
const boundBox & bounds() const
Return const reference to boundBox.
Definition: searchableSurface.H:162
Foam::PrimitivePatch< labelledTri, List, pointField, point >::pointFaces
const labelListList & pointFaces() const
Return point-face addressing.
Definition: PrimitivePatchTemplate.C:352
Foam::IOobject::filePath
fileName filePath() const
Return complete path + object name if the file exists.
Definition: IOobject.C:336
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::PrimitivePatch< labelledTri, List, pointField, point >::points
const Field< point > & points() const
Return reference to global points.
Definition: PrimitivePatchTemplate.H:282
Foam::Vector< scalar >::zero
static const Vector zero
Definition: Vector.H:80
Foam::triSurface::clearOut
void clearOut()
Clear all data.
Definition: triSurface.C:757
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::boundBox::max
const point & max() const
Maximum describing the bounding box.
Definition: boundBoxI.H:60
Foam::IOobject::AUTO_WRITE
@ AUTO_WRITE
Definition: IOobject.H:117
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::PatchTools::calcBounds
static void calcBounds(const PrimitivePatch< Face, FaceList, PointField, PointType > &p, boundBox &bb, label &nPoints)
Definition: PatchToolsSearch.C:224
Foam::findIndex
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
Foam::triSurfaceMesh::getNormal
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const
From a set of points and indices get the normal.
Definition: triSurfaceMesh.C:653
Foam::triSurfaceRegionSearch::findNearest
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, const labelList &regionIndices, List< pointIndexHit > &info) const
Find the nearest point on the surface out of the regions.
Definition: triSurfaceRegionSearch.C:186
Foam::triSurfaceMesh::getRegion
virtual void getRegion(const List< pointIndexHit > &, labelList &region) const
From a set of points and indices get the region.
Definition: triSurfaceMesh.C:632
Foam::dictionary::readIfPresent
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Definition: dictionaryTemplates.C:94
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::autoPtr::ptr
T * ptr()
Return object pointer for reuse.
Definition: autoPtrI.H:90
Foam::SubList
A List obtained as a section of another List.
Definition: SubList.H:53
Foam::IOstream::compressionType
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:193
Foam::treeBoundBox
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:75
Foam::triSurfaceMesh::edgeTree
const indexedOctree< treeDataEdge > & edgeTree() const
Demand driven construction of octree for boundary edges.
Definition: triSurfaceMesh.C:471
Foam::objectRegistry::time
const Time & time() const
Return time.
Definition: objectRegistry.H:117
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
Foam::fileName::path
fileName path() const
Return directory path name (part before last /)
Definition: fileName.C:293
Foam::triSurfaceRegionSearch::clearOut
void clearOut()
Clear storage.
Definition: triSurfaceRegionSearch.C:61
Foam::TimePaths::caseSystem
fileName caseSystem() const
Return system name for the case.
Definition: TimePaths.C:110
Foam::HashTable::insert
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
Definition: HashTableI.H:80
Foam::triSurfaceSearch::findNearest
void findNearest(const pointField &samples, const scalarField &nearestDistSqr, List< pointIndexHit > &info) const
Definition: triSurfaceSearch.C:282
triSurfaceFields.H
Fields for triSurface.
Foam::triSurfaceMesh
IOoject and searching on triSurface.
Definition: triSurfaceMesh.H:63
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::invertManyToMany
void invertManyToMany(const label len, const UList< InList > &, List< OutList > &)
Invert many-to-many.
Definition: ListOpsTemplates.C:418
Foam::triSurfaceRegionSearch
Helper class to search on triSurface. Creates an octree for each region of the surface and only searc...
Definition: triSurfaceRegionSearch.H:55
Foam::triSurfaceSearch::findLineAll
void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &info) const
Calculate all intersections from start to end.
Definition: triSurfaceSearch.C:371
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::IOobject::instance
const fileName & instance() const
Definition: IOobject.H:350
Foam::IOobject::writeOpt
writeOption writeOpt() const
Definition: IOobject.H:327
Foam::IOobject::time
const Time & time() const
Return time.
Definition: IOobject.C:245
Foam::triSurfaceMesh::findLineAny
virtual void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Return any intersection on segment from start to end.
Definition: triSurfaceMesh.C:610
Foam::triSurfaceMesh::meshSubDir
static word meshSubDir
Return the mesh sub-directory name (usually "triSurface")
Definition: triSurfaceMesh.H:143
Foam::indexedOctree::perturbTol
static scalar & perturbTol()
Get the perturbation tolerance.
Definition: indexedOctree.C:2550
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
Foam::triSurface::movePoints
virtual void movePoints(const pointField &)
Move points.
Definition: triSurface.C:789
Foam::IOobject::db
const objectRegistry & db() const
Return the local objectRegistry.
Definition: IOobject.C:239
pFaces
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=*(cellModeller::lookup("hex"));labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells]=cellShape(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< SLList< face > > pFaces[nBCs]
Definition: readKivaGrid.H:235
Foam::triSurfaceMesh::movePoints
virtual void movePoints(const pointField &)
Move points.
Definition: triSurfaceMesh.C:449
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::IOobject::objectPath
fileName objectPath() const
Return complete path + object name.
Definition: IOobject.H:376
Foam::IOstream::versionNumber
Version number type.
Definition: IOstream.H:96
samples
scalarField samples(nIntervals, 0)
Foam::indexedOctree::findBox
void findBox(const label nodeI, const treeBoundBox &searchBox, labelHashSet &elements) const
Find all elements intersecting box.
Definition: indexedOctree.C:1994
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::volumeType
Definition: volumeType.H:54
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::labelField
Field< label > labelField
Specialisation of Field<T> for label.
Definition: labelField.H:49
Foam::TimePaths::system
const word & system() const
Return system name.
Definition: TimePaths.H:120
Foam::triSurface
Triangulated surface description with patch information.
Definition: triSurface.H:57
Foam::IOobject::readOpt
readOption readOpt() const
Definition: IOobject.H:317
Foam::treeBoundBox::extend
treeBoundBox extend(Random &, const scalar s) const
Return slightly wider bounding box.
Definition: treeBoundBoxI.H:317
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
Foam::Info
messageStream Info
Foam::searchableSurface
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
Definition: searchableSurface.H:66
Foam::regIOobject::eventNo
label eventNo() const
Event number at last update.
Definition: regIOobjectI.H:80
Foam::triSurfaceMesh::findLine
virtual void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &) const
Find first intersection on segment from start to end.
Definition: triSurfaceMesh.C:599
Foam::indexedOctree
Non-pointer based hierarchical recursive searching.
Definition: treeDataTriSurface.H:47
Foam::treeDataEdge
Holds data for octree to work on an edges subset.
Definition: treeDataEdge.H:53
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobject.H:273
Foam::triSurfaceMesh::getField
virtual void getField(const List< pointIndexHit > &, labelList &) const
WIP. From a set of hits (points and.
Definition: triSurfaceMesh.C:770
Foam::triSurfaceMesh::regions
virtual const wordList & regions() const
Names of regions.
Definition: triSurfaceMesh.C:536
Foam::boundBox::min
const point & min() const
Minimum describing the bounding box.
Definition: boundBoxI.H:54
Foam::triSurfaceMesh::triSurfaceMesh
triSurfaceMesh(const triSurfaceMesh &)
Disallow default bitwise copy construct.
coordinates
PtrList< coordinateSystem > coordinates(solidRegions.size())
Foam::triSurfaceMesh::boundingSpheres
virtual void boundingSpheres(pointField &centres, scalarField &radiusSqr) const
Get bounding spheres (centre and radius squared). Any point.
Definition: triSurfaceMesh.C:406
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::triSurfaceMesh::clearOut
void clearOut()
Clear storage.
Definition: triSurfaceMesh.C:378
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
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::triSurfaceMesh::points
virtual tmp< pointField > points() const
Get the points that define the surface.
Definition: triSurfaceMesh.C:433
Foam::triSurfaceMesh::coordinates
virtual tmp< pointField > coordinates() const
Get representative set of element coordinates.
Definition: triSurfaceMesh.C:389
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::isFile
bool isFile(const fileName &, const bool checkGzip=true)
Does the name exist as a FILE in the file system?
Definition: POSIX.C:622
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
s
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){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Foam::HashTable::find
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Foam::triSurfaceMesh::setField
virtual void setField(const labelList &values)
WIP. Store element-wise field.
Definition: triSurfaceMesh.C:729
Random.H
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::List< labelledTri >::size
label size() const
Return the number of elements in the UList.
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::triSurfaceMesh::checkFile
static const fileName & checkFile(const fileName &fName, const fileName &objectName)
Check file existence.
Definition: triSurfaceMesh.C:105
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::EdgeMap< label >
Foam::triSurfaceSearch::findLine
void findLine(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
Definition: triSurfaceSearch.C:325
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::triSurfaceMesh::findLineAll
virtual void findLineAll(const pointField &start, const pointField &end, List< List< pointIndexHit > > &) const
Get all intersections in order from start to end.
Definition: triSurfaceMesh.C:621
Foam::triSurfaceMesh::~triSurfaceMesh
virtual ~triSurfaceMesh()
Destructor.
Definition: triSurfaceMesh.C:372
Foam::triSurface::scalePoints
virtual void scalePoints(const scalar &)
Scale points. A non-positive factor is ignored.
Definition: triSurface.C:803
Foam::HashTable::clear
void clear()
Clear all entries from table.
Definition: HashTable.C:473
f
labelList f(nPoints)
Foam::triSurfaceMesh::findNearest
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const
Definition: triSurfaceMesh.C:570
Foam::Vector< scalar >
Foam::Time::timeName
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:741
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::TimePaths::caseConstant
fileName caseConstant() const
Return constant name for the case.
Definition: TimePaths.C:123
Foam::triSurfaceMesh::addFaceToEdge
static bool addFaceToEdge(const edge &, EdgeMap< label > &)
Helper function for isSurfaceClosed.
Definition: triSurfaceMesh.C:121
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePaths.H:130
Foam::triSurfaceMesh::writeObject
virtual bool writeObject(IOstream::streamFormat fmt, IOstream::versionNumber ver, IOstream::compressionType cmp) const
Write using given format, version and compression.
Definition: triSurfaceMesh.C:840
Foam::PrimitivePatch::faceCentres
const Field< PointType > & faceCentres() const
Return face centres for patch.
Definition: PrimitivePatchTemplate.C:500
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: doubleFloat.H:94
Foam::triSurfaceMesh::overlaps
virtual bool overlaps(const boundBox &bb) const
Does any part of the surface overlap the supplied bound box?
Definition: triSurfaceMesh.C:439
timeName
word timeName
Definition: getTimeIndex.H:3
EdgeMap.H
Foam::labelledTri
Triangle with additional region number.
Definition: labelledTri.H:49
Foam::triSurfaceMesh::isSurfaceClosed
bool isSurfaceClosed() const
Check whether surface is closed without calculating any permanent.
Definition: triSurfaceMesh.C:143
Foam::boundBox
A bounding box defined in terms of the points at its extremities.
Definition: boundBox.H:55
patches
patches[0]
Definition: createSingleCellMesh.H:36
Foam::triSurfaceSearch::findLineAny
void findLineAny(const pointField &start, const pointField &end, List< pointIndexHit > &info) const
Definition: triSurfaceSearch.C:348
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::point
vector point
Point is a vector.
Definition: point.H:41
Foam::triSurface::write
void write(const fileName &, const word &ext, const bool sort) const
Generic write routine. Chooses writer based on extension.
Definition: triSurface.C:433
Foam::mkDir
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Definition: POSIX.C:419
triSurfaceMesh.H
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::triSurfaceMesh::getVolumeType
virtual void getVolumeType(const pointField &, List< volumeType > &) const
Determine type (inside/outside/mixed) for point. unknown if.
Definition: triSurfaceMesh.C:796
Foam::triSurfaceMesh::hasVolumeType
virtual bool hasVolumeType() const
Whether supports volume type below. I.e. whether is closed.
Definition: triSurfaceMesh.C:551
Foam::volumeType::UNKNOWN
@ UNKNOWN
Definition: volumeType.H:61
Foam::IOobject::local
const fileName & local() const
Definition: IOobject.H:360
Foam::magSqr
dimensioned< scalar > magSqr(const dimensioned< Type > &)
rndGen
cachedRandom rndGen(label(0), -1)
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
normal
A normal distribution model.
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88
Foam::IOstream::streamFormat
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86