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-2022 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  if (zoneMapPtr_)
54  {
56  << "zone map already calculated"
57  << abort(FatalError);
58  }
59  else
60  {
61  // Count number of objects in all zones
62  label nObjects = 0;
63 
64  const PtrList<ZoneType>& zones = *this;
65 
66  for (const ZoneType& zn : zones)
67  {
68  nObjects += zn.size();
69  }
70 
71  zoneMapPtr_.reset(new Map<label>(2*nObjects));
72  auto& zm = *zoneMapPtr_;
73 
74  // Fill in objects of all zones into the map.
75  // The key is the global object index, value is the zone index
76 
77  label zonei = 0;
78 
79  for (const ZoneType& zn : zones)
80  {
81  const labelList& labels = zn;
82 
83  for (const label idx : labels)
84  {
85  zm.insert(idx, zonei);
86  }
87 
88  ++zonei;
89  }
90  }
91 }
92 
93 
94 template<class ZoneType, class MeshType>
96 {
97  if (groupIDsPtr_)
98  {
99  // Use existing cache
100  return !groupIDsPtr_->empty();
101  }
102 
103  const PtrList<ZoneType>& zones = *this;
104 
105  for (const ZoneType& zn : zones)
106  {
107  if (!zn.inGroups().empty())
108  {
109  return true;
110  }
111  }
112 
113  return false;
114 }
115 
116 
117 template<class ZoneType, class MeshType>
119 {
120  if (groupIDsPtr_)
121  {
122  return; // Or FatalError
123  }
124 
125  groupIDsPtr_.reset(new HashTable<labelList>(16));
126  auto& groupLookup = *groupIDsPtr_;
127 
128  const PtrList<ZoneType>& zones = *this;
129 
130  forAll(zones, zonei)
131  {
132  const wordList& groups = zones[zonei].inGroups();
133 
134  for (const word& groupName : groups)
135  {
136  groupLookup(groupName).append(zonei);
137  }
138  }
139 
140  // Remove groups that clash with zone names
141  forAll(zones, zonei)
142  {
143  if (groupLookup.erase(zones[zonei].name()))
144  {
146  << "Removed group '" << zones[zonei].name()
147  << "' which clashes with zone " << zonei
148  << " of the same name."
149  << endl;
150  }
151  }
152 }
153 
154 
155 template<class ZoneType, class MeshType>
157 {
158  if (isReadRequired() || (isReadOptional() && headerOk()))
159  {
160  // Warn for MUST_READ_IF_MODIFIED
161  warnNoRereading<ZoneMesh<ZoneType, MeshType>>();
162 
163  PtrList<ZoneType>& zones = *this;
164 
165  // Read zones as entries
166  Istream& is = readStream(typeName);
167 
168  PtrList<entry> patchEntries(is);
169  zones.resize(patchEntries.size());
170 
171  // Transcribe
172  forAll(zones, zonei)
173  {
174  zones.set
175  (
176  zonei,
178  (
179  patchEntries[zonei].keyword(),
180  patchEntries[zonei].dict(),
181  zonei,
182  *this
183  )
184  );
185  }
186 
187  is.check(FUNCTION_NAME);
188  close();
189  return true;
190  }
191 
192  // Nothing read
193  return false;
194 }
195 
196 
197 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
198 
199 template<class ZoneType, class MeshType>
201 (
202  const IOobject& io,
203  const MeshType& mesh
204 )
205 :
206  PtrList<ZoneType>(),
207  regIOobject(io),
208  mesh_(mesh)
209 {
210  readContents();
211 }
212 
213 
214 template<class ZoneType, class MeshType>
216 (
217  const IOobject& io,
218  const MeshType& mesh,
219  const label size
220 )
221 :
222  PtrList<ZoneType>(size),
223  regIOobject(io),
224  mesh_(mesh)
225 {
226  // Optionally read contents, otherwise keep size
227  readContents();
228 }
229 
230 
231 template<class ZoneType, class MeshType>
233 (
234  const IOobject& io,
235  const MeshType& mesh,
236  const PtrList<ZoneType>& pzm
237 )
238 :
239  PtrList<ZoneType>(),
240  regIOobject(io),
241  mesh_(mesh)
242 {
243  if (!readContents())
244  {
245  // Nothing read. Use supplied zones
246  PtrList<ZoneType>& zones = *this;
247  zones.resize(pzm.size());
248 
249  forAll(zones, zonei)
250  {
251  zones.set(zonei, pzm[zonei].clone(*this));
252  }
253  }
254 }
255 
256 
257 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
258 
259 template<class ZoneType, class MeshType>
261 {
262  clearAddressing();
263 }
264 
265 
266 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
267 
268 template<class ZoneType, class MeshType>
271 {
272  if (!zoneMapPtr_)
273  {
274  calcZoneMap();
275  }
277  return *zoneMapPtr_;
278 }
279 
280 
281 template<class ZoneType, class MeshType>
283 (
284  const label objectIndex
285 ) const
286 {
287  return zoneMap().lookup(objectIndex, -1);
288 }
289 
290 
291 template<class ZoneType, class MeshType>
293 {
294  return PtrListOps::get<word>(*this, typeOp<ZoneType>());
295 }
296 
297 
298 template<class ZoneType, class MeshType>
300 {
301  return PtrListOps::get<word>(*this, nameOp<ZoneType>());
302 }
303 
304 
305 template<class ZoneType, class MeshType>
307 {
308  return this->groupZoneIDs().sortedToc();
309 }
310 
311 
312 template<class ZoneType, class MeshType>
314 (
315  const wordRe& matcher
316 ) const
317 {
318  return PtrListOps::names(*this, matcher);
319 }
320 
321 
322 template<class ZoneType, class MeshType>
324 (
325  const wordRes& matcher
326 )
327 const
328 {
329  return PtrListOps::names(*this, matcher);
330 }
331 
332 
333 template<class ZoneType, class MeshType>
335 {
336  wordList sorted(this->names());
337  Foam::sort(sorted);
339  return sorted;
340 }
341 
342 
343 template<class ZoneType, class MeshType>
345 (
346  const wordRe& matcher
347 ) const
348 {
349  wordList sorted(this->names(matcher));
350  Foam::sort(sorted);
352  return sorted;
353 }
354 
355 
356 template<class ZoneType, class MeshType>
358 (
359  const wordRes& matcher
360 )
361 const
362 {
363  wordList sorted(this->names(matcher));
364  Foam::sort(sorted);
366  return sorted;
367 }
368 
369 
370 template<class ZoneType, class MeshType>
372 (
373  const wordRe& matcher,
374  const bool useGroups
375 ) const
376 {
377  if (matcher.empty())
378  {
379  return labelList();
380  }
381 
382  // Only check groups if requested and they exist
383  const bool checkGroups = (useGroups && this->hasGroupIDs());
384 
385  labelHashSet ids;
386 
387  if (checkGroups)
388  {
389  ids.resize(2*this->size());
390  }
391 
392  if (matcher.isPattern())
393  {
394  if (checkGroups)
395  {
396  const auto& groupLookup = groupZoneIDs();
397  forAllConstIters(groupLookup, iter)
398  {
399  if (matcher.match(iter.key()))
400  {
401  // Hash ids associated with the group
402  ids.insert(iter.val());
403  }
404  }
405  }
406 
407  if (ids.empty())
408  {
409  return PtrListOps::findMatching(*this, matcher);
410  }
411  else
412  {
413  ids.insert(PtrListOps::findMatching(*this, matcher));
414  }
415  }
416  else
417  {
418  // Literal string.
419  // Special version of above for reduced memory footprint
420 
421  const label zoneId = PtrListOps::firstMatching(*this, matcher);
422 
423  if (zoneId >= 0)
424  {
425  return labelList(one{}, zoneId);
426  }
427  else if (checkGroups)
428  {
429  const auto iter = groupZoneIDs().cfind(matcher);
430 
431  if (iter.found())
432  {
433  // Hash ids associated with the group
434  ids.insert(iter.val());
435  }
436  }
437  }
439  return ids.sortedToc();
440 }
441 
442 
443 template<class ZoneType, class MeshType>
445 (
446  const wordRes& matcher,
447  const bool useGroups
448 ) const
449 {
450  if (matcher.empty())
451  {
452  return labelList();
453  }
454  else if (matcher.size() == 1)
455  {
456  return this->indices(matcher.first(), useGroups);
457  }
458 
459  labelHashSet ids;
460 
461  // Only check groups if requested and they exist
462  if (useGroups && this->hasGroupIDs())
463  {
464  ids.resize(2*this->size());
465 
466  const auto& groupLookup = groupZoneIDs();
467  forAllConstIters(groupLookup, iter)
468  {
469  if (matcher.match(iter.key()))
470  {
471  // Hash the 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  }
486  return ids.sortedToc();
487 }
488 
489 
490 template<class ZoneType, class MeshType>
492 (
493  const wordRe& key
494 ) const
495 {
496  if (key.empty())
497  {
498  return -1;
499  }
500  return PtrListOps::firstMatching(*this, key);
501 }
502 
503 
504 template<class ZoneType, class MeshType>
506 (
507  const wordRes& matcher
508 ) const
509 {
510  if (matcher.empty())
511  {
512  return -1;
513  }
514  return PtrListOps::firstMatching(*this, matcher);
515 }
516 
517 
518 template<class ZoneType, class MeshType>
520 (
521  const word& zoneName
522 ) const
523 {
524  if (zoneName.empty())
525  {
526  return -1;
527  }
528 
529  label zoneId = PtrListOps::firstMatching(*this, zoneName);
530 
531  if (zoneId < 0)
532  {
534  << "Zone named " << zoneName << " not found. "
535  << "List of available zone names: " << names() << endl;
536 
537  // Used for -dry-run, for example
538  if (disallowGenericZones != 0)
539  {
540  auto& zm = const_cast<ZoneMesh<ZoneType, MeshType>&>(*this);
541  zoneId = zm.size();
542 
543  Info<< "Creating dummy zone " << zoneName << endl;
544  zm.append(new ZoneType(zoneName, zoneId, zm));
545  }
546  }
548  return zoneId;
549 }
550 
551 
552 template<class ZoneType, class MeshType>
554 (
555  const word& zoneName
556 ) const
557 {
558  if (zoneName.empty())
559  {
560  return nullptr;
561  }
562 
563  const PtrList<ZoneType>& zones = *this;
564 
565  for (auto iter = zones.begin(); iter != zones.end(); ++iter)
566  {
567  const ZoneType* ptr = iter.get();
568 
569  if (ptr && zoneName == ptr->name())
570  {
571  return ptr;
572  }
573  }
574 
575  // Used for -dry-run, for example
576  if (disallowGenericZones != 0)
577  {
578  auto& zm = const_cast<ZoneMesh<ZoneType, MeshType>&>(*this);
579 
580  Info<< "Creating dummy zone " << zoneName << endl;
581  zm.append(new ZoneType(zoneName, zm.size(), zm));
582  }
584  return nullptr;
585 }
586 
587 
588 template<class ZoneType, class MeshType>
590 (
591  const word& zoneName
592 )
593 {
594  return const_cast<ZoneType*>(this->cfindZone(zoneName));
595 }
596 
597 
598 template<class ZoneType, class MeshType>
600 (
601  const labelUList& zoneIds
602 ) const
603 {
604  bitSet bitset;
605 
606  for (const label zonei : zoneIds)
607  {
608  #ifdef FULLDEBUG
609  if (zonei < 0 || zonei >= this->size())
610  {
612  << ZoneType::typeName << " "
613  << zonei << " out of range [0," << this->size() << ")"
614  << abort(FatalError);
615  }
616  #endif
617 
618  bitset.set
619  (
620  static_cast<const labelList&>(this->operator[](zonei))
621  );
622  }
624  return bitset;
625 }
626 
627 
628 template<class ZoneType, class MeshType>
630 (
631  const wordRe& matcher,
632  const bool useGroups
633 ) const
634 {
635  // matcher.empty() is handled by indices()
636  return this->selection(this->indices(matcher, useGroups));
637 }
638 
639 
640 template<class ZoneType, class MeshType>
642 (
643  const wordRes& matcher,
644  const bool useGroups
645 ) const
646 {
647  // matcher.empty() is handled by indices()
648  return this->selection(this->indices(matcher, useGroups));
649 }
650 
651 
652 template<class ZoneType, class MeshType>
655 {
656  if (!groupIDsPtr_)
657  {
658  calcGroupIDs();
659  }
661  return *groupIDsPtr_;
662 }
663 
664 
665 template<class ZoneType, class MeshType>
667 (
668  const word& groupName,
669  const labelUList& zoneIDs
670 )
671 {
672  groupIDsPtr_.clear();
673 
674  PtrList<ZoneType>& zones = *this;
675 
676  boolList doneZone(zones.size(), false);
677 
678  // Add to specified zones
679  for (const label zonei : zoneIDs)
680  {
681  zones[zonei].inGroups().appendUniq(groupName);
682  doneZone[zonei] = true;
683  }
684 
685  // Remove from other zones
686  forAll(zones, zonei)
687  {
688  if (!doneZone[zonei])
689  {
690  wordList& groups = zones[zonei].inGroups();
691 
692  if (groups.found(groupName))
693  {
694  label newi = 0;
695  forAll(groups, i)
696  {
697  if (groups[i] != groupName)
698  {
699  groups[newi++] = groups[i];
700  }
701  }
702  groups.resize(newi);
703  }
704  }
705  }
706 }
707 
708 
709 template<class ZoneType, class MeshType>
711 {
712  zoneMapPtr_.clear();
713  groupIDsPtr_.clear();
714 
715  PtrList<ZoneType>& zones = *this;
716 
717  for (ZoneType& zn : zones)
718  {
719  zn.clearAddressing();
720  }
721 }
722 
723 
724 template<class ZoneType, class MeshType>
726 {
727  clearAddressing();
729 }
730 
731 
732 template<class ZoneType, class MeshType>
734 (
735  const bool report
736 ) const
737 {
738  bool hasError = false;
739 
740  const PtrList<ZoneType>& zones = *this;
741 
742  for (const ZoneType& zn : zones)
743  {
744  hasError |= zn.checkDefinition(report);
745  }
747  return hasError;
748 }
749 
750 
751 template<class ZoneType, class MeshType>
753 (
754  const bool report
755 ) const
756 {
757  if (!Pstream::parRun())
758  {
759  return false;
760  }
761 
762  const PtrList<ZoneType>& zones = *this;
763 
764  bool hasError = false;
765 
766  const wordList localNames(this->names());
767  const wordList localTypes(this->types());
768 
769  // Check and report error(s) on master
770  // - don't need indexing on master itself
771 
772  const globalIndex procAddr
773  (
774  globalIndex::gatherNonLocal{},
775  localNames.size()
776  );
777 
778  const wordList allNames(procAddr.gather(localNames));
779  const wordList allTypes(procAddr.gather(localTypes));
780 
781  // Automatically restricted to master
782  for (const int proci : procAddr.subProcs())
783  {
784  const auto procNames(allNames.slice(procAddr.range(proci)));
785  const auto procTypes(allTypes.slice(procAddr.range(proci)));
786 
787  if (procNames != localNames || procTypes != localTypes)
788  {
789  hasError = true;
790 
791  if (debug || report)
792  {
793  Info<< " ***Inconsistent zones across processors, "
794  "processor 0 has zone names:" << localNames
795  << " zone types:" << localTypes
796  << " processor " << proci
797  << " has zone names:" << procNames
798  << " zone types:" << procTypes
799  << endl;
800  }
801  }
802  }
803 
804  Pstream::broadcast(hasError);
805 
806  // Check local contents
807  if (!hasError)
808  {
809  for (const ZoneType& zn : zones)
810  {
811  if (zn.checkParallelSync(false))
812  {
813  hasError = true;
814 
815  if (debug || (report && Pstream::master()))
816  {
817  Info<< " ***Zone " << zn.name()
818  << " of type " << zn.type()
819  << " is not correctly synchronised"
820  << " across coupled boundaries."
821  << " (coupled faces are either not both"
822  << " present in set or have same flipmap)" << endl;
823  }
824  }
825  }
826  }
827 
828  return hasError;
829 }
830 
831 
832 template<class ZoneType, class MeshType>
834 {
835  PtrList<ZoneType>& zones = *this;
836 
837  for (ZoneType& zn : zones)
838  {
839  zn.movePoints(pts);
840  }
841 }
842 
843 
844 template<class ZoneType, class MeshType>
846 {
847  wordList zoneNames(this->names());
848  if (zoneNames.empty())
849  {
850  this->removeMetaData();
851  }
852  else
853  {
854  dictionary& meta = this->getMetaData();
855  meta.set("names", zoneNames);
856  }
857 }
858 
859 
860 template<class ZoneType, class MeshType>
862 {
863  os << *this;
864  return os.good();
865 }
866 
867 
868 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
869 
870 template<class ZoneType, class MeshType>
872 (
873  const word& zoneName
874 ) const
875 {
876  const label zonei = findZoneID(zoneName);
877 
878  if (zonei < 0)
879  {
881  << "Zone named " << zoneName << " not found." << nl
882  << "Available zone names: " << names() << endl
883  << abort(FatalError);
884  }
886  return operator[](zonei);
887 }
888 
889 
890 template<class ZoneType, class MeshType>
892 (
893  const word& zoneName
894 )
895 {
896  const label zonei = findZoneID(zoneName);
897 
898  if (zonei < 0)
899  {
901  << "Zone named " << zoneName << " not found." << nl
902  << "Available zone names: " << names() << endl
903  << abort(FatalError);
904  }
906  return operator[](zonei);
907 }
908 
909 
910 template<class ZoneType, class MeshType>
912 (
913  const word& zoneName,
914  const bool verbose
915 )
916 {
917  ZoneType* ptr = findZone(zoneName);
918 
919  const bool existing = bool(ptr);
920 
921  if (!ptr)
922  {
923  ptr = new ZoneType(zoneName, this->size(), *this);
924  this->append(ptr);
925  }
926 
927  if (verbose)
928  {
929  Info<< ZoneType::typeName << ' ' << zoneName
930  << " (" << (existing ? "existing" : "new")
931  << " at index " << ptr->index() << ')'
932  << endl;
933  }
934 
935  return *ptr;
936 }
937 
938 
939 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
940 
941 template<class ZoneType, class MeshType>
942 Foam::Ostream& Foam::operator<<
943 (
944  Ostream& os,
945  const ZoneMesh<ZoneType, MeshType>& zones
946 )
947 {
948  const label sz = zones.size();
949 
950  if (sz)
951  {
952  os << sz << nl << token::BEGIN_LIST;
953 
954  for (label i=0; i < sz; ++i)
955  {
956  zones[i].writeDict(os);
957  }
958 
959  os << token::END_LIST;
960  }
961  else
962  {
963  os << sz << token::BEGIN_LIST << token::END_LIST;
964  }
965 
966  return os;
967 }
968 
969 
970 // ************************************************************************* //
bool checkParallelSync(const bool report=false) const
Check whether all procs have all zones and in same order.
Definition: ZoneMesh.C:746
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:118
const labelIOList & zoneIDs
Definition: correctPhi.H:59
wordList types() const
Return a list of zone types.
Definition: ZoneMesh.C:285
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:703
ZoneType * findZone(const word &zoneName)
Find zone by name and return pointer, nullptr on error.
Definition: ZoneMesh.C:583
void set(const bitSet &bitset)
Set specified bits from another bitset.
Definition: bitSetI.H:583
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:718
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:120
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:578
void append(const T &val)
Append an element at the end of the list.
Definition: List.H:491
label findIndex(const wordRe &key) const
Zone index for the first match, return -1 if not found.
Definition: ZoneMesh.C:485
const Map< label > & zoneMap() const
Map of zones containing zone index for all zoned elements.
Definition: ZoneMesh.C:263
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
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 the UList is empty (ie, size() is zero)
Definition: UListI.H:420
T & first()
Access first element of the list, position [0].
Definition: UList.H:798
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
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:120
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
~ZoneMesh()
Destructor.
Definition: ZoneMesh.C:253
void movePoints(const pointField &pts)
Correct zone mesh after moving points.
Definition: ZoneMesh.C:826
void resize(const label sz)
Resize the hash table for efficiency.
Definition: HashTable.C:594
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:413
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
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
dynamicFvMesh & mesh
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) zone indices for all matches.
Definition: ZoneMesh.C:365
label findZoneID(const word &zoneName) const
Find zone index by name, return -1 if not found.
Definition: ZoneMesh.C:513
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:334
void setGroup(const word &groupName, const labelUList &zoneIDs)
Set/add group with zones.
Definition: ZoneMesh.C:660
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:99
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:47
patchWriters clear()
A HashTable similar to std::unordered_map.
Definition: HashTable.H:102
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:163
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:55
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:276
bool empty() const noexcept
True if the list is empty (ie, size() is zero)
Definition: UPtrListI.H:106
List< word > wordList
A List of words.
Definition: fileName.H:58
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
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:299
bool match(const std::string &text, bool literal=false) const
Smart match as literal or regex, stopping on the first match.
Definition: wordResI.H:84
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:69
bool checkDefinition(const bool report=false) const
Check zone definition. Return true if in error.
Definition: ZoneMesh.C:727
wordList names() const
A list of the zone names.
Definition: ZoneMesh.C:292
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:593
bool match(const std::string &text, bool literal=false) const
Smart match as regular expression or as a string.
Definition: wordReI.H:193
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
Definition: dictionary.C:777
wordList sortedNames() const
Sorted list of the zone names.
Definition: ZoneMesh.C:327
List< label > labelList
A List of labels.
Definition: List.H:62
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:166
static int disallowGenericZones
Debug switch to disallow the use of generic zones.
Definition: ZoneMesh.H:122
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:547
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:854
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:647
void updateMetaData()
Update internal meta-data (eg, prior to writing)
Definition: ZoneMesh.C:838
const pointField & pts