refinementHistory.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-2017 OpenFOAM Foundation
9  Copyright (C) 2015-2019 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 "refinementHistory.H"
30 #include "mapPolyMesh.H"
31 #include "mapDistributePolyMesh.H"
32 #include "polyMesh.H"
33 #include "syncTools.H"
34 #include "topoSet.H"
35 
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40  defineTypeNameAndDebug(refinementHistory, 0);
41 }
42 
43 
44 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
45 
46 void Foam::refinementHistory::writeEntry
47 (
48  const List<splitCell8>& splitCells,
49  const splitCell8& split
50 )
51 {
52  // Write me:
53  if (split.addedCellsPtr_.valid())
54  {
55  Pout<< "parent:" << split.parent_
56  << " subCells:" << split.addedCellsPtr_()
57  << endl;
58  }
59  else
60  {
61  Pout<< "parent:" << split.parent_
62  << " no subcells"
63  << endl;
64  }
65 
66  if (split.parent_ >= 0)
67  {
68  Pout<< "parent data:" << endl;
69  // Write my parent
70  string oldPrefix = Pout.prefix();
71  Pout.prefix() = " " + oldPrefix;
72  writeEntry(splitCells, splitCells[split.parent_]);
73  Pout.prefix() = oldPrefix;
74  }
75 }
76 
77 
79 (
80  const labelList& visibleCells,
81  const List<splitCell8>& splitCells
82 )
83 {
84  string oldPrefix = Pout.prefix();
85  Pout.prefix() = "";
86 
87  forAll(visibleCells, celli)
88  {
89  label index = visibleCells[celli];
90 
91  if (index >= 0)
92  {
93  Pout<< "Cell from refinement:" << celli << " index:" << index
94  << endl;
95 
96  string oldPrefix = Pout.prefix();
97  Pout.prefix() = " " + oldPrefix;
98  writeEntry(splitCells, splitCells[index]);
99  Pout.prefix() = oldPrefix;
100  }
101  else
102  {
103  Pout<< "Unrefined cell:" << celli << " index:" << index << endl;
104  }
105  }
106  Pout.prefix() = oldPrefix;
107 }
108 
109 
110 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
111 
113 :
114  parent_(-1),
115  addedCellsPtr_(nullptr)
116 {}
117 
118 
120 :
121  parent_(parent),
122  addedCellsPtr_(nullptr)
123 {}
124 
125 
127 {
128  is >> *this;
129 }
130 
131 
133 :
134  parent_(sc.parent_),
135  addedCellsPtr_
136  (
137  sc.addedCellsPtr_.valid()
138  ? new FixedList<label, 8>(sc.addedCellsPtr_())
139  : nullptr
140  )
141 {}
142 
143 
144 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
145 
147 {
148  // Assignment operator since autoPtr otherwise 'steals' storage.
149 
150  if (this == &s)
151  {
152  return; // Self-assignment is a no-op
153  }
154 
155  parent_ = s.parent_;
156 
157  addedCellsPtr_.reset
158  (
159  s.addedCellsPtr_.valid()
160  ? new FixedList<label, 8>(s.addedCellsPtr_())
161  : nullptr
162  );
163 }
164 
165 
167 {
168  if (addedCellsPtr_.valid() != s.addedCellsPtr_.valid())
169  {
170  return false;
171  }
172  else if (parent_ != s.parent_)
173  {
174  return false;
175  }
176  else if (addedCellsPtr_.valid())
177  {
178  return addedCellsPtr_() == s.addedCellsPtr_();
179  }
180 
181  return true;
182 }
183 
184 
186 {
187  return !operator==(s);
188 }
189 
190 
191 // * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
192 
194 {
195  labelList addedCells;
196 
197  is >> sc.parent_ >> addedCells;
198 
199  if (addedCells.size())
200  {
201  sc.addedCellsPtr_.reset(new FixedList<label, 8>(addedCells));
202  }
203  else
204  {
205  sc.addedCellsPtr_.reset(nullptr);
206  }
207 
208  return is;
209 }
210 
211 
212 Foam::Ostream& Foam::operator<<
213 (
214  Ostream& os,
216 )
217 {
218  // Output as labelList so we can have 0 sized lists. Alternative is to
219  // output as fixedlist with e.g. -1 elements and check for this upon
220  // reading. However would cause much more data to be transferred.
221 
222  if (sc.addedCellsPtr_.valid())
223  {
224  return os
225  << sc.parent_
226  << token::SPACE
227  << labelList(sc.addedCellsPtr_());
228  }
229  else
230  {
231  return os << sc.parent_ << token::SPACE << labelList(0);
232  }
233 }
234 
235 
236 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
237 
238 void Foam::refinementHistory::checkIndices() const
239 {
240  // Check indices.
241  forAll(visibleCells_, i)
242  {
243  if (visibleCells_[i] < 0 && visibleCells_[i] >= splitCells_.size())
244  {
246  << "Illegal entry " << visibleCells_[i]
247  << " in visibleCells at location" << i << nl
248  << "It points outside the range of splitCells : 0.."
249  << splitCells_.size()-1
250  << abort(FatalError);
251  }
252  }
253 }
254 
255 
256 Foam::label Foam::refinementHistory::allocateSplitCell
257 (
258  const label parent,
259  const label i
260 )
261 {
262  label index = -1;
263 
264  if (freeSplitCells_.size())
265  {
266  index = freeSplitCells_.remove();
267 
268  splitCells_[index] = splitCell8(parent);
269  }
270  else
271  {
272  index = splitCells_.size();
273 
274  splitCells_.append(splitCell8(parent));
275  }
276 
277 
278  // Update the parent field
279  if (parent >= 0)
280  {
281  splitCell8& parentSplit = splitCells_[parent];
282 
283  if (parentSplit.addedCellsPtr_.empty())
284  {
285  // Allocate storage on parent for the 8 subcells.
286  parentSplit.addedCellsPtr_.reset(new FixedList<label, 8>(-1));
287  }
288 
289 
290  // Store me on my parent
291  FixedList<label, 8>& parentSplits = parentSplit.addedCellsPtr_();
292 
293  parentSplits[i] = index;
294  }
295 
296  return index;
297 }
298 
299 
300 void Foam::refinementHistory::freeSplitCell(const label index)
301 {
302  splitCell8& split = splitCells_[index];
303 
304  // Make sure parent does not point to me anymore.
305  if (split.parent_ >= 0)
306  {
307  autoPtr<FixedList<label, 8>>& subCellsPtr =
308  splitCells_[split.parent_].addedCellsPtr_;
309 
310  if (subCellsPtr.valid())
311  {
312  FixedList<label, 8>& subCells = subCellsPtr();
313 
314  label myPos = subCells.find(index);
315 
316  if (myPos == -1)
317  {
319  << "Problem: cannot find myself in"
320  << " parents' children" << abort(FatalError);
321  }
322  else
323  {
324  subCells[myPos] = -1;
325  }
326  }
327  }
328 
329  // Mark splitCell as free
330  split.parent_ = -2;
331 
332  // Add to cache of free splitCells
333  freeSplitCells_.append(index);
334 }
335 
336 
337 void Foam::refinementHistory::markSplit
338 (
339  const label index,
340  labelList& oldToNew,
341  DynamicList<splitCell8>& newSplitCells
342 ) const
343 {
344  if (oldToNew[index] == -1)
345  {
346  // Not yet compacted.
347 
348  const splitCell8& split = splitCells_[index];
349 
350  oldToNew[index] = newSplitCells.size();
351  newSplitCells.append(split);
352 
353  if (split.parent_ >= 0)
354  {
355  markSplit(split.parent_, oldToNew, newSplitCells);
356  }
357  if (split.addedCellsPtr_.valid())
358  {
359  const FixedList<label, 8>& splits = split.addedCellsPtr_();
360 
361  forAll(splits, i)
362  {
363  if (splits[i] >= 0)
364  {
365  markSplit(splits[i], oldToNew, newSplitCells);
366  }
367  }
368  }
369  }
370 }
371 
372 
373 void Foam::refinementHistory::mark
374 (
375  const label val,
376  const label index,
377  labelList& splitToVal
378 ) const
379 {
380  splitToVal[index] = val;
381 
382  const splitCell8& split = splitCells_[index];
383 
384  if (split.addedCellsPtr_.valid())
385  {
386  const FixedList<label, 8>& splits = split.addedCellsPtr_();
387 
388  forAll(splits, i)
389  {
390  if (splits[i] >= 0)
391  {
392  mark(val, splits[i], splitToVal);
393  }
394  }
395  }
396 }
397 
398 
399 Foam::label Foam::refinementHistory::markCommonCells
400 (
401  labelList& cellToCluster
402 ) const
403 {
404  label clusterI = 0;
405 
406  labelList splitToCluster(splitCells_.size(), -1);
407 
408  // Pass1: find top of all clusters
409  forAll(visibleCells_, cellI)
410  {
411  label index = visibleCells_[cellI];
412 
413  if (index >= 0)
414  {
415  // Find highest ancestor
416  while (splitCells_[index].parent_ != -1)
417  {
418  index = splitCells_[index].parent_;
419  }
420 
421  // Mark tree with clusterI
422  if (splitToCluster[index] == -1)
423  {
424  mark(clusterI, index, splitToCluster);
425  clusterI++;
426  }
427  }
428  }
429 
430  // Pass2: mark all cells with cluster
431  cellToCluster.setSize(visibleCells_.size(), -1);
432 
433  forAll(visibleCells_, cellI)
434  {
435  label index = visibleCells_[cellI];
436 
437  if (index >= 0)
438  {
439  cellToCluster[cellI] = splitToCluster[index];
440  }
441  }
442 
443  return clusterI;
444 }
445 
446 
448 (
449  boolList& blockedFace,
450  PtrList<labelList>& specifiedProcessorFaces,
451  labelList& specifiedProcessor,
452  List<labelPair>& explicitConnections
453 ) const
454 {
455  const polyMesh& mesh = dynamic_cast<const polyMesh&>(db());
456 
457  blockedFace.setSize(mesh.nFaces(), true);
458 
459  // Find common parent for all cells
460  labelList cellToCluster;
461  markCommonCells(cellToCluster);
462 
463 
464  // Unblock all faces inbetween same cluster
465 
466  label nUnblocked = 0;
467 
468  forAll(mesh.faceNeighbour(), faceI)
469  {
470  label ownCluster = cellToCluster[mesh.faceOwner()[faceI]];
471  label neiCluster = cellToCluster[mesh.faceNeighbour()[faceI]];
472 
473  if (ownCluster != -1 && ownCluster == neiCluster)
474  {
475  if (blockedFace[faceI])
476  {
477  blockedFace[faceI] = false;
478  nUnblocked++;
479  }
480  }
481  }
482 
484  {
485  reduce(nUnblocked, sumOp<label>());
486  Info<< type() << " : unblocked " << nUnblocked << " faces" << endl;
487  }
488 
489  syncTools::syncFaceList(mesh, blockedFace, andEqOp<bool>());
490 }
491 
492 
494 (
495  const boolList& blockedFace,
496  const PtrList<labelList>& specifiedProcessorFaces,
497  const labelList& specifiedProcessor,
498  const List<labelPair>& explicitConnections,
499  labelList& decomposition
500 ) const
501 {
502  const polyMesh& mesh = dynamic_cast<const polyMesh&>(db());
503 
504  // Find common parent for all cells
505  labelList cellToCluster;
506  label nClusters = markCommonCells(cellToCluster);
507 
508  // Unblock all faces inbetween same cluster
509 
510 
511  labelList clusterToProc(nClusters, -1);
512 
513  label nChanged = 0;
514 
515  forAll(mesh.faceNeighbour(), faceI)
516  {
517  label own = mesh.faceOwner()[faceI];
518  label nei = mesh.faceNeighbour()[faceI];
519 
520  label ownCluster = cellToCluster[own];
521  label neiCluster = cellToCluster[nei];
522 
523  if (ownCluster != -1 && ownCluster == neiCluster)
524  {
525  if (clusterToProc[ownCluster] == -1)
526  {
527  clusterToProc[ownCluster] = decomposition[own];
528  }
529 
530  if (decomposition[own] != clusterToProc[ownCluster])
531  {
532  decomposition[own] = clusterToProc[ownCluster];
533  nChanged++;
534  }
535  if (decomposition[nei] != clusterToProc[ownCluster])
536  {
537  decomposition[nei] = clusterToProc[ownCluster];
538  nChanged++;
539  }
540  }
541  }
542 
544  {
545  reduce(nChanged, sumOp<label>());
546  Info<< type() << " : changed decomposition on " << nChanged
547  << " cells" << endl;
548  }
549 }
550 
551 
552 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
553 
555 :
556  regIOobject(io),
557  active_(false)
558 {
559  // Warn for MUST_READ_IF_MODIFIED
560  warnNoRereading<refinementHistory>();
561 
562  if
563  (
566  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
567  )
568  {
569  readStream(typeName) >> *this;
570  close();
571  }
572 
573  // When running in redistributePar + READ_IF_PRESENT it can happen
574  // that some processors do have refinementHistory and some don't so
575  // test for active has to be outside of above condition.
576  active_ = (returnReduce(visibleCells_.size(), sumOp<label>()) > 0);
577 
578  if (debug)
579  {
580  Pout<< "refinementHistory::refinementHistory :"
581  << " constructed history from IOobject :"
582  << " splitCells:" << splitCells_.size()
583  << " visibleCells:" << visibleCells_.size()
584  << " active:" << active_
585  << endl;
586  }
587 }
588 
589 
591 (
592  const IOobject& io,
593  const List<splitCell8>& splitCells,
594  const labelList& visibleCells,
595  const bool active
596 )
597 :
598  regIOobject(io),
599  active_(active),
600  splitCells_(splitCells),
601  freeSplitCells_(0),
602  visibleCells_(visibleCells)
603 {
604  // Warn for MUST_READ_IF_MODIFIED
605  warnNoRereading<refinementHistory>();
606 
607  if
608  (
611  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
612  )
613  {
614  readStream(typeName) >> *this;
615  close();
616  }
617 
618  // Check indices.
619  checkIndices();
620 
621  if (debug)
622  {
623  Pout<< "refinementHistory::refinementHistory :"
624  << " constructed history from IOobject or components :"
625  << " splitCells:" << splitCells_.size()
626  << " visibleCells:" << visibleCells_.size()
627  << " active:" << active_
628  << endl;
629  }
630 }
631 
632 
634 (
635  const IOobject& io,
636  const label nCells
637 )
638 :
639  regIOobject(io),
640  active_(false),
641  freeSplitCells_(0)
642 {
643  // Warn for MUST_READ_IF_MODIFIED
644  warnNoRereading<refinementHistory>();
645 
646  if
647  (
650  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
651  )
652  {
653  readStream(typeName) >> *this;
654  close();
655  }
656  else
657  {
658  visibleCells_.setSize(nCells);
659  splitCells_.setCapacity(nCells);
660 
661  for (label cellI = 0; cellI < nCells; cellI++)
662  {
663  visibleCells_[cellI] = cellI;
664  splitCells_.append(splitCell8());
665  }
666  }
667 
668  active_ = (returnReduce(visibleCells_.size(), sumOp<label>()) > 0);
669 
670 
671  // Check indices.
672  checkIndices();
673 
674  if (debug)
675  {
676  Pout<< "refinementHistory::refinementHistory :"
677  << " constructed history from IOobject or initial size :"
678  << " splitCells:" << splitCells_.size()
679  << " visibleCells:" << visibleCells_.size()
680  << " active:" << active_
681  << endl;
682  }
683 }
684 
685 
686 // Construct from initial number of cells (all visible)
688 (
689  const IOobject& io,
690  const label nCells,
691  const bool active
692 )
693 :
694  regIOobject(io),
695  active_(active),
696  freeSplitCells_(0)
697 {
698  // Warn for MUST_READ_IF_MODIFIED
699  warnNoRereading<refinementHistory>();
700 
701  if
702  (
705  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
706  )
707  {
708  readStream(typeName) >> *this;
709  close();
710  }
711  else
712  {
713  visibleCells_.setSize(nCells);
714  splitCells_.setCapacity(nCells);
715 
716  for (label celli = 0; celli < nCells; celli++)
717  {
718  visibleCells_[celli] = celli;
719  splitCells_.append(splitCell8());
720  }
721  }
722 
723  // Check indices.
724  checkIndices();
725 
726  if (debug)
727  {
728  Pout<< "refinementHistory::refinementHistory :"
729  << " constructed history from IOobject or initial size :"
730  << " splitCells:" << splitCells_.size()
731  << " visibleCells:" << visibleCells_.size()
732  << " active:" << active_
733  << endl;
734  }
735 }
736 
737 
739 (
740  const IOobject& io,
741  const refinementHistory& rh
742 )
743 :
744  regIOobject(io),
745  active_(rh.active_),
746  splitCells_(rh.splitCells()),
747  freeSplitCells_(rh.freeSplitCells()),
748  visibleCells_(rh.visibleCells())
749 {
750  if (debug)
751  {
752  Pout<< "refinementHistory::refinementHistory : constructed initial"
753  << " history." << endl;
754  }
755 }
756 
757 
759 (
760  const IOobject& io,
761  const UPtrList<const labelList>& cellMaps,
763 )
764 :
765  regIOobject(io),
766  active_(false)
767 {
768  if
769  (
772  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
773  )
774  {
776  << "read option IOobject::MUST_READ, READ_IF_PRESENT or "
777  << "MUST_READ_IF_MODIFIED"
778  << " suggests that a read constructor would be more appropriate."
779  << endl;
780  }
781 
782  const polyMesh& mesh = dynamic_cast<const polyMesh&>(db());
783 
784 
785  // Determine offsets into splitCells
786  labelList offsets(refs.size()+1);
787  offsets[0] = 0;
788  forAll(refs, refI)
789  {
790  const DynamicList<splitCell8>& subSplits = refs[refI].splitCells();
791  offsets[refI+1] = offsets[refI]+subSplits.size();
792  }
793 
794  // Construct merged splitCells
795  splitCells_.setSize(offsets.last());
796  forAll(refs, refI)
797  {
798  const DynamicList<splitCell8>& subSplits = refs[refI].splitCells();
799  forAll(subSplits, i)
800  {
801  splitCell8& newSplit = splitCells_[offsets[refI]+i];
802 
803  // Copy
804  newSplit = subSplits[i];
805 
806  // Offset indices
807  if (newSplit.parent_ >= 0)
808  {
809  newSplit.parent_ += offsets[refI];
810  }
811 
812  if (newSplit.addedCellsPtr_.valid())
813  {
814  FixedList<label, 8>& splits = newSplit.addedCellsPtr_();
815 
816  forAll(splits, i)
817  {
818  if (splits[i] >= 0)
819  {
820  splits[i] += offsets[refI];
821  }
822  }
823  }
824  }
825  }
826 
827 
828  // Construct merged visibleCells
829  visibleCells_.setSize(mesh.nCells(), -1);
830  forAll(refs, refI)
831  {
832  const labelList& cellMap = cellMaps[refI];
833  const labelList& subVis = refs[refI].visibleCells();
834 
835  forAll(subVis, i)
836  {
837  label& newVis = visibleCells_[cellMap[i]];
838 
839  newVis = subVis[i];
840  if (newVis >= 0)
841  {
842  newVis += offsets[refI];
843  }
844  }
845  }
846 
847 
848  // Is active if any of the refinementHistories is active (assumes active
849  // flag parallel synchronised)
850  active_ = false;
851  forAll(refs, refI)
852  {
853  if (refs[refI].active())
854  {
855  active_ = true;
856  break;
857  }
858  }
859 
860  // Check indices.
861  checkIndices();
862 
863  if (debug)
864  {
865  Pout<< "refinementHistory::refinementHistory :"
866  << " constructed history from multiple refinementHistories :"
867  << " splitCells:" << splitCells_.size()
868  << " visibleCells:" << visibleCells_.size()
869  << endl;
870  }
871 }
872 
873 
875 :
876  regIOobject(io),
877  splitCells_(is),
878  freeSplitCells_(0),
879  visibleCells_(is)
880 {
881  active_ = (returnReduce(visibleCells_.size(), sumOp<label>()) > 0);
882 
883  // Check indices.
884  checkIndices();
885 
886  if (debug)
887  {
888  Pout<< "refinementHistory::refinementHistory :"
889  << " constructed history from Istream"
890  << " splitCells:" << splitCells_.size()
891  << " visibleCells:" << visibleCells_.size()
892  << endl;
893  }
894 }
895 
896 
897 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
898 
900 (
901  const IOobject& io,
902  // Per visible cell the processor it is going to
903  const labelList& decomposition,
904  // Per splitCell entry the processor it moves to
905  const labelList& splitCellProc,
906  // Per splitCell entry the number of live cells that move to that processor
907  const labelList& splitCellNum,
908 
909  const label procI,
910 
911  // From old to new splitCells
912  labelList& oldToNewSplit
913 ) const
914 {
915  oldToNewSplit.setSize(splitCells_.size());
916  oldToNewSplit = -1;
917 
918  // Compacted splitCells
919  DynamicList<splitCell8> newSplitCells(splitCells_.size());
920 
921  // Loop over all entries. Note: could recurse like countProc so only
922  // visit used entries but is probably not worth it.
923 
924  forAll(splitCells_, index)
925  {
926  if (splitCellProc[index] == procI && splitCellNum[index] == 8)
927  {
928  // Entry moves in its whole to procI
929  oldToNewSplit[index] = newSplitCells.size();
930  newSplitCells.append(splitCells_[index]);
931  }
932  }
933 
934  // Add live cells that are subsetted.
935  forAll(visibleCells_, cellI)
936  {
937  label index = visibleCells_[cellI];
938 
939  if (index >= 0 && decomposition[cellI] == procI)
940  {
941  label parent = splitCells_[index].parent_;
942 
943  // Create new splitCell with parent
944  oldToNewSplit[index] = newSplitCells.size();
945  newSplitCells.append(splitCell8(parent));
946  }
947  }
948 
949  //forAll(oldToNewSplit, index)
950  //{
951  // Pout<< "old:" << index << " new:" << oldToNewSplit[index]
952  // << endl;
953  //}
954 
955  newSplitCells.shrink();
956 
957  // Renumber contents of newSplitCells
958  forAll(newSplitCells, index)
959  {
960  splitCell8& split = newSplitCells[index];
961 
962  if (split.parent_ >= 0)
963  {
964  split.parent_ = oldToNewSplit[split.parent_];
965  }
966  if (split.addedCellsPtr_.valid())
967  {
968  FixedList<label, 8>& splits = split.addedCellsPtr_();
969 
970  forAll(splits, i)
971  {
972  if (splits[i] >= 0)
973  {
974  splits[i] = oldToNewSplit[splits[i]];
975  }
976  }
977  }
978  }
979 
980 
981  // Count number of cells
982  label nSub = 0;
983  forAll(decomposition, cellI)
984  {
985  if (decomposition[cellI] == procI)
986  {
987  nSub++;
988  }
989  }
990 
991  labelList newVisibleCells(nSub);
992  nSub = 0;
993 
994  forAll(visibleCells_, cellI)
995  {
996  if (decomposition[cellI] == procI)
997  {
998  label index = visibleCells_[cellI];
999  if (index >= 0)
1000  {
1001  index = oldToNewSplit[index];
1002  }
1003  newVisibleCells[nSub++] = index;
1004  }
1005  }
1006 
1008  (
1009  new refinementHistory
1010  (
1011  io,
1012  newSplitCells,
1013  newVisibleCells,
1014  active_
1015  )
1016  );
1017 }
1018 
1019 
1022  const IOobject& io,
1023  const labelList& cellMap
1024 ) const
1025 {
1026  if (active_)
1027  {
1028  // Mark selected cells with '1'
1029  labelList decomposition(visibleCells_.size(), Zero);
1030  forAll(cellMap, i)
1031  {
1032  decomposition[cellMap[i]] = 1;
1033  }
1034 
1035 
1036  // Per splitCell entry the processor it moves to
1037  labelList splitCellProc(splitCells_.size(), -1);
1038  // Per splitCell entry the number of live cells that move to that
1039  // processor
1040  labelList splitCellNum(splitCells_.size(), Zero);
1041 
1042  forAll(visibleCells_, cellI)
1043  {
1044  label index = visibleCells_[cellI];
1045 
1046  if (index >= 0)
1047  {
1048  countProc
1049  (
1050  splitCells_[index].parent_,
1051  decomposition[cellI],
1052  splitCellProc,
1053  splitCellNum
1054  );
1055  }
1056  }
1057 
1058  labelList oldToNewSplit;
1059  return clone
1060  (
1061  io,
1062  decomposition,
1063  splitCellProc,
1064  splitCellNum,
1065  1, //procI,
1066  oldToNewSplit
1067  );
1068  }
1069  else
1070  {
1072  (
1073  new refinementHistory
1074  (
1075  io,
1077  labelList(0),
1078  false
1079  )
1080  );
1081  }
1082 }
1083 
1084 
1086 {
1087  label oldSize = visibleCells_.size();
1088 
1089  if (debug)
1090  {
1091  Pout<< "refinementHistory::resize from " << oldSize << " to " << size
1092  << " cells" << endl;
1093  }
1094 
1095  visibleCells_.setSize(size);
1096 
1097  // Set additional elements to -1.
1098  for (label i = oldSize; i < visibleCells_.size(); i++)
1099  {
1100  visibleCells_[i] = -1;
1101  }
1102 }
1103 
1104 
1106 {
1107  if (active())
1108  {
1109  const labelList& reverseCellMap = map.reverseCellMap();
1110 
1111  // Note that only the live cells need to be renumbered.
1112 
1113  labelList newVisibleCells(map.cellMap().size(), -1);
1114 
1115  forAll(visibleCells_, celli)
1116  {
1117  if (visibleCells_[celli] != -1)
1118  {
1119  label index = visibleCells_[celli];
1120 
1121  // Check not already set
1122  if (splitCells_[index].addedCellsPtr_.valid())
1123  {
1125  << "Problem" << abort(FatalError);
1126  }
1127 
1128  label newCelli = reverseCellMap[celli];
1129 
1130  if (newCelli >= 0)
1131  {
1132  newVisibleCells[newCelli] = index;
1133  }
1134  }
1135  }
1136 
1137  if (debug)
1138  {
1139  Pout<< "refinementHistory::updateMesh : from "
1140  << visibleCells_.size()
1141  << " to " << newVisibleCells.size()
1142  << " cells" << endl;
1143  }
1144 
1145  visibleCells_.transfer(newVisibleCells);
1146  }
1147 }
1148 
1149 
1152  const labelList& pointMap,
1153  const labelList& faceMap,
1154  const labelList& cellMap
1155 )
1156 {
1157  if (active())
1158  {
1159  labelList newVisibleCells(cellMap.size(), -1);
1160 
1161  forAll(newVisibleCells, celli)
1162  {
1163  label oldCelli = cellMap[celli];
1164 
1165  label index = visibleCells_[oldCelli];
1166 
1167  // Check that cell is live (so its parent has no refinement)
1168  if (index >= 0 && splitCells_[index].addedCellsPtr_.valid())
1169  {
1171  << "Problem" << abort(FatalError);
1172  }
1173 
1174  newVisibleCells[celli] = index;
1175  }
1176 
1177  if (debug)
1178  {
1179  Pout<< "refinementHistory::updateMesh : from "
1180  << visibleCells_.size()
1181  << " to " << newVisibleCells.size()
1182  << " cells" << endl;
1183  }
1184 
1185  visibleCells_.transfer(newVisibleCells);
1186  }
1187 }
1188 
1189 
1190 void Foam::refinementHistory::countProc
1191 (
1192  const label index,
1193  const label newProcNo,
1194  labelList& splitCellProc,
1195  labelList& splitCellNum
1196 ) const
1197 {
1198  if (splitCellProc[index] != newProcNo)
1199  {
1200  // Different destination processor from other cells using this
1201  // parent. Reset count.
1202  splitCellProc[index] = newProcNo;
1203  splitCellNum[index] = 1;
1204  }
1205  else
1206  {
1207  splitCellNum[index]++;
1208 
1209  // Increment parent if whole splitCell moves to same processor
1210  if (splitCellNum[index] == 8)
1211  {
1212  if (debug)
1213  {
1214  Pout<< "Moving " << splitCellNum[index]
1215  << " cells originating from cell " << index
1216  << " from processor " << Pstream::myProcNo()
1217  << " to processor " << splitCellProc[index]
1218  << endl;
1219  }
1220 
1221  label parent = splitCells_[index].parent_;
1222 
1223  if (parent >= 0)
1224  {
1225  countProc(parent, newProcNo, splitCellProc, splitCellNum);
1226  }
1227  }
1228  }
1229 }
1230 
1231 
1233 {
1234  if (!active())
1235  {
1237  << "Calling distribute on inactive history" << abort(FatalError);
1238  }
1239 
1240 
1241  if (!Pstream::parRun())
1242  {
1243  return;
1244  }
1245 
1246  // Remove unreferenced history.
1247  compact();
1248 
1249  //Pout<< nl << "--BEFORE:" << endl;
1250  //writeDebug();
1251  //Pout<< "---------" << nl << endl;
1252 
1253 
1254  // Distribution is only partially functional.
1255  // If all 8 cells resulting from a single parent are sent across in one
1256  // go it will also send across that part of the refinement history.
1257  // If however e.g. first 1 and then the other 7 are sent across the
1258  // history will not be reconstructed.
1259 
1260  // Determine clusters. This is per every entry in splitCells_ (that is
1261  // a parent of some refinement) a label giving the processor it goes to
1262  // if all its children are going to the same processor.
1263 
1264  // Per visible cell the processor it goes to.
1265  labelList destination(visibleCells_.size());
1266 
1267  const labelListList& subCellMap = map.cellMap().subMap();
1268 
1269  forAll(subCellMap, proci)
1270  {
1271  const labelList& newToOld = subCellMap[proci];
1272 
1273  forAll(newToOld, i)
1274  {
1275  label oldCelli = newToOld[i];
1276 
1277  destination[oldCelli] = proci;
1278  }
1279  }
1280 
1281  // Per splitCell entry the processor it moves to
1282  labelList splitCellProc(splitCells_.size(), -1);
1283  // Per splitCell entry the number of live cells that move to that processor
1284  labelList splitCellNum(splitCells_.size(), Zero);
1285 
1286  forAll(visibleCells_, celli)
1287  {
1288  label index = visibleCells_[celli];
1289 
1290  if (index >= 0)
1291  {
1292  countProc
1293  (
1294  splitCells_[index].parent_,
1295  destination[celli],
1296  splitCellProc,
1297  splitCellNum
1298  );
1299  }
1300  }
1301 
1302  //Pout<< "refinementHistory::distribute :"
1303  // << " splitCellProc:" << splitCellProc << endl;
1304  //
1305  //Pout<< "refinementHistory::distribute :"
1306  // << " splitCellNum:" << splitCellNum << endl;
1307 
1308 
1309  // Create subsetted refinement tree consisting of all parents that
1310  // move in their whole to other processor.
1311  for (label proci = 0; proci < Pstream::nProcs(); proci++)
1312  {
1313  //Pout<< "-- Subetting for processor " << proci << endl;
1314 
1315  // From uncompacted to compacted splitCells.
1316  labelList oldToNew(splitCells_.size(), -1);
1317 
1318  // Compacted splitCells. Similar to subset routine below.
1319  DynamicList<splitCell8> newSplitCells(splitCells_.size());
1320 
1321  // Loop over all entries. Note: could recurse like countProc so only
1322  // visit used entries but is probably not worth it.
1323 
1324  forAll(splitCells_, index)
1325  {
1326  if (splitCellProc[index] == proci && splitCellNum[index] == 8)
1327  {
1328  // Entry moves in its whole to proci
1329  oldToNew[index] = newSplitCells.size();
1330  newSplitCells.append(splitCells_[index]);
1331  }
1332  }
1333 
1334  // Add live cells that are subsetted.
1335  forAll(visibleCells_, celli)
1336  {
1337  label index = visibleCells_[celli];
1338 
1339  if (index >= 0 && destination[celli] == proci)
1340  {
1341  label parent = splitCells_[index].parent_;
1342 
1343  // Create new splitCell with parent
1344  oldToNew[index] = newSplitCells.size();
1345  newSplitCells.append(splitCell8(parent));
1346  }
1347  }
1348 
1349  //forAll(oldToNew, index)
1350  //{
1351  // Pout<< "old:" << index << " new:" << oldToNew[index]
1352  // << endl;
1353  //}
1354 
1355  newSplitCells.shrink();
1356 
1357  // Renumber contents of newSplitCells
1358  forAll(newSplitCells, index)
1359  {
1360  splitCell8& split = newSplitCells[index];
1361 
1362  if (split.parent_ >= 0)
1363  {
1364  split.parent_ = oldToNew[split.parent_];
1365  }
1366  if (split.addedCellsPtr_.valid())
1367  {
1368  FixedList<label, 8>& splits = split.addedCellsPtr_();
1369 
1370  forAll(splits, i)
1371  {
1372  if (splits[i] >= 0)
1373  {
1374  splits[i] = oldToNew[splits[i]];
1375  }
1376  }
1377  }
1378  }
1379 
1380 
1381  const labelList& subMap = subCellMap[proci];
1382 
1383  // New visible cells.
1384  labelList newVisibleCells(subMap.size(), -1);
1385 
1386  forAll(subMap, newCelli)
1387  {
1388  label oldCelli = subMap[newCelli];
1389 
1390  label oldIndex = visibleCells_[oldCelli];
1391 
1392  if (oldIndex >= 0)
1393  {
1394  newVisibleCells[newCelli] = oldToNew[oldIndex];
1395  }
1396  }
1397 
1398  //Pout<< nl << "--Subset for domain:" << proci << endl;
1399  //writeDebug(newVisibleCells, newSplitCells);
1400  //Pout<< "---------" << nl << endl;
1401 
1402 
1403  // Send to neighbours
1405  toNbr << newSplitCells << newVisibleCells;
1406  }
1407 
1408 
1409  // Receive from neighbours and merge
1410  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1411 
1412  // Remove all entries. Leave storage intact.
1413  splitCells_.clear();
1414 
1415  const polyMesh& mesh = dynamic_cast<const polyMesh&>(db());
1416 
1417  visibleCells_.setSize(mesh.nCells());
1418  visibleCells_ = -1;
1419 
1420  for (label proci = 0; proci < Pstream::nProcs(); proci++)
1421  {
1422  IPstream fromNbr(Pstream::commsTypes::blocking, proci);
1423  List<splitCell8> newSplitCells(fromNbr);
1424  labelList newVisibleCells(fromNbr);
1425 
1426  //Pout<< nl << "--Received from domain:" << proci << endl;
1427  //writeDebug(newVisibleCells, newSplitCells);
1428  //Pout<< "---------" << nl << endl;
1429 
1430 
1431  // newSplitCells contain indices only into newSplitCells so
1432  // renumbering can be done here.
1433  label offset = splitCells_.size();
1434 
1435  //Pout<< "**Renumbering data from proc " << proci << " with offset "
1436  // << offset << endl;
1437 
1438  forAll(newSplitCells, index)
1439  {
1440  splitCell8& split = newSplitCells[index];
1441 
1442  if (split.parent_ >= 0)
1443  {
1444  split.parent_ += offset;
1445  }
1446  if (split.addedCellsPtr_.valid())
1447  {
1448  FixedList<label, 8>& splits = split.addedCellsPtr_();
1449 
1450  forAll(splits, i)
1451  {
1452  if (splits[i] >= 0)
1453  {
1454  splits[i] += offset;
1455  }
1456  }
1457  }
1458 
1459  splitCells_.append(split);
1460  }
1461 
1462 
1463  // Combine visibleCell.
1464  const labelList& constructMap = map.cellMap().constructMap()[proci];
1465 
1466  forAll(newVisibleCells, i)
1467  {
1468  if (newVisibleCells[i] >= 0)
1469  {
1470  visibleCells_[constructMap[i]] = newVisibleCells[i] + offset;
1471  }
1472  }
1473  }
1474  splitCells_.shrink();
1475 
1476  //Pout<< nl << "--AFTER:" << endl;
1477  //writeDebug();
1478  //Pout<< "---------" << nl << endl;
1479 }
1480 
1481 
1483 {
1484  if (debug)
1485  {
1486  Pout<< "refinementHistory::compact() Entering with:"
1487  << " freeSplitCells_:" << freeSplitCells_.size()
1488  << " splitCells_:" << splitCells_.size()
1489  << " visibleCells_:" << visibleCells_.size()
1490  << endl;
1491 
1492  // Check all free splitCells are marked as such
1493  forAll(freeSplitCells_, i)
1494  {
1495  label index = freeSplitCells_[i];
1496 
1497  if (splitCells_[index].parent_ != -2)
1498  {
1500  << "Problem index:" << index
1501  << abort(FatalError);
1502  }
1503  }
1504 
1505  // Check none of the visible cells are marked as free
1506  forAll(visibleCells_, celli)
1507  {
1508  if
1509  (
1510  visibleCells_[celli] >= 0
1511  && splitCells_[visibleCells_[celli]].parent_ == -2
1512  )
1513  {
1515  << "Problem : visible cell:" << celli
1516  << " is marked as being free." << abort(FatalError);
1517  }
1518  }
1519  }
1520 
1521  DynamicList<splitCell8> newSplitCells(splitCells_.size());
1522 
1523  // From uncompacted to compacted splitCells.
1524  labelList oldToNew(splitCells_.size(), -1);
1525 
1526  // Mark all used splitCell entries. These are either indexed by visibleCells
1527  // or indexed from other splitCell entries.
1528 
1529  // Mark from visibleCells
1530  forAll(visibleCells_, celli)
1531  {
1532  label index = visibleCells_[celli];
1533 
1534  if (index >= 0)
1535  {
1536  // Make sure we only mark visible indices if they either have a
1537  // parent or subsplits.
1538  if
1539  (
1540  splitCells_[index].parent_ != -1
1541  || splitCells_[index].addedCellsPtr_.valid()
1542  )
1543  {
1544  markSplit(index, oldToNew, newSplitCells);
1545  }
1546  }
1547  }
1548 
1549  // Mark from splitCells
1550  forAll(splitCells_, index)
1551  {
1552  if (splitCells_[index].parent_ == -2)
1553  {
1554  // freed cell.
1555  }
1556  else if
1557  (
1558  splitCells_[index].parent_ == -1
1559  && splitCells_[index].addedCellsPtr_.empty()
1560  )
1561  {
1562  // recombined cell. No need to keep since no parent and no subsplits
1563  // Note that gets marked if reachable from other index!
1564  }
1565  else
1566  {
1567  // Is used element.
1568  markSplit(index, oldToNew, newSplitCells);
1569  }
1570  }
1571 
1572 
1573  // Now oldToNew is fully complete and compacted elements are in
1574  // newSplitCells.
1575  // Renumber contents of newSplitCells and visibleCells.
1576  forAll(newSplitCells, index)
1577  {
1578  splitCell8& split = newSplitCells[index];
1579 
1580  if (split.parent_ >= 0)
1581  {
1582  split.parent_ = oldToNew[split.parent_];
1583  }
1584  if (split.addedCellsPtr_.valid())
1585  {
1586  FixedList<label, 8>& splits = split.addedCellsPtr_();
1587 
1588  forAll(splits, i)
1589  {
1590  if (splits[i] >= 0)
1591  {
1592  splits[i] = oldToNew[splits[i]];
1593  }
1594  }
1595  }
1596  }
1597 
1598 
1599  if (debug)
1600  {
1601  Pout<< "refinementHistory::compact : compacted splitCells from "
1602  << splitCells_.size() << " to " << newSplitCells.size() << endl;
1603  }
1604 
1605  splitCells_.transfer(newSplitCells);
1606  freeSplitCells_.clearStorage();
1607 
1608 
1609  if (debug)
1610  {
1611  Pout<< "refinementHistory::compact() NOW:"
1612  << " freeSplitCells_:" << freeSplitCells_.size()
1613  << " splitCells_:" << splitCells_.size()
1614  << " newSplitCells:" << newSplitCells.size()
1615  << " visibleCells_:" << visibleCells_.size()
1616  << endl;
1617  }
1618 
1619 
1620  // Adapt indices in visibleCells_
1621  forAll(visibleCells_, celli)
1622  {
1623  label index = visibleCells_[celli];
1624 
1625  if (index >= 0)
1626  {
1627  // Note that oldToNew can be -1 so it resets newVisibleCells.
1628  visibleCells_[celli] = oldToNew[index];
1629  }
1630  else
1631  {
1632  // Keep -1 value.
1633  }
1634  }
1635 }
1636 
1637 
1639 {
1640  writeDebug(visibleCells_, splitCells_);
1641 }
1642 
1643 
1646  const label celli,
1647  const labelList& addedCells
1648 )
1649 {
1650  label parentIndex = -1;
1651 
1652  if (visibleCells_[celli] != -1)
1653  {
1654  // Was already live. The current live cell becomes the
1655  // parent of the cells split off from it.
1656 
1657  parentIndex = visibleCells_[celli];
1658 
1659  // It is no longer live (note that actually celli gets alive
1660  // again below since is addedCells[0])
1661  visibleCells_[celli] = -1;
1662  }
1663  else
1664  {
1665  // Create 0th level. -1 parent to denote this.
1666  parentIndex = allocateSplitCell(-1, -1);
1667  }
1668 
1669  // Create live entries for added cells that point to the
1670  // cell they were created from (parentIndex)
1671  forAll(addedCells, i)
1672  {
1673  label addedCelli = addedCells[i];
1674 
1675  // Create entries for the split off cells. All of them
1676  // are visible.
1677  visibleCells_[addedCelli] = allocateSplitCell(parentIndex, i);
1678  }
1679 }
1680 
1681 
1684  const label masterCelli,
1685  const labelList& combinedCells
1686 )
1687 {
1688  // Save the parent structure
1689  label parentIndex = splitCells_[visibleCells_[masterCelli]].parent_;
1690 
1691  // Remove the information for the combined cells
1692  forAll(combinedCells, i)
1693  {
1694  label celli = combinedCells[i];
1695 
1696  freeSplitCell(visibleCells_[celli]);
1697  visibleCells_[celli] = -1;
1698  }
1699 
1700  splitCell8& parentSplit = splitCells_[parentIndex];
1701  parentSplit.addedCellsPtr_.reset(nullptr);
1702  visibleCells_[masterCelli] = parentIndex;
1703 }
1704 
1705 
1707 {
1708  bool ok = readData(readStream(typeName));
1709  close();
1710 
1711  active_ = (returnReduce(visibleCells_.size(), sumOp<label>()) > 0);
1712 
1713  return ok;
1714 }
1715 
1716 
1718 {
1719  is >> *this;
1720  return !is.bad();
1721 }
1722 
1723 
1725 {
1726  os << *this;
1727 
1728  return os.good();
1729 }
1730 
1731 
1733 {
1734  IOobject io
1735  (
1736  "dummy",
1737  mesh.facesInstance(),
1738  mesh.meshSubDir,
1739  mesh
1740  );
1741  fileName setsDir(io.path());
1742 
1743  if (topoSet::debug) DebugVar(setsDir);
1744 
1745  if (exists(setsDir/typeName))
1746  {
1747  rm(setsDir/typeName);
1748  }
1749 }
1750 
1751 
1752 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
1753 
1755 {
1756  rh.freeSplitCells_.clearStorage();
1757 
1758  is >> rh.splitCells_ >> rh.visibleCells_;
1759 
1760  // Check indices.
1761  rh.checkIndices();
1762 
1763  return is;
1764 }
1765 
1766 
1768 {
1769  const_cast<refinementHistory&>(rh).compact();
1770 
1771  return os << "// splitCells" << nl
1772  << rh.splitCells_ << nl
1773  << "// visibleCells" << nl
1774  << rh.visibleCells_;
1775 }
1776 
1777 
1778 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:74
Foam::refinementHistory::visibleCells
const labelList & visibleCells() const
Per cell in the current mesh (i.e. visible) either -1 (unrefined)
Definition: refinementHistory.H:272
Foam::mapDistributeBase::subMap
const labelListList & subMap() const
From subsetted data back to original data.
Definition: mapDistributeBase.H:282
Foam::UPstream::commsTypes::blocking
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::refinementHistory::refinementHistory
refinementHistory(const IOobject &)
Construct (read) given an IOobject. If global number of visible.
Definition: refinementHistory.C:554
Foam::val
label ListType::const_reference val
Definition: ListOps.H:407
Foam::UPtrList::size
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:90
Foam::exists
bool exists(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
Definition: MSwindows.C:625
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:94
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::refinementHistory::apply
void apply(const boolList &blockedFace, const PtrList< labelList > &specifiedProcessorFaces, const labelList &specifiedProcessor, const List< labelPair > &explicitConnections, labelList &decomposition) const
Apply any additional post-decomposition constraints.
Definition: refinementHistory.C:494
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:94
s
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputSpray.H:25
Foam::refinementHistory::read
virtual bool read()
Read object. If global number of visible cells > 0 becomes active.
Definition: refinementHistory.C:1706
topoSet.H
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:57
Foam::OPstream
Output inter-processor communications stream.
Definition: OPstream.H:52
Foam::refinementHistory::storeSplit
void storeSplit(const label celli, const labelList &addedCells)
Store splitting of cell into 8.
Definition: refinementHistory.C:1645
Foam::refinementHistory::compact
void compact()
Compact splitCells_. Removes all freeSplitCells_ elements.
Definition: refinementHistory.C:1482
mapPolyMesh.H
Foam::UPstream::nProcs
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:426
Foam::polyMesh::meshSubDir
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:315
Foam::andEqOp
Definition: ops.H:85
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:414
Foam::polyMesh::facesInstance
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:821
Foam::rm
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
Definition: MSwindows.C:994
Foam::List::append
void append(const T &val)
Append an element at the end of the list.
Definition: ListI.H:182
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:228
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::Pout
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
Foam::refinementHistory::writeData
virtual bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
Definition: refinementHistory.C:1724
Foam::refinementHistory::splitCell8
Definition: refinementHistory.H:112
polyMesh.H
Foam::refinementHistory::splitCell8::parent_
label parent_
Definition: refinementHistory.H:119
syncTools.H
Foam::refinementHistory::splitCell8::operator==
bool operator==(const splitCell8 &s) const
Definition: refinementHistory.C:166
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::sumOp
Definition: ops.H:213
Foam::refinementHistory::freeSplitCells
const DynamicList< label > & freeSplitCells() const
Cache of unused indices in splitCells.
Definition: refinementHistory.H:284
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::mapDistributePolyMesh::cellMap
const mapDistribute & cellMap() const
Cell distribute map.
Definition: mapDistributePolyMesh.H:223
Foam::IOobject::db
const objectRegistry & db() const
Return the local objectRegistry.
Definition: IOobject.C:432
Foam::refinementHistory
All refinement history. Used in unrefinement.
Definition: refinementHistory.H:106
mapDistributePolyMesh.H
Foam::refinementHistory::splitCell8::splitCell8
splitCell8()
Construct null (parent = -1)
Definition: refinementHistory.C:112
Foam::refinementHistory::writeDebug
void writeDebug() const
Debug write.
Definition: refinementHistory.C:1638
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:51
Foam::syncTools::syncFaceList
static void syncFaceList(const polyMesh &mesh, UList< T > &faceValues, const CombineOp &cop)
Synchronize values on all mesh faces.
Definition: syncTools.H:390
Foam::refinementHistory::splitCell8::addedCellsPtr_
autoPtr< FixedList< label, 8 > > addedCellsPtr_
Cells this cell was refined into.
Definition: refinementHistory.H:122
Foam::primitiveMesh::nCells
label nCells() const
Number of mesh cells.
Definition: primitiveMeshI.H:96
Foam::label
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:62
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::DynamicList::append
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
Definition: DynamicListI.H:472
Foam::IOobject::READ_IF_PRESENT
Definition: IOobject.H:122
Foam::UPtrList
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:63
Foam::IOobject::clone
autoPtr< IOobject > clone() const
Clone.
Definition: IOobject.H:326
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:65
Foam::refinementHistory::splitCell8::operator!=
bool operator!=(const splitCell8 &s) const
Definition: refinementHistory.C:185
Foam::FatalError
error FatalError
Foam::IOstream::bad
bool bad() const
Return true if stream is corrupted.
Definition: IOstream.H:234
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::refinementHistory::resize
void resize(const label nCells)
Extend/shrink storage. additional visibleCells_ elements get.
Definition: refinementHistory.C:1085
Foam::FixedList::setSize
void setSize(const label n)
Dummy setSize function, to make FixedList consistent with List.
Definition: FixedListI.H:323
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::refinementHistory::removeFiles
static void removeFiles(const polyMesh &)
Helper: remove all sets files from mesh instance.
Definition: refinementHistory.C:1732
Foam::DynamicList::setSize
void setSize(const label nElem)
Alter addressable list size.
Definition: DynamicListI.H:282
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:444
Foam::refinementHistory::readData
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation. Note:
Definition: refinementHistory.C:1717
Foam::autoPtr< Foam::refinementHistory >
Foam::refinementHistory::combineCells
void combineCells(const label masterCelli, const labelList &combinedCells)
Store combining 8 cells into master.
Definition: refinementHistory.C:1683
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:67
Foam::mapPolyMesh::reverseCellMap
const labelList & reverseCellMap() const
Reverse cell map.
Definition: mapPolyMesh.H:531
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::refinementHistory::add
void add(boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Add my decomposition constraints.
Definition: refinementHistory.C:448
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::regIOobject::close
void close()
Close Istream.
Definition: regIOobjectRead.C:182
Foam::List< label >
Foam::IOobject::readOpt
readOption readOpt() const
The read option.
Definition: IOobjectI.H:141
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::FixedList
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:104
Foam::token::SPACE
Space [isspace].
Definition: token.H:112
Foam::DynamicList::clearStorage
void clearStorage()
Clear the list and delete storage.
Definition: DynamicListI.H:355
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:121
Foam::DynamicList::remove
T remove()
Remove and return the last element. Fatal on an empty list.
Definition: DynamicListI.H:651
Foam::refinementHistory::subset
void subset(const labelList &pointMap, const labelList &faceMap, const labelList &cellMap)
Update numbering for subsetting.
Definition: refinementHistory.C:1151
split
static bool split(const std::string &line, std::string &key, std::string &val)
Definition: cpuInfo.C:39
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:160
Foam::refinementHistory::splitCell8::operator=
void operator=(const splitCell8 &s)
Copy operator since autoPtr otherwise 'steals' storage.
Definition: refinementHistory.C:146
Foam::refinementHistory::splitCells
const DynamicList< splitCell8 > & splitCells() const
Storage for splitCell8s.
Definition: refinementHistory.H:278
Foam::refinementHistory::distribute
void distribute(const mapDistributePolyMesh &)
Update local numbering for mesh redistribution.
Definition: refinementHistory.C:1232
Foam::refinementHistory::updateMesh
void updateMesh(const mapPolyMesh &)
Update numbering for mesh changes.
Definition: refinementHistory.C:1105
Foam::IPstream
Input inter-processor communications stream.
Definition: IPstream.H:52
refinementHistory.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::regIOobject::readStream
Istream & readStream(const word &, const bool valid=true)
Return Istream and check object type against that given.
Definition: regIOobjectRead.C:140
Foam::mapDistributePolyMesh
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Definition: mapDistributePolyMesh.H:66
Foam::IOstream::good
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:216
Foam::List::setSize
void setSize(const label newSize)
Alias for resize(const label)
Definition: ListI.H:146
Foam::mapDistributeBase::constructMap
const labelListList & constructMap() const
From subsetted data to new reconstructed data.
Definition: mapDistributeBase.H:294
Foam::IOobject::path
fileName path() const
The complete path.
Definition: IOobject.C:456
DebugVar
#define DebugVar(var)
Report a variable name and value.
Definition: messageStream.H:372
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:294
Foam::prefixOSstream::prefix
const string & prefix() const
Return the stream prefix.
Definition: prefixOSstream.H:88
Foam::regIOobject::headerOk
bool headerOk()
Read and check header info.
Definition: regIOobject.C:449
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102
Foam::mapPolyMesh::cellMap
const labelList & cellMap() const
Old cell map.
Definition: mapPolyMesh.H:434
Foam::IOobject::MUST_READ
Definition: IOobject.H:120