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