triSurface.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2024 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "triSurface.H"
30 #include "Time.H"
31 #include "surfZoneList.H"
32 #include "MeshedSurface.H"
33 #include "ListOps.H"
34 #include "stringListOps.H" // For stringListOps::findMatching()
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  defineTypeNameAndDebug(triSurface, 0);
41 }
42 
43 
44 // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Helper function to print triangle info
50 static void printTriangle
51 (
52  Ostream& os,
53  const string& pre,
54  const labelledTri& f,
55  const pointField& points
56 )
57 {
58  os
59  << pre.c_str() << "vertex numbers:"
60  << f[0] << ' ' << f[1] << ' ' << f[2] << nl
61 
62  << pre.c_str() << "vertex coords :"
63  << points[f[0]] << ' ' << points[f[1]] << ' ' << points[f[2]]
64 
65  << pre.c_str() << "region :" << f.region() << nl
66  << endl;
67 }
68 
69 } // End namespace Foam
70 
71 
72 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
73 
75 {
76  fileName foamName(d.caseName() + ".ftr");
77 
78  // Search back through the time directories list to find the time
79  // closest to and lower than current time
80 
81  instantList ts = d.times();
82  label i;
83 
84  for (i=ts.size()-1; i>=0; i--)
85  {
86  if (ts[i].value() <= d.timeOutputValue())
87  {
88  break;
89  }
90  }
91 
92  // Noting that the current directory has already been searched
93  // for mesh data, start searching from the previously stored time directory
94 
95  if (i>=0)
96  {
97  for (label j=i; j>=0; j--)
98  {
99  if (isFile(d.path()/ts[j].name()/typeName/foamName))
100  {
101  if (debug)
102  {
103  Pout<< " triSurface::triSurfInstance(const Time& d)"
104  << "reading " << foamName
105  << " from " << ts[j].name()/typeName
106  << endl;
107  }
108 
109  return ts[j].name();
110  }
111  }
112  }
113 
114  if (debug)
115  {
116  Pout<< " triSurface::triSurfInstance(const Time& d)"
117  << "reading " << foamName
118  << " from constant/" << endl;
119  }
120  return d.constant();
121 }
122 
123 
124 Foam::List<Foam::labelledTri> Foam::triSurface::convertToTri
125 (
126  const faceList& faces,
127  const label defaultRegion
128 )
129 {
130  List<labelledTri> triFaces(faces.size());
131 
132  forAll(triFaces, facei)
133  {
134  const face& f = faces[facei];
135 
136  if (f.size() != 3)
137  {
139  << "Face at position " << facei
140  << " does not have three vertices:" << f
141  << abort(FatalError);
142  }
143 
144  labelledTri& tri = triFaces[facei];
145 
146  tri[0] = f[0];
147  tri[1] = f[1];
148  tri[2] = f[2];
149  tri.region() = defaultRegion;
150  }
151 
152  return triFaces;
153 }
154 
155 
156 Foam::List<Foam::labelledTri> Foam::triSurface::convertToTri
157 (
158  const triFaceList& faces,
159  const label defaultRegion
160 )
161 {
162  List<labelledTri> triFaces(faces.size());
163 
164  forAll(triFaces, facei)
165  {
166  const triFace& f = faces[facei];
167 
168  labelledTri& tri = triFaces[facei];
169 
170  tri[0] = f[0];
171  tri[1] = f[1];
172  tri[2] = f[2];
173  tri.region() = defaultRegion;
174  }
175 
176  return triFaces;
177 }
178 
179 
180 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
181 
182 // Remove non-triangles, double triangles.
183 void Foam::triSurface::checkTriangles(const bool verbose)
184 {
185  // Simple check on indices ok.
186  const label maxPointi = points().size() - 1;
187 
188  for (const auto& f : *this)
189  {
190  for (const label verti : f)
191  {
192  if (verti < 0 || verti > maxPointi)
193  {
195  << "triangle " << f
196  << " uses point indices outside point range 0.."
197  << maxPointi
198  << exit(FatalError);
199  }
200  }
201  }
202 
203  // Two phase process
204  // 1. mark invalid faces
205  // 2. pack
206  // Done to keep numbering constant in phase 1
207 
208  // List of valid triangles
209  bitSet valid(size(), true);
210 
211  forAll(*this, facei)
212  {
213  const labelledTri& f = (*this)[facei];
214 
215  if (!f.good())
216  {
217  // 'degenerate' triangle check
218  valid.unset(facei);
219 
220  if (verbose)
221  {
223  << "triangle " << facei
224  << " does not have three unique vertices:\n";
225  printTriangle(Warning, " ", f, points());
226  }
227  }
228  else
229  {
230  // duplicate triangle check
231  const labelList& fEdges = faceEdges()[facei];
232 
233  // Check if faceNeighbours use same points as this face.
234  // Note: discards normal information - sides of baffle are merged.
235 
236  for (const label edgei : fEdges)
237  {
238  const labelList& eFaces = edgeFaces()[edgei];
239 
240  for (const label neighbour : eFaces)
241  {
242  if (neighbour > facei)
243  {
244  // lower numbered faces already checked
245  const labelledTri& n = (*this)[neighbour];
246 
247  if
248  (
249  ((f[0] == n[0]) || (f[0] == n[1]) || (f[0] == n[2]))
250  && ((f[1] == n[0]) || (f[1] == n[1]) || (f[1] == n[2]))
251  && ((f[2] == n[0]) || (f[2] == n[1]) || (f[2] == n[2]))
252  )
253  {
254  valid.unset(facei);
255 
256  if (verbose)
257  {
259  << "triangles share the same vertices:\n"
260  << " face 1 :" << facei << endl;
261  printTriangle(Warning, " ", f, points());
262 
263  Warning
264  << endl
265  << " face 2 :"
266  << neighbour << endl;
267  printTriangle(Warning, " ", n, points());
268  }
269 
270  break;
271  }
272  }
273  }
274  }
275  }
276  }
277 
278  if (!valid.all())
279  {
280  // Compact
281  label newFacei = 0;
282  for (const label facei : valid)
283  {
284  (*this)[newFacei++] = (*this)[facei];
285  }
286 
287  if (verbose)
288  {
290  << "Removing " << size() - newFacei
291  << " illegal faces." << endl;
292  }
293  (*this).setSize(newFacei);
294 
295  // Topology can change because of renumbering
296  clearOut();
297  }
298 }
299 
300 
301 // Check/fix edges with more than two triangles
302 void Foam::triSurface::checkEdges(const bool verbose)
303 {
304  const labelListList& eFaces = edgeFaces();
305 
306  forAll(eFaces, edgei)
307  {
308  const labelList& myFaces = eFaces[edgei];
309 
310  if (myFaces.empty())
311  {
313  << "Edge " << edgei << " with vertices " << edges()[edgei]
314  << " has no edgeFaces"
315  << exit(FatalError);
316  }
317  else if (myFaces.size() > 2 && verbose)
318  {
320  << "Edge " << edgei << " with vertices " << edges()[edgei]
321  << " has more than 2 faces connected to it : " << myFaces
322  << endl;
323  }
324  }
325 }
326 
327 
328 // Returns patch info. Sets faceMap to the indexing according to patch
329 // numbers. Patch numbers start at 0.
331 Foam::triSurface::calcPatches(labelList& faceMap) const
332 {
333  // Determine the sorted order:
334  // use sortedOrder directly (the intermediate list is discarded anyhow)
335 
336  labelList regions(size());
337  forAll(regions, facei)
338  {
339  regions[facei] = operator[](facei).region();
340  }
341  sortedOrder(regions, faceMap);
342  regions.clear();
343 
344  // Extend regions
345  label maxRegion = patches_.size()-1; // for non-compacted regions
346 
347  if (!faceMap.empty())
348  {
349  maxRegion = max
350  (
351  maxRegion,
352  operator[](faceMap.back()).region()
353  );
354  }
355 
356  // Get new region list
357  surfacePatchList newPatches(maxRegion + 1);
358 
359  // Fill patch sizes
360  forAll(*this, facei)
361  {
362  label region = operator[](facei).region();
363 
364  newPatches[region].size()++;
365  }
366 
367 
368  // Fill rest of patch info
369 
370  label startFacei = 0;
371  forAll(newPatches, newPatchi)
372  {
373  surfacePatch& newPatch = newPatches[newPatchi];
374 
375  newPatch.index() = newPatchi;
376  newPatch.start() = startFacei;
377 
378  // Take over any information from existing patches
379  if
380  (
381  newPatchi < patches_.size()
382  && !patches_[newPatchi].name().empty()
383  )
384  {
385  newPatch.name() = patches_[newPatchi].name();
386  }
387  else
388  {
389  newPatch.name() = surfacePatch::defaultName(newPatchi);
390  }
391 
392  if
393  (
394  newPatchi < patches_.size()
395  && !patches_[newPatchi].geometricType().empty()
396  )
397  {
398  newPatch.geometricType() = patches_[newPatchi].geometricType();
399  }
400  else
401  {
402  newPatch.geometricType() = surfacePatch::emptyType;
403  }
404 
405  startFacei += newPatch.size();
406  }
407 
408  return newPatches;
409 }
410 
411 
412 void Foam::triSurface::setDefaultPatches()
413 {
415 
416  // Get names, types and sizes
417  surfacePatchList newPatches(calcPatches(faceMap));
418 
419  // Take over names and types (but not size)
420  patches_.setSize(newPatches.size());
421 
422  forAll(newPatches, patchi)
423  {
424  patches_[patchi].index() = patchi;
425  patches_[patchi].name() = newPatches[patchi].name();
426  patches_[patchi].geometricType() = newPatches[patchi].geometricType();
427  }
428 }
429 
430 
431 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
432 
434 :
436  patches_(),
437  sortedEdgeFacesPtr_(nullptr),
438  edgeOwnerPtr_(nullptr)
439 {}
440 
441 
443 :
444  MeshReference(surf, surf.points()),
445  patches_(surf.patches()),
446  sortedEdgeFacesPtr_(nullptr),
447  edgeOwnerPtr_(nullptr)
448 {}
449 
450 
452 :
454 {
455  transfer(surf);
456 }
457 
458 
460 (
463  const pointField& pts
464 )
465 :
466  MeshReference(triangles, pts),
467  patches_(patches),
468  sortedEdgeFacesPtr_(nullptr),
469  edgeOwnerPtr_(nullptr)
470 {}
471 
472 
474 (
477  pointField& pts,
478  const bool reuse
479 )
480 :
481  MeshReference(triangles, pts, reuse),
482  patches_(patches),
483  sortedEdgeFacesPtr_(nullptr),
484  edgeOwnerPtr_(nullptr)
485 {}
486 
487 
489 (
491  const pointField& pts
492 )
493 :
494  MeshReference(triangles, pts),
495  patches_(),
496  sortedEdgeFacesPtr_(nullptr),
497  edgeOwnerPtr_(nullptr)
498 {
499  setDefaultPatches();
500 }
501 
502 
504 (
505  const triFaceList& triangles,
506  const pointField& pts
507 )
508 :
509  MeshReference(convertToTri(triangles, 0), pts),
510  patches_(),
511  sortedEdgeFacesPtr_(nullptr),
512  edgeOwnerPtr_(nullptr)
513 {
514  setDefaultPatches();
515 }
516 
517 
519 (
520  const fileName& name,
521  const scalar scaleFactor
522 )
523 :
524  triSurface(name, name.ext(), scaleFactor)
525 {}
526 
527 
529 (
530  const fileName& name,
531  const word& fileType,
532  const scalar scaleFactor
533 )
534 :
535  triSurface()
536 {
537  read(name, fileType);
538  scalePoints(scaleFactor);
539  setDefaultPatches();
540 }
541 
542 
543 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
544 
546 {
547  clearOut();
548 }
549 
550 
551 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
552 
554 {
555  MeshReference::clearTopology();
556  sortedEdgeFacesPtr_.reset(nullptr);
557  edgeOwnerPtr_.reset(nullptr);
558 }
559 
562 {
563  MeshReference::clearPatchMeshAddr();
564 }
565 
566 
568 {
569  MeshReference::clearOut();
570  clearTopology();
571  clearPatchMeshAddr();
572 }
573 
574 
576 {
577  if (this == &surf)
578  {
579  return; // Self-swap is a no-op
580  }
581 
582  clearOut();
583  surf.clearOut();
585  storedFaces().swap(surf.storedFaces());
586  storedPoints().swap(surf.storedPoints());
587  patches_.swap(surf.patches());
588 }
589 
590 
592 {
593  if (!sortedEdgeFacesPtr_)
594  {
595  calcSortedEdgeFaces();
596  }
597 
598  return *sortedEdgeFacesPtr_;
599 }
600 
601 
603 {
604  if (!edgeOwnerPtr_)
605  {
606  calcEdgeOwner();
607  }
608 
609  return *edgeOwnerPtr_;
610 }
611 
612 
614 {
615  // Remove all geometry dependent data
616  sortedEdgeFacesPtr_.reset(nullptr);
617 
618  // Adapt for new point positions
619  MeshReference::movePoints(pts);
620 
621  // Copy new points
622  storedPoints() = pts;
623 }
624 
625 
627 {
628  // Remove all geometry dependent data
629  sortedEdgeFacesPtr_.reset(nullptr);
630 
631  // Adapt for new point positions
632  MeshReference::movePoints(pts);
633 
634  // Move/swap new points
635  storedPoints().swap(pts);
636 }
637 
638 
639 void Foam::triSurface::scalePoints(const scalar scaleFactor)
640 {
641  // Avoid bad or no scaling
642  if (scaleFactor > SMALL && !equal(scaleFactor, 1))
643  {
644  // Remove all geometry dependent data
645  this->clearTopology();
646 
647  // Adapt for new point positions
648  MeshReference::movePoints(pointField());
650  this->storedPoints() *= scaleFactor;
651  }
652 }
653 
654 
655 // Remove non-triangles, double triangles.
656 void Foam::triSurface::cleanup(const bool verbose)
657 {
658  // Merge points (already done for STL, TRI)
659  stitchTriangles(SMALL, verbose);
660 
661  // Merging points might have changed geometric factors
662  clearOut();
664  checkTriangles(verbose);
665 
666  checkEdges(verbose);
667 }
668 
669 
671 {
672  this->clearOut(); // Topology changes
673 
674  // Remove unused points while walking and renumbering faces
675  // in visit order - walk order as per localFaces()
676 
677  labelList oldToCompact(this->points().size(), -1);
678  DynamicList<label> compactPointMap(oldToCompact.size());
679 
680  for (auto& f : this->storedFaces())
681  {
682  for (label& pointi : f)
683  {
684  label compacti = oldToCompact[pointi];
685  if (compacti == -1)
686  {
687  compacti = compactPointMap.size();
688  oldToCompact[pointi] = compacti;
689  compactPointMap.append(pointi);
690  }
691  pointi = compacti;
692  }
693  }
694 
695  pointField newPoints
696  (
697  UIndirectList<point>(this->points(), compactPointMap)
698  );
699 
700  this->swapPoints(newPoints);
701 
702  if (notNull(pointMap))
703  {
704  pointMap.transfer(compactPointMap);
705  }
706 }
707 
708 
711 {
712  surfacePatchList patches(calcPatches(faceMap));
713 
714  surfZoneList zones(patches.size());
715  forAll(patches, patchi)
716  {
717  zones[patchi] = surfZone(patches[patchi]);
718  }
719 
720  return zones;
721 }
722 
723 
724 void Foam::triSurface::triFaceFaces(List<face>& plainFaces) const
725 {
726  plainFaces.setSize(size());
727 
728  forAll(*this, facei)
729  {
730  plainFaces[facei] = this->operator[](facei);
731  }
732 }
733 
734 
735 // Finds area, starting at facei, delimited by borderEdge. Marks all visited
736 // faces (from face-edge-face walk) with currentZone.
738 (
739  const boolList& borderEdge,
740  const label facei,
741  const label currentZone,
742  labelList& faceZone
743 ) const
744 {
745  // List of faces whose faceZone has been set.
746  labelList changedFaces(1, facei);
747 
748  while (true)
749  {
750  // Pick up neighbours of changedFaces
751  DynamicList<label> newChangedFaces(2*changedFaces.size());
752 
753  for (const label facei : changedFaces)
754  {
755  const labelList& fEdges = faceEdges()[facei];
756 
757  for (const label edgei : fEdges)
758  {
759  if (!borderEdge[edgei])
760  {
761  const labelList& eFaces = edgeFaces()[edgei];
762 
763  for (const label nbrFacei : eFaces)
764  {
765  if (faceZone[nbrFacei] == -1)
766  {
767  faceZone[nbrFacei] = currentZone;
768  newChangedFaces.append(nbrFacei);
769  }
770  else if (faceZone[nbrFacei] != currentZone)
771  {
773  << "Zones " << faceZone[nbrFacei]
774  << " at face " << nbrFacei
775  << " connects to zone " << currentZone
776  << " at face " << facei
777  << abort(FatalError);
778  }
779  }
780  }
781  }
782  }
783 
784  if (newChangedFaces.empty())
785  {
786  break;
787  }
788 
789  changedFaces.transfer(newChangedFaces);
790  }
791 }
792 
793 
794 // Finds areas delimited by borderEdge (or 'real' edges).
795 // Fills faceZone accordingly
796 Foam::label Foam::triSurface::markZones
797 (
798  const boolList& borderEdge,
799  labelList& faceZone
800 ) const
801 {
802  faceZone.setSize(size());
803  faceZone = -1;
804 
805  if (borderEdge.size() != nEdges())
806  {
808  << "borderEdge boolList not same size as number of edges" << endl
809  << "borderEdge:" << borderEdge.size() << endl
810  << "nEdges :" << nEdges()
811  << exit(FatalError);
812  }
813 
814  label zoneI = 0;
815 
816  for (label startFacei = 0;; zoneI++)
817  {
818  // Find first non-coloured face
819  for (; startFacei < size(); startFacei++)
820  {
821  if (faceZone[startFacei] == -1)
822  {
823  break;
824  }
825  }
826 
827  if (startFacei >= size())
828  {
829  break;
830  }
831 
832  faceZone[startFacei] = zoneI;
833 
834  markZone(borderEdge, startFacei, zoneI, faceZone);
835  }
836 
837  return zoneI;
838 }
839 
840 
841 Foam::triSurface Foam::triSurface::subsetMeshImpl
842 (
843  const labelList& pointMap,
844  const labelList& faceMap
845 ) const
846 {
847  const pointField& locPoints = localPoints();
848  const List<labelledTri>& locFaces = localFaces();
849 
850  // Subset of points (compact)
851  pointField newPoints(UIndirectList<point>(locPoints, pointMap));
852 
853  // Inverse point mapping - same as ListOps invert() without checks
854  labelList oldToNew(locPoints.size(), -1);
855  forAll(pointMap, pointi)
856  {
857  oldToNew[pointMap[pointi]] = pointi;
858  }
859 
860  // Subset of faces
861  List<labelledTri> newFaces(UIndirectList<labelledTri>(locFaces, faceMap));
862 
863  // Renumber face node labels
864  for (auto& f : newFaces)
865  {
866  for (label& vert : f)
867  {
868  vert = oldToNew[vert];
869  }
870  }
871  oldToNew.clear();
872 
873  // Construct sub-surface
874  return triSurface(newFaces, patches(), newPoints, true);
875 }
876 
877 
880 (
881  const UList<bool>& include,
882  labelList& pointMap,
884 ) const
885 {
886  this->subsetMeshMap(include, pointMap, faceMap);
887  return this->subsetMeshImpl(pointMap, faceMap);
888 }
889 
890 
893 (
894  const bitSet& include,
895  labelList& pointMap,
897 ) const
898 {
899  this->subsetMeshMap(include, pointMap, faceMap);
900  return this->subsetMeshImpl(pointMap, faceMap);
901 }
902 
903 
905 Foam::triSurface::subsetMesh(const UList<bool>& include) const
906 {
907  labelList pointMap, faceMap;
908  return this->subsetMesh(include, pointMap, faceMap);
909 }
910 
911 
913 Foam::triSurface::subsetMesh(const bitSet& include) const
914 {
915  labelList pointMap, faceMap;
916  return this->subsetMesh(include, pointMap, faceMap);
917 }
918 
919 
922 (
923  const wordRes& includeNames,
924  const wordRes& excludeNames
925 ) const
926 {
927  const bitSet selectPatches
928  (
930  (
931  patches_,
932  includeNames,
933  excludeNames,
935  )
936  );
937 
938  bitSet include(this->size());
939 
940  forAll(*this, facei)
941  {
942  const label patchi = (*this)[facei].region();
943 
944  if (selectPatches.test(patchi))
945  {
946  include.set(facei);
947  }
948  }
949 
950  return this->subsetMesh(include);
951 }
952 
953 
954 void Foam::triSurface::swapFaces(List<labelledTri>& faceLst)
955 {
956  clearOut(); // Topology changes
957 
958  this->storedFaces().swap(faceLst);
959 }
960 
961 
963 {
964  clearOut();
965 
966  storedFaces().transfer(surf.storedFaces());
967  storedPoints().transfer(surf.storedPoints());
968  patches_.transfer(surf.patches());
969 
970  surf.clearOut();
971 }
972 
973 
975 {
976  // Transcribe zone -> patch info
977  auto patches = ListOps::create<geometricSurfacePatch>
978  (
979  surf.surfZones(),
981  );
982 
983  // Fairly ugly, but the only way to get at the data safely
984  List<labelledTri> fcs;
985  pointField pts;
986 
987  surf.swapFaces(fcs);
988  surf.swapPoints(pts);
989 
990  clearOut();
991  surf.clear();
992 
993  triSurface s(fcs, patches, pts, true);
994  swap(s);
995 }
996 
997 
998 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
999 
1000 void Foam::triSurface::operator=(const triSurface& surf)
1001 {
1002  clearOut();
1004  storedFaces() = surf;
1005  storedPoints() = surf.points();
1006  patches_ = surf.patches();
1007 }
1008 
1011 {
1012  transfer(surf);
1013 }
1014 
1015 
1017 {
1018  transfer(surf);
1019 }
1020 
1021 
1022 // ************************************************************************* //
List< triFace > triFaceList
List of triFace.
Definition: triFaceList.H:31
triSurface subsetMesh(const UList< bool > &include, labelList &pointMap, labelList &faceMap) const
Return a new surface subsetted on the selected faces.
Definition: triSurface.C:873
void cleanup(const bool verbose)
Remove non-valid triangles.
Definition: triSurface.C:649
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
std::enable_if< std::is_same< bool, TypeT >::value, bool >::type unset(const label i)
Unset the bool entry at specified position, always false for out-of-range access. ...
Definition: UList.H:805
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition: bitSetI.H:498
A class for handling file names.
Definition: fileName.H:72
virtual const fileName & name() const
The name of the stream.
Definition: IOstream.C:33
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
Definition: List.C:326
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
bool equal(const T &a, const T &b)
Compare two values for equality.
Definition: label.H:164
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:608
void compactPoints(labelList &pointMap=const_cast< labelList &>(labelList::null()))
Remove unused points and renumber faces in local visit order.
Definition: triSurface.C:663
void append(const T &val)
Append an element at the end of the list.
Definition: List.H:521
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
A surface zone on a MeshedSurface.
Definition: surfZone.H:52
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
virtual void movePoints(const pointField &pts)
Move points.
Definition: triSurface.C:606
virtual void clear()
Clear all storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
void transfer(triSurface &surf)
Alter contents by transferring (triangles, points) components.
Definition: triSurface.C:955
std::vector< Triangle > triangles
static void printTriangle(Ostream &os, const string &pre, const labelledTri &f, const pointField &points)
Definition: triSurface.C:44
Operations on lists of strings.
void clearPatchMeshAddr()
Definition: triSurface.C:554
virtual const fileName & name() const override
Get the name of the output serial stream. (eg, the name of the Fstream file name) ...
Definition: OSstream.H:134
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
List< labelledTri > & storedFaces()
Non-const access to the faces.
Definition: triSurface.H:238
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Extract name (as a word) from an object, typically using its name() method.
Definition: word.H:340
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
static word defaultName(const label n=-1)
Default patch name: "patch" or "patchN".
Helper to convert identifier types as an operation.
void swapPoints(pointField &points)
Swap the stored points.
List< face > faceList
List of faces.
Definition: faceListFwd.H:39
static fileName triSurfInstance(const Time &)
Name of triSurface directory to use.
Definition: triSurface.C:67
const geometricSurfacePatchList & patches() const noexcept
Definition: triSurface.H:509
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
const labelListList & sortedEdgeFaces() const
Return edge-face addressing sorted (for edges with more than.
Definition: triSurface.C:584
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
const pointField & points
A class for handling words, derived from Foam::string.
Definition: word.H:63
face triFace(3)
void checkTriangles(const bool verbose)
Check/remove duplicate/degenerate triangles.
Definition: triSurface.C:176
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:106
labelList findMatching(const StringListType &input, const wordRes::filter &pred, AccessOp aop=identityOp())
Return ids for items with matching names.
void checkEdges(const bool verbose)
Check triply (or more) connected edges.
Definition: triSurface.C:295
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
void swapFaces(List< labelledTri > &faceLst)
Swap the list of faces being addressed.
Definition: triSurface.C:947
A triFace with additional (region) index.
Definition: labelledTri.H:53
const Field< point_type > & points() const noexcept
Return reference to global points.
errorManip< error > abort(error &err)
Definition: errorManip.H:139
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:105
pointField & storedPoints()
Non-const access to global points.
Definition: triSurface.H:230
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
void markZone(const boolList &borderEdge, const label facei, const label currentZone, labelList &faceZone) const
Fill faceZone with currentZone for every face reachable.
Definition: triSurface.C:731
int debug
Static debugging option.
void triFaceFaces(List< face > &plainFaceList) const
Create a list of faces from the triFaces.
Definition: triSurface.C:717
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
static constexpr const char *const emptyType
The name for an &#39;empty&#39; type.
labelList f(nPoints)
messageStream Warning
Warning stream (stdout output on master, null elsewhere), with additional &#39;FOAM Warning&#39; header text...
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
Definition: POSIX.C:877
virtual void swapPoints(pointField &pts)
Swap points. Similar to movePoints, but returns the old points.
Definition: triSurface.C:619
triSurface()
Default construct.
Definition: triSurface.C:426
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
#define WarningInFunction
Report a warning using Foam::Warning.
bool notNull(const T *ptr) noexcept
True if ptr is not a pointer (of type T) to the nullObject.
Definition: nullObject.H:267
const polyBoundaryMesh & patches
List< surfZone > surfZoneList
List of surfZone.
Definition: surfZoneList.H:32
List< surfZone > sortedZones(labelList &faceMap) const
Sort faces according to zoneIds.
Definition: triSurface.C:703
void swap(triSurface &surf)
Definition: triSurface.C:568
void swapFaces(List< Face > &faces)
Swap the stored faces. Use with caution.
virtual void scalePoints(const scalar scaleFactor)
Scale points. A non-positive factor is ignored.
Definition: triSurface.C:632
label n
label markZones(const boolList &borderEdge, labelList &faceZone) const
(size and) fills faceZone with zone of face. Zone is area
Definition: triSurface.C:790
virtual ~triSurface()
Destructor.
Definition: triSurface.C:538
void clearTopology()
Definition: triSurface.C:546
List< label > labelList
A List of labels.
Definition: List.H:62
List< instant > instantList
List of instants.
Definition: instantList.H:41
const surfZoneList & surfZones() const
Const access to the surface zones.
Triangulated surface description with patch information.
Definition: triSurface.H:71
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void operator=(const triSurface &surf)
Copy assignment.
Definition: triSurface.C:993
const labelList & edgeOwner() const
If 2 face neighbours: label of face where ordering of edge.
Definition: triSurface.C:595
List< bool > boolList
A List of bools.
Definition: List.H:60
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Namespace for OpenFOAM.
List< surfacePatch > surfacePatchList
List of surfacePatch.
const pointField & pts