MeshedSurface.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
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 "MeshedSurface.H"
27 #include "UnsortedMeshedSurface.H"
28 #include "MeshedSurfaceProxy.H"
29 #include "mergePoints.H"
30 #include "Time.H"
31 #include "ListOps.H"
32 #include "polyBoundaryMesh.H"
33 #include "polyMesh.H"
34 #include "surfMesh.H"
35 #include "primitivePatch.H"
36 #include "polygonTriangulate.H"
38 
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 
41 template<class Face>
43 {
44  return false;
45 }
46 
47 
48 template<class Face>
50 {
51  return wordHashSet(*fileExtensionConstructorTablePtr_);
52 }
53 
54 
55 template<class Face>
57 {
58  return wordHashSet(*writefileExtensionMemberFunctionTablePtr_);
59 }
60 
61 
62 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
63 
64 template<class Face>
66 (
67  const word& ext,
68  const bool verbose
69 )
70 {
71  return fileFormats::surfaceFormatsCore::checkSupport
72  (
73  readTypes() | FriendType::readTypes(),
74  ext,
75  verbose,
76  "reading"
77  );
78 }
79 
80 
81 template<class Face>
83 (
84  const word& ext,
85  const bool verbose
86 )
87 {
88  return fileFormats::surfaceFormatsCore::checkSupport
89  (
90  writeTypes() | ProxyType::writeTypes(),
91  ext,
92  verbose,
93  "writing"
94  );
95 }
96 
97 
98 template<class Face>
100 (
101  const fileName& name,
102  const bool verbose
103 )
104 {
105  word ext = name.ext();
106  if (ext == "gz")
107  {
108  ext = name.lessExt().ext();
109  }
110  return canReadType(ext, verbose);
111 }
112 
113 
114 template<class Face>
116 (
117  const fileName& name,
118  const MeshedSurface<Face>& surf
119 )
120 {
121  if (debug)
122  {
123  InfoInFunction << "Writing to " << name << endl;
124  }
125 
126  const word ext = name.ext();
127 
128  typename writefileExtensionMemberFunctionTable::iterator mfIter =
129  writefileExtensionMemberFunctionTablePtr_->find(ext);
130 
131  if (mfIter == writefileExtensionMemberFunctionTablePtr_->end())
132  {
133  // no direct writer, delegate to proxy if possible
134  wordHashSet supported = ProxyType::writeTypes();
135 
136  if (supported.found(ext))
137  {
138  MeshedSurfaceProxy<Face>(surf).write(name);
139  }
140  else
141  {
143  << "Unknown file extension " << ext << nl << nl
144  << "Valid types are :" << endl
145  << (supported | writeTypes())
146  << exit(FatalError);
147  }
148  }
149  else
150  {
151  mfIter()(name, surf);
152  }
153 }
154 
155 
156 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
157 
158 template<class Face>
160 :
161  ParentType(List<Face>(), pointField())
162 {}
163 
164 
165 template<class Face>
167 (
168  pointField&& pointLst,
169  List<Face>&& faceLst,
170  surfZoneList&& zoneLst
171 )
172 :
174  zones_()
175 {
176  reset(move(pointLst), move(faceLst), move(zoneLst));
177 }
178 
179 
180 template<class Face>
182 (
183  pointField&& pointLst,
184  List<Face>&& faceLst,
185  const labelUList& zoneSizes,
186  const UList<word>& zoneNames
187 )
188 :
190 {
191  reset(move(pointLst), move(faceLst), surfZoneList());
192 
193  if (zoneSizes.size())
194  {
195  if (zoneNames.size())
196  {
197  addZones(zoneSizes, zoneNames);
198  }
199  else
200  {
201  addZones(zoneSizes);
202  }
203  }
204 }
205 
206 
207 template<class Face>
209 (
210  const MeshedSurface<Face>& surf
211 )
212 :
213  ParentType(surf.faces(), surf.points()),
214  zones_(surf.surfZones())
215 {}
216 
217 
218 template<class Face>
220 (
221  const UnsortedMeshedSurface<Face>& surf
222 )
223 :
224  ParentType(List<Face>(), surf.points())
225 {
227  this->storedZones() = surf.sortedZones(faceMap);
228 
229  const List<Face>& origFaces = surf.faces();
230  List<Face> newFaces(origFaces.size());
231 
232  forAll(newFaces, facei)
233  {
234  newFaces[faceMap[facei]] = origFaces[facei];
235  }
236 
237  this->storedFaces().transfer(newFaces);
238 }
239 
240 
241 template<class Face>
243 :
244  ParentType(List<Face>(), pointField())
245 {
246  // same face type as surfMesh
248  (
249  clone(mesh.points()),
250  clone(mesh.faces()),
251  clone(mesh.surfZones())
252  );
253 
254  this->transcribe(surf);
255 }
256 
257 
258 template<class Face>
260 (
261  const polyBoundaryMesh& bMesh,
262  const bool useGlobalPoints
263 )
264 :
266 {
267  const polyMesh& mesh = bMesh.mesh();
268  const polyPatchList& bPatches = bMesh;
269 
270  // Get a single patch for all boundaries
271  primitivePatch allBoundary
272  (
274  (
275  mesh.faces(),
276  mesh.nFaces() - mesh.nInternalFaces(),
277  mesh.nInternalFaces()
278  ),
279  mesh.points()
280  );
281 
282  // use global/local points:
283  const pointField& bPoints =
284  (
285  useGlobalPoints ? mesh.points() : allBoundary.localPoints()
286  );
287 
288  // global/local face addressing:
289  const List<Face>& bFaces =
290  (
291  useGlobalPoints ? allBoundary : allBoundary.localFaces()
292  );
293 
294 
295  // create zone list
296  surfZoneList newZones(bPatches.size());
297 
298  label startFacei = 0;
299  label nZone = 0;
300  forAll(bPatches, patchi)
301  {
302  const polyPatch& p = bPatches[patchi];
303 
304  if (p.size())
305  {
306  newZones[nZone] = surfZone
307  (
308  p.name(),
309  p.size(),
310  startFacei,
311  nZone
312  );
313 
314  nZone++;
315  startFacei += p.size();
316  }
317  }
318 
319  newZones.setSize(nZone);
320 
321  // same face type as the polyBoundaryMesh
323  (
324  pointField(bPoints),
325  faceList(bFaces),
326  move(newZones)
327  );
328 
329  this->transcribe(surf);
330 }
331 
332 
333 template<class Face>
335 (
336  const fileName& name,
337  const word& ext
338 )
339 :
341 {
342  read(name, ext);
343 }
344 
345 
346 template<class Face>
348 :
349  ParentType(List<Face>(), pointField())
350 {
351  read(name);
352 }
353 
354 
355 template<class Face>
357 (
358  const Time& t,
359  const word& surfName
360 )
361 :
363 {
364  surfMesh mesh
365  (
366  IOobject
367  (
368  "dummyName",
369  t.timeName(),
370  t,
371  IOobject::MUST_READ_IF_MODIFIED,
372  IOobject::NO_WRITE,
373  false
374  ),
375  surfName
376  );
377 
378  // same face type as surfMesh
380  (
381  move(mesh.storedPoints()),
382  move(mesh.storedFaces()),
383  move(mesh.storedZones())
384  );
385 
386  this->transcribe(surf);
387 }
388 
389 
390 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
391 
392 template<class Face>
394 {}
395 
396 
397 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
398 
399 template<class Face>
401 (
402  const labelUList& faceMap
403 )
404 {
405  // recalculate the zone start/size
406  if (notNull(faceMap) && faceMap.size())
407  {
408  surfZoneList& zones = storedZones();
409 
410  if (zones.size() == 1)
411  {
412  // optimised for single zone case
413  zones[0].size() = faceMap.size();
414  }
415  else if (zones.size())
416  {
417  label newFacei = 0;
418  label origEndI = 0;
419  forAll(zones, zoneI)
420  {
421  surfZone& zone = zones[zoneI];
422 
423  // adjust zone start
424  zone.start() = newFacei;
425  origEndI += zone.size();
426 
427  for (label facei = newFacei; facei < faceMap.size(); ++facei)
428  {
429  if (faceMap[facei] < origEndI)
430  {
431  ++newFacei;
432  }
433  else
434  {
435  break;
436  }
437  }
438 
439  // adjust zone size
440  zone.size() = newFacei - zone.start();
441  }
442  }
443  }
444 }
445 
446 
447 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
448 
449 template<class Face>
451 {
452  ParentType::clearOut();
453 
454  storedPoints().clear();
455  storedFaces().clear();
456  storedZones().clear();
457 }
458 
459 
460 template<class Face>
462 {
463  // Adapt for new point position
464  ParentType::clearGeom();
465 
466  // Copy new points
467  storedPoints() = newPoints;
468 }
469 
470 
471 template<class Face>
472 void Foam::MeshedSurface<Face>::scalePoints(const scalar scaleFactor)
473 {
474  // avoid bad scaling
475  if (scaleFactor > 0 && scaleFactor != 1.0)
476  {
477  pointField newPoints(scaleFactor*this->points());
478 
479  // Adapt for new point position
480  ParentType::clearGeom();
481 
482  storedPoints() = newPoints;
483  }
484 }
485 
486 
487 template<class Face>
489 (
490  pointField&& pointLst,
491  List<Face>&& faceLst,
492  surfZoneList&& zoneLst
493 )
494 {
495  ParentType::clearOut();
496 
497  // Take over new primitive data.
498  // Optimised to avoid overwriting data at all
499  if (notNull(pointLst))
500  {
501  storedPoints().transfer(pointLst);
502  }
503 
504  if (notNull(faceLst))
505  {
506  storedFaces().transfer(faceLst);
507  }
508 
509  if (notNull(zoneLst))
510  {
511  storedZones().transfer(zoneLst);
512  }
513 }
514 
515 
516 template<class Face>
518 (
519  List<point>&& pointLst,
520  List<Face>&& faceLst,
521  surfZoneList&& zoneLst
522 )
523 {
524  ParentType::clearOut();
525 
526  // Take over new primitive data.
527  // Optimised to avoid overwriting data at all
528  if (notNull(pointLst))
529  {
530  storedPoints().transfer(pointLst);
531  }
532 
533  if (notNull(faceLst))
534  {
535  storedFaces().transfer(faceLst);
536  }
537 
538  if (notNull(zoneLst))
539  {
540  storedZones().transfer(zoneLst);
541  }
542 }
543 
544 
545 // Remove badly degenerate faces, double faces.
546 template<class Face>
547 void Foam::MeshedSurface<Face>::cleanup(const bool verbose)
548 {
549  // merge points (already done for STL, TRI)
550  stitchFaces(small, verbose);
551 
552  checkFaces(verbose);
553  this->checkTopology(verbose);
554 }
555 
556 
557 template<class Face>
559 (
560  const scalar tol,
561  const bool verbose
562 )
563 {
564  pointField& pointLst = this->storedPoints();
565 
566  // Merge points
567  labelList pointMap(pointLst.size());
568  pointField newPoints(pointLst.size());
569 
570  bool hasMerged = mergePoints(pointLst, tol, verbose, pointMap, newPoints);
571 
572  if (!hasMerged)
573  {
574  return false;
575  }
576 
577  if (verbose)
578  {
579  InfoInFunction<< "Renumbering all faces" << endl;
580  }
581 
582  // Set the coordinates to the merged ones
583  pointLst.transfer(newPoints);
584 
585  List<Face>& faceLst = this->storedFaces();
586 
587  List<label> faceMap(faceLst.size());
588 
589  // Reset the point labels to the unique points array
590  label newFacei = 0;
591  forAll(faceLst, facei)
592  {
593  Face& f = faceLst[facei];
594  forAll(f, fp)
595  {
596  f[fp] = pointMap[f[fp]];
597  }
598 
599  // for extra safety: collapse face as well
600  if (f.collapse() >= 3)
601  {
602  if (newFacei != facei)
603  {
604  faceLst[newFacei] = f;
605  }
606  faceMap[newFacei] = facei;
607  newFacei++;
608  }
609  else if (verbose)
610  {
611  Pout<< "MeshedSurface::stitchFaces : "
612  << "Removing collapsed face " << facei << endl
613  << " vertices :" << f << endl;
614  }
615  }
616  pointMap.clear();
617 
618  if (newFacei != faceLst.size())
619  {
620  if (verbose)
621  {
622  Pout<< "MeshedSurface::stitchFaces : "
623  << "Removed " << faceLst.size() - newFacei
624  << " faces" << endl;
625  }
626  faceLst.setSize(newFacei);
627  faceMap.setSize(newFacei);
628  remapFaces(faceMap);
629  }
630  faceMap.clear();
631 
632  // Merging points might have changed geometric factors
633  ParentType::clearOut();
634  return true;
635 }
636 
637 
638 // Remove badly degenerate faces and double faces.
639 template<class Face>
641 (
642  const bool verbose
643 )
644 {
645  bool changed = false;
646  List<Face>& faceLst = this->storedFaces();
647 
648  List<label> faceMap(faceLst.size());
649 
650  label newFacei = 0;
651  // Detect badly labelled faces and mark degenerate faces
652  const label maxPointi = this->points().size() - 1;
653  forAll(faceLst, facei)
654  {
655  Face& f = faceLst[facei];
656 
657  // avoid degenerate faces
658  if (f.collapse() >= 3)
659  {
660  forAll(f, fp)
661  {
662  if (f[fp] < 0 || f[fp] > maxPointi)
663  {
665  << "face " << f
666  << " uses point indices outside point range 0.."
667  << maxPointi
668  << exit(FatalError);
669  }
670  }
671 
672  faceMap[facei] = facei;
673  newFacei++;
674  }
675  else
676  {
677  // mark as bad face
678  faceMap[facei] = -1;
679 
680  changed = true;
681  if (verbose)
682  {
684  << "face[" << facei << "] = " << f
685  << " does not have three unique vertices" << endl;
686  }
687  }
688  }
689 
690  // Detect doubled faces
691  // do not touch the faces
692  const labelListList& fFaces = this->faceFaces();
693  newFacei = 0;
694  forAll(faceLst, facei)
695  {
696  // skip already collapsed faces:
697  if (faceMap[facei] < 0)
698  {
699  continue;
700  }
701 
702  const Face& f = faceLst[facei];
703 
704  // duplicate face check
705  bool okay = true;
706  const labelList& neighbours = fFaces[facei];
707 
708  // Check if faceNeighbours use same points as this face.
709  // Note: discards normal information - sides of baffle are merged.
710  forAll(neighbours, neighI)
711  {
712  const label neiFacei = neighbours[neighI];
713 
714  if (neiFacei <= facei || faceMap[neiFacei] < 0)
715  {
716  // lower numbered faces already checked
717  // skip neighbours that are themselves collapsed
718  continue;
719  }
720 
721  const Face& nei = faceLst[neiFacei];
722 
723  if (f == nei)
724  {
725  okay = false;
726 
727  if (verbose)
728  {
730  << "faces share the same vertices:" << nl
731  << " face[" << facei << "] : " << f << nl
732  << " face[" << neiFacei << "] : " << nei << endl;
733  // printFace(Warning, " ", f, points());
734  // printFace(Warning, " ", nei, points());
735  }
736 
737  break;
738  }
739  }
740 
741  if (okay)
742  {
743  faceMap[facei] = facei;
744  newFacei++;
745  }
746  else
747  {
748  faceMap[facei] = -1;
749  }
750  }
751 
752  // Phase 1: pack
753  // Done to keep numbering constant in phase 1
754 
755  if (changed || newFacei < faceLst.size())
756  {
757  changed = true;
758 
759  if (verbose)
760  {
762  << "Removed " << faceLst.size() - newFacei
763  << " illegal faces." << endl;
764  }
765 
766  // compress the face list
767  newFacei = 0;
768  forAll(faceLst, facei)
769  {
770  if (faceMap[facei] >= 0)
771  {
772  if (newFacei != facei)
773  {
774  faceLst[newFacei] = faceLst[facei];
775  }
776  faceMap[newFacei] = facei;
777  newFacei++;
778  }
779  }
780 
781  faceLst.setSize(newFacei);
782  remapFaces(faceMap);
783  }
784  faceMap.clear();
785 
786  // Topology can change because of renumbering
787  ParentType::clearOut();
788  return changed;
789 }
790 
791 
792 template<class Face>
794 {
795  return triangulate
796  (
797  const_cast<List<label>&>(List<label>::null())
798  );
799 }
800 
801 
802 template<class Face>
804 (
805  List<label>& faceMapOut
806 )
807 {
808  label nTri = 0;
809  label maxTri = 0; // the maximum number of triangles for any single face
810  List<Face>& faceLst = this->storedFaces();
811 
812  // determine how many triangles will be needed
813  forAll(faceLst, facei)
814  {
815  const label n = faceLst[facei].nTriangles();
816  if (maxTri < n)
817  {
818  maxTri = n;
819  }
820  nTri += n;
821  }
822 
823  // nothing to do
824  if (nTri <= faceLst.size())
825  {
826  if (notNull(faceMapOut))
827  {
828  faceMapOut.clear();
829  }
830  return 0;
831  }
832 
833  List<Face> newFaces(nTri);
835 
836  // reuse storage from optional faceMap
837  if (notNull(faceMapOut))
838  {
839  faceMap.transfer(faceMapOut);
840  }
841  faceMap.setSize(nTri);
842 
843  // remember the number of *additional* faces
844  nTri -= faceLst.size();
845 
846  if (this->points().empty())
847  {
848  // triangulate without points
849  // simple face triangulation around f[0]
850  label newFacei = 0;
851  forAll(faceLst, facei)
852  {
853  const Face& f = faceLst[facei];
854 
855  for (label fp = 1; fp < f.size() - 1; ++fp)
856  {
857  label fp1 = f.fcIndex(fp);
858 
859  newFaces[newFacei] = triFace(f[0], f[fp], f[fp1]);
860  faceMap[newFacei] = facei;
861  newFacei++;
862  }
863  }
864  }
865  else
866  {
867  // triangulate with points
868  polygonTriangulate triEngine;
869 
870  label newFacei = 0;
871  forAll(faceLst, facei)
872  {
873  const face& f = faceLst[facei];
874 
875  triEngine.triangulate(UIndirectList<point>(this->points(), f));
876 
877  forAll(triEngine.triPoints(), triI)
878  {
879  newFaces[newFacei] = triEngine.triPoints(triI, f);
880  faceMap[newFacei] = facei;
881  newFacei++;
882  }
883  }
884  }
885 
886  faceLst.transfer(newFaces);
887  remapFaces(faceMap);
888 
889  // optionally return the faceMap
890  if (notNull(faceMapOut))
891  {
892  faceMapOut.transfer(faceMap);
893  }
894  faceMap.clear();
895 
896  // Topology can change because of renumbering
897  ParentType::clearOut();
898  return nTri;
899 }
900 
901 
902 
903 
904 template<class Face>
906 (
907  const labelHashSet& include,
908  labelList& pointMap,
909  labelList& faceMap
910 ) const
911 {
912  const pointField& locPoints = this->localPoints();
913  const List<Face>& locFaces = this->localFaces();
914 
915 
916  // Fill pointMap, faceMap
917  PatchTools::subsetMap(*this, include, pointMap, faceMap);
918 
919  // Create compact coordinate list and forward mapping array
920  pointField newPoints(pointMap.size());
921  labelList oldToNew(locPoints.size());
922  forAll(pointMap, pointi)
923  {
924  newPoints[pointi] = locPoints[pointMap[pointi]];
925  oldToNew[pointMap[pointi]] = pointi;
926  }
927 
928  // create/copy a new zones list, each zone with zero size
929  surfZoneList newZones(this->surfZones());
930  forAll(newZones, zoneI)
931  {
932  newZones[zoneI].size() = 0;
933  }
934 
935  // Renumber face node labels
936  List<Face> newFaces(faceMap.size());
937  forAll(faceMap, facei)
938  {
939  const label origFacei = faceMap[facei];
940  newFaces[facei] = Face(locFaces[origFacei]);
941 
942  // Renumber labels for face
943  Face& f = newFaces[facei];
944  forAll(f, fp)
945  {
946  f[fp] = oldToNew[f[fp]];
947  }
948  }
949  oldToNew.clear();
950 
951  // recalculate the zones start/size
952  label newFacei = 0;
953  label origEndI = 0;
954 
955  // adjust zone sizes
956  forAll(newZones, zoneI)
957  {
958  surfZone& zone = newZones[zoneI];
959 
960  // adjust zone start
961  zone.start() = newFacei;
962  origEndI += zone.size();
963 
964  for (label facei = newFacei; facei < faceMap.size(); ++facei)
965  {
966  if (faceMap[facei] < origEndI)
967  {
968  ++newFacei;
969  }
970  else
971  {
972  break;
973  }
974  }
975 
976  // adjust zone size
977  zone.size() = newFacei - zone.start();
978  }
979 
980 
981  // construct a sub-surface
982  return MeshedSurface
983  (
984  move(newPoints),
985  move(newFaces),
986  move(newZones)
987  );
988 }
989 
990 
991 template<class Face>
993 (
994  const labelHashSet& include
995 ) const
996 {
997  labelList pointMap, faceMap;
998  return subsetMesh(include, pointMap, faceMap);
999 }
1000 
1001 
1002 
1003 template<class Face>
1006  MeshedSurface<Face>& surf
1007 )
1008 {
1009  reset
1010  (
1011  move(surf.storedPoints()),
1012  move(surf.storedFaces()),
1013  move(surf.storedZones())
1014  );
1015 }
1016 
1017 
1018 template<class Face>
1022 )
1023 {
1024  clear();
1025 
1027  surfZoneList zoneLst = surf.sortedZones(faceMap);
1028 
1029  if (zoneLst.size() <= 1)
1030  {
1031  reset
1032  (
1033  move(surf.storedPoints()),
1034  move(surf.storedFaces()),
1035  surfZoneList()
1036  );
1037  }
1038  else
1039  {
1040  List<Face>& oldFaces = surf.storedFaces();
1041  List<Face> newFaces(faceMap.size());
1042 
1043  forAll(faceMap, facei)
1044  {
1045  newFaces[faceMap[facei]].transfer(oldFaces[facei]);
1046  }
1047 
1048  reset
1049  (
1050  move(surf.storedPoints()),
1051  move(newFaces),
1052  move(zoneLst)
1053  );
1054  }
1055 
1056  faceMap.clear();
1057  surf.clear();
1058 }
1059 
1060 
1061 // Read from file, determine format from extension
1062 template<class Face>
1064 {
1065  word ext = name.ext();
1066  if (ext == "gz")
1067  {
1068  fileName unzipName = name.lessExt();
1069  return read(unzipName, unzipName.ext());
1070  }
1071  else
1072  {
1073  return read(name, ext);
1074  }
1075 }
1076 
1077 
1078 // Read from file in given format
1079 template<class Face>
1082  const fileName& name,
1083  const word& ext
1084 )
1085 {
1086  clear();
1087 
1088  // read via selector mechanism
1089  transfer(New(name, ext)());
1090  return true;
1091 }
1092 
1093 
1094 template<class Face>
1097  const Time& t,
1098  const word& surfName
1099 ) const
1100 {
1101  MeshedSurfaceProxy<Face>(*this).write(t, surfName);
1102 }
1103 
1104 
1105 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
1106 
1107 template<class Face>
1109 {
1110  clear();
1111 
1112  this->storedPoints() = surf.points();
1113  this->storedFaces() = surf.faces();
1114  this->storedZones() = surf.surfZones();
1115 }
1116 
1117 
1118 template<class Face>
1120 {
1122  (
1123  this->points(),
1124  this->faces(),
1125  this->surfZones()
1126  );
1127 }
1128 
1129 
1130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
1131 
1132 #include "MeshedSurfaceZones.C"
1133 #include "MeshedSurfaceIO.C"
1134 #include "MeshedSurfaceNew.C"
1135 
1136 // ************************************************************************* //
bool read(const fileName &, const word &ext)
Read from file. Chooses reader based on explicit extension.
A surface geometry mesh, in which the surface zone information is conveyed by the &#39;zoneId&#39; associated...
Definition: MeshedSurface.H:74
virtual void clear()
Clear all storage.
A HashTable with keys but without contents.
Definition: HashSet.H:59
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
tUEqn clear()
const word & name() const
Return name.
A class for handling file names.
Definition: fileName.H:79
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:75
virtual ~MeshedSurface()
Destructor.
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
label nInternalFaces() const
surfZoneList & storedZones()
Non-const access to the zones.
Definition: surfMesh.H:108
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
label nFaces() const
A surface geometry mesh with zone information, not to be confused with the similarly named surfaceMes...
Definition: MeshedSurface.H:72
A surface zone on a MeshedSurface.
Definition: surfZone.H:62
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
static wordHashSet writeTypes()
Definition: MeshedSurface.C:56
List< face > faceList
Definition: faceListFwd.H:43
faceList & storedFaces()
Non-const access to the faces.
Definition: surfMesh.H:102
virtual void clear()
Clear all storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
label size() const
Return size of this zone in the face list.
Definition: surfZone.H:141
void transfer(MeshedSurface< Face > &)
Transfer the contents of the argument and annul the argument.
MeshedSurface subsetMesh(const labelHashSet &include, labelList &pointMap, labelList &faceMap) const
Return new surface.
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
fvMesh & mesh
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
surfZoneList & storedZones()
Non-const access to the zones.
word ext() const
Return file name extension (part after last .)
Definition: fileName.C:299
Macros for easy insertion into run-time selection tables.
label checkTopology(const polyMesh &, const bool, const bool, const autoPtr< surfaceWriter > &, const autoPtr< setWriter > &)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Various functions to operate on Lists.
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1211
A list of faces which address into the list of points.
A List obtained as a section of another List.
Definition: SubList.H:53
void operator=(const MeshedSurface< Face > &)
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
T clone(const T &t)
Definition: List.H:54
static wordHashSet readTypes()
Definition: MeshedSurface.C:49
const pointField & points
List< Face > & storedFaces()
Non-const access to the faces.
bool found(const Key &) const
Return true if hashedEntry is found in table.
Definition: HashTable.C:113
Base class for zones.
Definition: zone.H:57
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.H:125
static word timeName(const scalar, const int precision=curPrecision_)
Return time name of given scalar time.
Definition: Time.C:666
A class for handling words, derived from string.
Definition: word.H:59
face triFace(3)
virtual const faceList & faces() const
Return faces.
Definition: surfMesh.C:329
pointField & storedPoints()
Non-const access to global points.
virtual void cleanup(const bool verbose)
Remove invalid faces.
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
const Field< PointType > & points() const
Return reference to global points.
const polyMesh & mesh() const
Return the mesh reference.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
HashSet wordHashSet
A HashSet with word keys.
Definition: HashSet.H:208
virtual const faceList & faces() const
Return raw faces.
Definition: polyMesh.C:1224
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
static bool isTri()
Face storage only handles triangulated faces.
Definition: MeshedSurface.C:42
static void write(const fileName &, const MeshedSurface< Face > &)
Write to file.
static bool canWriteType(const word &ext, const bool verbose=false)
Can we write this file format?
Definition: MeshedSurface.C:83
Foam::polyBoundaryMesh.
A surface mesh consisting of general polygon faces.
Definition: surfMesh.H:55
virtual void reset(pointField &&points, List< Face > &&faces, surfZoneList &&zones)
Reset primitive data (points, faces and zones)
static const char nl
Definition: Ostream.H:260
A proxy for writing MeshedSurface, UnsortedMeshedSurface and surfMesh to various file formats...
Definition: MeshedSurface.H:73
Merge points. See below.
labelList f(nPoints)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
List< surfZone > surfZoneList
Definition: surfZoneList.H:45
const List< Face > & faces() const
Return const access to the faces.
virtual void scalePoints(const scalar)
Scale points. A non-positive factor is ignored.
surfZoneList sortedZones(labelList &faceMap) const
Sort faces according to zoneIds.
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
Definition: nullObjectI.H:52
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
void setSize(const label)
Reset size of List.
Definition: List.C:281
static void write(const fileName &, const MeshedSurfaceProxy< Face > &)
Write to file.
label start() const
Return start label of this zone in the face list.
Definition: surfZone.H:129
label patchi
virtual void remapFaces(const labelUList &faceMap)
Set new zones from faceMap.
#define WarningInFunction
Report a warning using Foam::Warning.
virtual const surfZoneList & surfZones() const
Return surface zones.
Definition: surfMesh.H:211
static bool canReadType(const word &ext, const bool verbose=false)
Can we read this file format?
Definition: MeshedSurface.C:66
Triangulation of three-dimensional polygons.
virtual bool checkFaces(const bool verbose=false)
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
const polyBoundaryMesh & bMesh
static bool canRead(const fileName &, const bool verbose=false)
Can we read this file format?
A List with indirect addressing.
Definition: fvMatrix.H:106
label mergePoints(const UList< Type > &points, const scalar mergeTol, const bool verbose, labelList &pointMap, const Type &origin=Type::zero)
Sorts and merges points. All points closer than/equal mergeTol get merged.
fileName lessExt() const
Return file name without extension (part before last .)
Definition: fileName.C:284
virtual bool stitchFaces(const scalar tol=small, const bool verbose=false)
pointField & storedPoints()
Non-const access to global points.
Definition: surfMesh.H:96
label n
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
virtual const pointField & points() const
Return points.
Definition: surfMesh.C:323
volScalarField & p
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
label size() const
Return the number of elements in the UList.
Definition: UListI.H:311
const UList< triFace > & triPoints() const
Get the triangles&#39; points.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Definition: List.C:342
virtual void movePoints(const pointField &)
Move points.
const List< surfZone > & surfZones() const
Const access to the surface zones.
MeshedSurface()
Construct null.
#define InfoInFunction
Report an information message using Foam::Info.