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