ZoneMesh.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-2023 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 "ZoneMesh.H"
30 #include "entry.H"
31 #include "DynamicList.H"
32 #include "Pstream.H"
33 #include "PtrListOps.H"
34 #include "globalIndex.H"
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  template<class ZoneType, class MeshType>
42  (
43  debug::debugSwitch("disallowGenericZones", 0)
44  );
45 }
46 
47 
48 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
49 
50 template<class ZoneType, class MeshType>
52 {
53  // Count number of objects in all zones
54  const PtrList<ZoneType>& zones = *this;
55 
56  label total = 0;
57  for (const ZoneType& zn : zones)
58  {
59  total += zn.size();
60  }
61 
62  return total;
63 }
64 
65 
66 template<class ZoneType, class MeshType>
68 {
69  if (zoneMapPtr_)
70  {
72  << "zone map already calculated"
73  << abort(FatalError);
74  }
75  else
76  {
77  zoneMapPtr_.reset(new Map<label>());
78  auto& map = *zoneMapPtr_;
79 
80  // Fill in objects of all zones into the map.
81  // The key is the global object index, value is the zone index
82 
83  map.reserve(this->totalSize());
84 
85  const PtrList<ZoneType>& zones = *this;
86  label zonei = 0;
87 
88  for (const ZoneType& zn : zones)
89  {
90  for (const label id : static_cast<const labelList&>(zn))
91  {
92  map.insert(id, zonei);
93  }
94 
95  ++zonei;
96  }
97  }
98 }
99 
100 
101 template<class ZoneType, class MeshType>
103 {
104  if (groupIDsPtr_)
105  {
106  // Use existing cache
107  return !groupIDsPtr_->empty();
108  }
109 
110  const PtrList<ZoneType>& zones = *this;
111 
112  for (const ZoneType& zn : zones)
113  {
114  if (!zn.inGroups().empty())
115  {
116  return true;
117  }
118  }
119 
120  return false;
121 }
122 
123 
124 template<class ZoneType, class MeshType>
126 {
127  if (groupIDsPtr_)
128  {
129  return; // Or FatalError
130  }
131 
132  groupIDsPtr_.reset(new HashTable<labelList>(16));
133  auto& groupLookup = *groupIDsPtr_;
134 
135  const PtrList<ZoneType>& zones = *this;
136 
137  forAll(zones, zonei)
138  {
139  for (const word& groupName : zones[zonei].inGroups())
140  {
141  groupLookup(groupName).push_back(zonei);
142  }
143  }
144 
145  // Remove groups that clash with zone names
146  forAll(zones, zonei)
147  {
148  if (groupLookup.erase(zones[zonei].name()))
149  {
151  << "Removed group '" << zones[zonei].name()
152  << "' which clashes with zone " << zonei
153  << " of the same name."
154  << endl;
155  }
156  }
157 }
158 
159 
160 template<class ZoneType, class MeshType>
162 (
163  PtrList<entry>&& entries
164 )
165 {
166  clearLocalAddressing();
167 
168  PtrList<ZoneType>& zones = *this;
169 
170  zones.resize_null(entries.size());
171 
172  // Transcribe
173  // Does not handle nullptr at all
174  forAll(zones, zonei)
175  {
176  // Possible handling for nullptr:
177  // zones.emplace_set
178  // (
179  // zonei,
180  // "missing_" + ::Foam::name(zonei), zonei, *this
181  // );
182 
183  zones.set
184  (
185  zonei,
187  (
188  entries[zonei].keyword(),
189  entries[zonei].dict(),
190  zonei,
191  *this
192  )
193  );
194  }
195 
196  entries.clear();
197 }
198 
199 
200 template<class ZoneType, class MeshType>
202 (
203  const bool allowOptionalRead
204 )
205 {
206  bool updated = false;
207  PtrList<entry> entries;
208 
209  if
210  (
211  isReadRequired()
212  || (allowOptionalRead && isReadOptional() && headerOk())
213  )
214  {
215  // Warn for MUST_READ_IF_MODIFIED
216  warnNoRereading<ZoneMesh<ZoneType, MeshType>>();
217 
218  // Read entries
219  Istream& is = readStream(typeName);
220 
221  is >> entries;
222 
223  is.check(FUNCTION_NAME);
224  close();
225  updated = true;
226  }
227 
228  // Future: support master-only and broadcast?
229 
230  if (updated)
231  {
232  populate(std::move(entries));
233  }
234 
235  return updated;
236 }
237 
238 
239 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
240 
241 template<class ZoneType, class MeshType>
243 (
244  const IOobject& io,
245  const MeshType& mesh
246 )
247 :
248  PtrList<ZoneType>(),
249  regIOobject(io),
250  mesh_(mesh)
251 {
252  // Note: this is inconsistent with polyBoundaryMesh
253  // which does not permit optional reading
254  readContents(true); // allowOptionalRead = true
255 }
256 
257 
258 template<class ZoneType, class MeshType>
260 (
261  const IOobject& io,
262  const MeshType& mesh,
263  Foam::zero
264 )
265 :
266  PtrList<ZoneType>(),
268  mesh_(mesh)
269 {}
270 
271 
272 template<class ZoneType, class MeshType>
274 (
275  const IOobject& io,
276  const MeshType& mesh,
277  const label size
278 )
279 :
280  PtrList<ZoneType>(size),
281  regIOobject(io),
282  mesh_(mesh)
283 {
284  // Note: this is inconsistent with polyBoundaryMesh
285  // which does not read all
286  readContents(true); // allowOptionalRead = true
287 }
288 
289 
290 template<class ZoneType, class MeshType>
292 (
293  const IOobject& io,
294  const MeshType& mesh,
295  const PtrList<ZoneType>& list
296 )
297 :
298  PtrList<ZoneType>(),
299  regIOobject(io),
300  mesh_(mesh)
301 {
302  if (!readContents(true)) // allowOptionalRead = true
303  {
304  // Nothing read. Use supplied zones
305  PtrList<ZoneType>& zones = *this;
306  zones.resize(list.size());
307 
308  forAll(zones, zonei)
309  {
310  zones.set(zonei, list[zonei].clone(*this));
311  }
312  }
313 }
314 
315 
316 template<class ZoneType, class MeshType>
318 (
319  const IOobject& io,
320  const MeshType& mesh,
321  PtrList<entry>&& entries
322 )
323 :
324  PtrList<ZoneType>(),
325  regIOobject(io),
326  mesh_(mesh)
327 {
328  if (!readContents(true)) // allowOptionalRead = true
329  {
330  populate(std::move(entries));
331  }
332  entries.clear();
333 }
334 
335 
336 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
337 
338 template<class ZoneType, class MeshType>
341 {
342  if (!zoneMapPtr_)
343  {
344  calcZoneMap();
345  }
347  return *zoneMapPtr_;
348 }
349 
350 
351 template<class ZoneType, class MeshType>
353 (
354  const label objectIndex
355 ) const
356 {
357  return zoneMap().lookup(objectIndex, -1);
358 }
359 
360 
361 template<class ZoneType, class MeshType>
363 {
364  return PtrListOps::get<word>(*this, typeOp<ZoneType>());
365 }
366 
367 
368 template<class ZoneType, class MeshType>
370 {
371  return PtrListOps::get<word>(*this, nameOp<ZoneType>());
372 }
373 
374 
375 template<class ZoneType, class MeshType>
377 {
378  return this->groupZoneIDs().sortedToc();
379 }
380 
381 
382 template<class ZoneType, class MeshType>
384 (
385  const wordRe& matcher
386 ) const
387 {
388  return PtrListOps::names(*this, matcher);
389 }
390 
391 
392 template<class ZoneType, class MeshType>
394 (
395  const wordRes& matcher
396 )
397 const
398 {
399  return PtrListOps::names(*this, matcher);
400 }
401 
402 
403 template<class ZoneType, class MeshType>
405 {
406  wordList sorted(this->names());
407  Foam::sort(sorted);
409  return sorted;
410 }
411 
412 
413 template<class ZoneType, class MeshType>
415 (
416  const wordRe& matcher
417 ) const
418 {
419  wordList sorted(this->names(matcher));
420  Foam::sort(sorted);
422  return sorted;
423 }
424 
425 
426 template<class ZoneType, class MeshType>
428 (
429  const wordRes& matcher
430 )
431 const
432 {
433  wordList sorted(this->names(matcher));
434  Foam::sort(sorted);
436  return sorted;
437 }
438 
439 
440 template<class ZoneType, class MeshType>
442 (
443  const wordRe& matcher,
444  const bool useGroups
445 ) const
446 {
447  if (matcher.empty())
448  {
449  return labelList();
450  }
451 
452  // Only check groups if requested and they exist
453  const bool checkGroups = (useGroups && this->hasGroupIDs());
454 
455  labelHashSet ids(0);
456 
457  if (checkGroups)
458  {
459  ids.reserve(this->size());
460  }
461 
462  if (matcher.isPattern())
463  {
464  if (checkGroups)
465  {
466  const auto& groupLookup = groupZoneIDs();
467  forAllConstIters(groupLookup, iter)
468  {
469  if (matcher(iter.key()))
470  {
471  // Hash ids associated with the group
472  ids.insert(iter.val());
473  }
474  }
475  }
476 
477  if (ids.empty())
478  {
479  return PtrListOps::findMatching(*this, matcher);
480  }
481  else
482  {
483  ids.insert(PtrListOps::findMatching(*this, matcher));
484  }
485  }
486  else
487  {
488  // Literal string.
489  // Special version of above for reduced memory footprint
490 
491  const label zoneId = PtrListOps::firstMatching(*this, matcher);
492 
493  if (zoneId >= 0)
494  {
495  return labelList(one{}, zoneId);
496  }
497  else if (checkGroups)
498  {
499  const auto iter = groupZoneIDs().cfind(matcher);
500 
501  if (iter.good())
502  {
503  // Hash ids associated with the group
504  ids.insert(iter.val());
505  }
506  }
507  }
509  return ids.sortedToc();
510 }
511 
512 
513 template<class ZoneType, class MeshType>
515 (
516  const wordRes& matcher,
517  const bool useGroups
518 ) const
519 {
520  if (matcher.empty())
521  {
522  return labelList();
523  }
524  else if (matcher.size() == 1)
525  {
526  return this->indices(matcher.front(), useGroups);
527  }
528 
529  labelHashSet ids(0);
530 
531  // Only check groups if requested and they exist
532  if (useGroups && this->hasGroupIDs())
533  {
534  ids.reserve(this->size());
535 
536  const auto& groupLookup = groupZoneIDs();
537  forAllConstIters(groupLookup, iter)
538  {
539  if (matcher(iter.key()))
540  {
541  // Hash the ids associated with the group
542  ids.insert(iter.val());
543  }
544  }
545  }
546 
547  if (ids.empty())
548  {
549  return PtrListOps::findMatching(*this, matcher);
550  }
551  else
552  {
553  ids.insert(PtrListOps::findMatching(*this, matcher));
554  }
556  return ids.sortedToc();
557 }
558 
559 
560 template<class ZoneType, class MeshType>
562 (
563  const wordRes& select,
564  const wordRes& ignore,
565  const bool useGroups
566 ) const
567 {
568  if (ignore.empty())
569  {
570  return this->indices(select, useGroups);
571  }
572 
573  const wordRes::filter matcher(select, ignore);
574 
575  labelHashSet ids(0);
576 
577  // Only check groups if requested and they exist
578  if (useGroups && this->hasGroupIDs())
579  {
580  ids.reserve(this->size());
581 
582  const auto& groupLookup = groupZoneIDs();
583  forAllConstIters(groupLookup, iter)
584  {
585  if (matcher(iter.key()))
586  {
587  // Add patch ids associated with the group
588  ids.insert(iter.val());
589  }
590  }
591  }
592 
593  if (ids.empty())
594  {
595  return PtrListOps::findMatching(*this, matcher);
596  }
597  else
598  {
599  ids.insert(PtrListOps::findMatching(*this, matcher));
600  }
602  return ids.sortedToc();
603 }
604 
605 
606 template<class ZoneType, class MeshType>
608 (
609  const wordRe& key
610 ) const
611 {
612  if (key.empty())
613  {
614  return -1;
615  }
616  return PtrListOps::firstMatching(*this, key);
617 }
618 
619 
620 template<class ZoneType, class MeshType>
622 (
623  const wordRes& matcher
624 ) const
625 {
626  if (matcher.empty())
627  {
628  return -1;
629  }
630  return PtrListOps::firstMatching(*this, matcher);
631 }
632 
633 
634 template<class ZoneType, class MeshType>
636 (
637  const word& zoneName
638 ) const
639 {
640  if (zoneName.empty())
641  {
642  return -1;
643  }
644 
645  label zoneId = PtrListOps::firstMatching(*this, zoneName);
646 
647  if (zoneId < 0)
648  {
650  << "Zone named " << zoneName << " not found. "
651  << "List of available zone names: " << names() << endl;
652 
653  // Used for -dry-run, for example
654  if (disallowGenericZones != 0)
655  {
656  Info<< "Creating dummy zone " << zoneName << endl;
657  auto& zm = const_cast<ZoneMesh<ZoneType, MeshType>&>(*this);
658  zm.emplace_back(zoneName, zm.size(), zm);
659  }
660  }
662  return zoneId;
663 }
664 
665 
666 template<class ZoneType, class MeshType>
668 (
669  const word& zoneName
670 ) const
671 {
672  if (zoneName.empty())
673  {
674  return nullptr;
675  }
676 
677  const PtrList<ZoneType>& zones = *this;
678 
679  for (auto iter = zones.begin(); iter != zones.end(); ++iter)
680  {
681  const ZoneType* ptr = iter.get();
682 
683  if (ptr && zoneName == ptr->name())
684  {
685  return ptr;
686  }
687  }
688 
689  // Used for -dry-run, for example
690  if (disallowGenericZones != 0)
691  {
692  Info<< "Creating dummy zone " << zoneName << endl;
693  auto& zm = const_cast<ZoneMesh<ZoneType, MeshType>&>(*this);
694  zm.emplace_back(zoneName, zm.size(), zm);
695  }
697  return nullptr;
698 }
699 
700 
701 template<class ZoneType, class MeshType>
703 (
704  const word& zoneName
705 )
706 {
707  return const_cast<ZoneType*>(this->cfindZone(zoneName));
708 }
709 
710 
711 template<class ZoneType, class MeshType>
713 (
714  const labelUList& zoneIds
715 ) const
716 {
717  bitSet bitset;
718 
719  for (const label zonei : zoneIds)
720  {
721  #ifdef FULLDEBUG
722  if (zonei < 0 || zonei >= this->size())
723  {
725  << ZoneType::typeName << " "
726  << zonei << " out of range [0," << this->size() << ")"
727  << abort(FatalError);
728  }
729  #endif
730 
731  bitset.set
732  (
733  static_cast<const labelList&>(this->operator[](zonei))
734  );
735  }
737  return bitset;
738 }
739 
740 
741 template<class ZoneType, class MeshType>
743 (
744  const wordRe& matcher,
745  const bool useGroups
746 ) const
747 {
748  // matcher.empty() is handled by indices()
749  return this->selection(this->indices(matcher, useGroups));
750 }
751 
752 
753 template<class ZoneType, class MeshType>
755 (
756  const wordRes& matcher,
757  const bool useGroups
758 ) const
759 {
760  // matcher.empty() is handled by indices()
761  return this->selection(this->indices(matcher, useGroups));
762 }
763 
764 
765 template<class ZoneType, class MeshType>
768 {
769  if (!groupIDsPtr_)
770  {
771  calcGroupIDs();
772  }
774  return *groupIDsPtr_;
775 }
776 
777 
778 template<class ZoneType, class MeshType>
780 (
781  const word& groupName,
782  const labelUList& zoneIDs
783 )
784 {
785  groupIDsPtr_.reset(nullptr);
786 
787  PtrList<ZoneType>& zones = *this;
788 
789  boolList pending(zones.size(), true);
790 
791  // Add to specified zones
792  for (const label zonei : zoneIDs)
793  {
794  if (pending.test(zonei))
795  {
796  pending.unset(zonei);
797  zones[zonei].addGroup(groupName);
798  }
799  }
800 
801  // Remove from other zones
802  forAll(zones, zonei)
803  {
804  if (pending.test(zonei))
805  {
806  zones[zonei].removeGroup(groupName);
807  }
808  }
809 }
810 
811 
812 // Private until it is more generally required (and gets a better name?)
813 template<class ZoneType, class MeshType>
815 {
816  zoneMapPtr_.reset(nullptr);
817  groupIDsPtr_.reset(nullptr);
818 }
819 
820 
821 template<class ZoneType, class MeshType>
823 {
824  clearLocalAddressing();
825 
826  PtrList<ZoneType>& zones = *this;
827 
828  for (ZoneType& zn : zones)
829  {
830  zn.clearAddressing();
831  }
832 }
833 
834 
835 template<class ZoneType, class MeshType>
837 {
838  PtrList<ZoneType>& zones = *this;
839 
840  for (ZoneType& zn : zones)
841  {
842  zn.clearPrimitives();
843  }
844 }
845 
846 
847 template<class ZoneType, class MeshType>
849 {
850  clearAddressing();
852 }
853 
854 
855 template<class ZoneType, class MeshType>
857 (
858  const bool report
859 ) const
860 {
861  bool hasError = false;
862 
863  const PtrList<ZoneType>& zones = *this;
864 
865  for (const ZoneType& zn : zones)
866  {
867  hasError |= zn.checkDefinition(report);
868  }
870  return hasError;
871 }
872 
873 
874 template<class ZoneType, class MeshType>
876 (
877  const bool report
878 ) const
879 {
880  if (!Pstream::parRun())
881  {
882  return false;
883  }
884 
885  const PtrList<ZoneType>& zones = *this;
886 
887  bool hasError = false;
888 
889  const wordList localNames(this->names());
890  const wordList localTypes(this->types());
891 
892  // Check and report error(s) on master
893  // - don't need indexing on master itself
894 
895  const globalIndex procAddr
896  (
897  globalIndex::gatherNonLocal{},
898  localNames.size()
899  );
900 
901  const wordList allNames(procAddr.gather(localNames));
902  const wordList allTypes(procAddr.gather(localTypes));
903 
904  // Automatically restricted to master
905  for (const int proci : procAddr.subProcs())
906  {
907  const auto procNames(allNames.slice(procAddr.range(proci)));
908  const auto procTypes(allTypes.slice(procAddr.range(proci)));
909 
910  if (procNames != localNames || procTypes != localTypes)
911  {
912  hasError = true;
913 
914  if (debug || report)
915  {
916  Info<< " ***Inconsistent zones across processors, "
917  "processor 0 has zone names:" << localNames
918  << " zone types:" << localTypes
919  << " processor " << proci
920  << " has zone names:" << procNames
921  << " zone types:" << procTypes
922  << endl;
923  }
924  }
925  }
926 
927  Pstream::broadcast(hasError);
928 
929  // Check local contents
930  if (!hasError)
931  {
932  for (const ZoneType& zn : zones)
933  {
934  if (zn.checkParallelSync(false))
935  {
936  hasError = true;
937 
938  if (debug || (report && Pstream::master()))
939  {
940  Info<< " ***Zone " << zn.name()
941  << " of type " << zn.type()
942  << " is not correctly synchronised"
943  << " across coupled boundaries."
944  << " (coupled faces are either not both"
945  << " present in set or have same flipmap)" << endl;
946  }
947  }
948  }
949  }
950 
951  return hasError;
952 }
953 
954 
955 template<class ZoneType, class MeshType>
957 {
958  PtrList<ZoneType>& zones = *this;
959 
960  for (ZoneType& zn : zones)
961  {
962  zn.movePoints(pts);
963  }
964 }
965 
966 
967 template<class ZoneType, class MeshType>
969 {
970  wordList zoneNames(this->names());
971  if (zoneNames.empty())
972  {
973  this->removeMetaData();
974  }
975  else
976  {
977  dictionary& meta = this->getMetaData();
978  meta.set("names", zoneNames);
979  }
980 }
981 
982 
983 template<class ZoneType, class MeshType>
985 {
986  os << *this;
987  return os.good();
988 }
989 
990 
991 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
992 
993 template<class ZoneType, class MeshType>
995 (
996  const word& zoneName
997 ) const
998 {
999  const label zonei = findZoneID(zoneName);
1000 
1001  if (zonei < 0)
1002  {
1004  << "Zone named " << zoneName << " not found." << nl
1005  << "Available zone names: " << names() << endl
1006  << abort(FatalError);
1007  }
1009  return operator[](zonei);
1010 }
1011 
1012 
1013 template<class ZoneType, class MeshType>
1015 (
1016  const word& zoneName
1017 )
1018 {
1019  const label zonei = findZoneID(zoneName);
1020 
1021  if (zonei < 0)
1022  {
1024  << "Zone named " << zoneName << " not found." << nl
1025  << "Available zone names: " << names() << endl
1026  << abort(FatalError);
1027  }
1029  return operator[](zonei);
1030 }
1031 
1032 
1033 template<class ZoneType, class MeshType>
1035 (
1036  const word& zoneName,
1037  const bool verbose
1038 )
1039 {
1040  ZoneType* ptr = findZone(zoneName);
1041 
1042  const bool existing = bool(ptr);
1043 
1044  if (!ptr)
1045  {
1046  ptr = new ZoneType(zoneName, this->size(), *this);
1047  this->push_back(ptr);
1048  }
1049 
1050  if (verbose)
1051  {
1052  Info<< ZoneType::typeName << ' ' << zoneName
1053  << " (" << (existing ? "existing" : "new")
1054  << " at index " << ptr->index() << ')'
1055  << endl;
1056  }
1057 
1058  return *ptr;
1059 }
1060 
1061 
1062 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
1063 
1064 template<class ZoneType, class MeshType>
1065 Foam::Ostream& Foam::operator<<
1066 (
1067  Ostream& os,
1068  const ZoneMesh<ZoneType, MeshType>& zones
1069 )
1070 {
1071  const label sz = zones.size();
1072 
1073  if (sz)
1074  {
1075  os << sz << nl << token::BEGIN_LIST;
1076 
1077  for (label i=0; i < sz; ++i)
1078  {
1079  zones[i].writeDict(os);
1080  }
1081 
1082  os << token::END_LIST;
1083  }
1084  else
1085  {
1086  os << sz << token::BEGIN_LIST << token::END_LIST;
1087  }
1088 
1089  return os;
1090 }
1091 
1092 
1093 // ************************************************************************* //
bool checkParallelSync(const bool report=false) const
Check whether all procs have all zones and in same order.
Definition: ZoneMesh.C:869
dictionary dict
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:796
const labelIOList & zoneIDs
Definition: correctPhi.H:59
wordList types() const
Return a list of zone types.
Definition: ZoneMesh.C:355
labelList findMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Extract list indices for all items with &#39;name()&#39; that matches.
void clearAddressing()
Clear addressing.
Definition: ZoneMesh.C:815
ZoneType * findZone(const word &zoneName)
Find zone by name and return pointer, nullptr on error.
Definition: ZoneMesh.C:696
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition: bitSetI.H:504
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
void clear()
Clear the zones.
Definition: ZoneMesh.C:841
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
label findIndex(const wordRe &key) const
Zone index for the first match, return -1 if not found.
Definition: ZoneMesh.C:601
const Map< label > & zoneMap() const
Map of zones containing zone index for all zoned elements.
Definition: ZoneMesh.C:333
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
Definition: BitOps.C:134
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
int debugSwitch(const char *name, const int deflt=0)
Lookup debug switch or add default value.
Definition: debug.C:222
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Definition: UList.H:666
T & front()
Access first element of the list, position [0].
Definition: UListI.H:237
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
A list of mesh zones.
Functions to operate on Pointer Lists.
const T * get(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
Definition: UPtrListI.H:134
void movePoints(const pointField &pts)
Correct zone mesh after moving points.
Definition: ZoneMesh.C:949
Extract name (as a word) from an object, typically using its name() method.
Definition: word.H:340
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
Definition: HashSet.H:85
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
dynamicFvMesh & mesh
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) zone indices for all matches.
Definition: ZoneMesh.C:435
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
Definition: ZoneMesh.C:629
friend Ostream & operator(Ostream &os, const ZoneMesh< ZoneType, MeshType > &zones)
A class for handling words, derived from Foam::string.
Definition: word.H:63
#define DebugInFunction
Report an information message using Foam::Info.
void sort(UList< T > &list)
Sort the list.
Definition: UList.C:296
void setGroup(const word &groupName, const labelUList &zoneIDs)
Set/add group with zones.
Definition: ZoneMesh.C:773
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:106
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
void clearPrimitives()
Clear primitive addressing.
Definition: ZoneMesh.C:829
patchWriters clear()
A HashTable similar to std::unordered_map.
Definition: HashTable.H:108
errorManip< error > abort(error &err)
Definition: errorManip.H:139
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
Definition: PtrList.H:159
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
Definition: wordRe.H:78
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
#define FUNCTION_NAME
void resize(const label newLen)
Adjust size of PtrList.
Definition: PtrList.C:95
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
Definition: ZoneMesh.C:346
ZoneMesh(const ZoneMesh &)=delete
No copy construct.
bool empty() const noexcept
True if the list is empty (ie, size() is zero)
Definition: UPtrListI.H:99
List< word > wordList
List of word.
Definition: fileName.H:59
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.
globalIndex procAddr(aMesh.nFaces())
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
Definition: foamGltfBase.H:103
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
wordList groupNames() const
A list of the zone group names (if any)
Definition: ZoneMesh.C:369
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:66
bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: ZoneMesh.C:850
wordList names() const
A list of the zone names.
Definition: ZoneMesh.C:362
messageStream Info
Information stream (stdout output on master, null elsewhere)
bitSet selection(const labelUList &zoneIds) const
Return all elements (cells, faces, points) contained in the listed zones.
Definition: ZoneMesh.C:706
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
Definition: dictionary.C:765
wordList sortedNames() const
Sorted list of the zone names.
Definition: ZoneMesh.C:397
List< label > labelList
A List of labels.
Definition: List.H:62
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
static int disallowGenericZones
Debug switch to disallow the use of generic zones.
Definition: ZoneMesh.H:136
bitSet bitset(const labelHashSet &locations)
Transform the on locations to a bitSet.
Definition: HashOps.C:63
const ZoneType * cfindZone(const word &zoneName) const
Find zone by name and return const pointer, nullptr on error.
Definition: ZoneMesh.C:661
bool isPattern() const noexcept
The wordRe is a pattern, not a literal string.
Definition: wordReI.H:104
bool writeData(Ostream &os) const
The writeData member function required by regIOobject.
Definition: ZoneMesh.C:977
Extract type (as a word) from an object, typically using its type() method.
Definition: word.H:361
Namespace for OpenFOAM.
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
label firstMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Find first list item with &#39;name()&#39; that matches, -1 on failure.
A HashTable to objects of type <T> with a label key.
const HashTable< labelList > & groupZoneIDs() const
The zone indices per zone group.
Definition: ZoneMesh.C:760
void updateMetaData()
Update internal meta-data (eg, prior to writing)
Definition: ZoneMesh.C:961
const pointField & pts