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-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
41 //- Construct null
43 :
44  parent_(-1),
45  addedCellsPtr_(NULL)
46 {}
47 
48 
49 //- Construct as child element of parent
51 :
52  parent_(parent),
53  addedCellsPtr_(NULL)
54 {}
55 
56 
57 //- Construct from Istream
59 {
60  is >> *this;
61 }
62 
63 
64 //- Construct as (deep) copy.
66 :
67  parent_(sc.parent_),
68  addedCellsPtr_
69  (
70  sc.addedCellsPtr_.valid()
71  ? new FixedList<label, 8>(sc.addedCellsPtr_())
72  : NULL
73  )
74 {}
75 
76 
77 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
78 
79 //- Copy operator since autoPtr otherwise 'steals' storage.
81 {
82  // Check for assignment to self
83  if (this == &s)
84  {
86  << "Attempted assignment to self"
87  << abort(FatalError);
88  }
89 
90  parent_ = s.parent_;
91 
92  addedCellsPtr_.reset
93  (
94  s.addedCellsPtr_.valid()
95  ? new FixedList<label, 8>(s.addedCellsPtr_())
96  : NULL
97  );
98 }
99 
100 
102 {
103  if (addedCellsPtr_.valid() != s.addedCellsPtr_.valid())
104  {
105  return false;
106  }
107  else if (parent_ != s.parent_)
108  {
109  return false;
110  }
111  else if (addedCellsPtr_.valid())
112  {
113  return addedCellsPtr_() == s.addedCellsPtr_();
114  }
115  else
116  {
117  return true;
118  }
119 }
120 
121 
123 {
124  return !operator==(s);
125 }
126 
127 
128 // * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
129 
131 {
132  labelList addedCells;
133 
134  is >> sc.parent_ >> addedCells;
135 
136  if (addedCells.size())
137  {
138  sc.addedCellsPtr_.reset(new FixedList<label, 8>(addedCells));
139  }
140  else
141  {
142  sc.addedCellsPtr_.reset(NULL);
143  }
144 
145  return is;
146 }
147 
148 
149 Foam::Ostream& Foam::operator<<
150 (
151  Ostream& os,
152  const refinementHistory::splitCell8& sc
153 )
154 {
155  // Output as labelList so we can have 0 sized lists. Alternative is to
156  // output as fixedlist with e.g. -1 elements and check for this upon
157  // reading. However would cause much more data to be transferred.
158 
159  if (sc.addedCellsPtr_.valid())
160  {
161  return os
162  << sc.parent_
163  << token::SPACE
164  << labelList(sc.addedCellsPtr_());
165  }
166  else
167  {
168  return os << sc.parent_ << token::SPACE << labelList(0);
169  }
170 }
171 
172 
173 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
174 
176 (
178  const splitCell8& split
179 )
180 {
181  // Write me:
182  if (split.addedCellsPtr_.valid())
183  {
184  Pout<< "parent:" << split.parent_
185  << " subCells:" << split.addedCellsPtr_()
186  << endl;
187  }
188  else
189  {
190  Pout<< "parent:" << split.parent_
191  << " no subcells"
192  << endl;
193  }
194 
195  if (split.parent_ >= 0)
196  {
197  Pout<< "parent data:" << endl;
198  // Write my parent
199  string oldPrefix = Pout.prefix();
200  Pout.prefix() = " " + oldPrefix;
202  Pout.prefix() = oldPrefix;
203  }
204 }
205 
206 
208 (
209  const labelList& visibleCells,
211 )
212 {
213  string oldPrefix = Pout.prefix();
214  Pout.prefix() = "";
215 
216  forAll(visibleCells, cellI)
217  {
218  label index = visibleCells[cellI];
219 
220  if (index >= 0)
221  {
222  Pout<< "Cell from refinement:" << cellI << " index:" << index
223  << endl;
224 
225  string oldPrefix = Pout.prefix();
226  Pout.prefix() = " " + oldPrefix;
228  Pout.prefix() = oldPrefix;
229  }
230  else
231  {
232  Pout<< "Unrefined cell:" << cellI << " index:" << index << endl;
233  }
234  }
235  Pout.prefix() = oldPrefix;
236 }
237 
238 
240 {
241  // Check indices.
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 
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 
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.
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
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 
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  refCount(),
561  active_(false)
562 {
563  // Temporary warning
565  {
567  << "Specified IOobject::MUST_READ_IF_MODIFIED but class"
568  << " does not support automatic rereading."
569  << endl;
570  }
571 
572  if
573  (
576  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
577  )
578  {
579  readStream(typeName) >> *this;
580  close();
581  }
582 
583  // When running in redistributPar + READ_IF_PRESENT it can happen
584  // that some processors do have refinementHistory and some don't so
585  // test for active has to be outside of above condition.
587 
588  if (debug)
589  {
590  Pout<< "refinementHistory::refinementHistory :"
591  << " constructed history from IOobject :"
592  << " splitCells:" << splitCells_.size()
593  << " visibleCells:" << visibleCells_.size()
594  << endl;
595  }
596 }
597 
598 
599 //- Read or construct
601 (
602  const IOobject& io,
603  const List<splitCell8>& splitCells,
604  const labelList& visibleCells,
605  const bool active
606 )
607 :
608  regIOobject(io),
609  refCount(),
610  active_(active),
611  splitCells_(splitCells),
612  freeSplitCells_(0),
613  visibleCells_(visibleCells)
614 {
615  // Temporary warning
617  {
619  << "Specified IOobject::MUST_READ_IF_MODIFIED but class"
620  << " does not support automatic rereading."
621  << endl;
622  }
623 
624  if
625  (
628  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
629  )
630  {
631  readStream(typeName) >> *this;
632  close();
633  }
634 
635  // Check indices.
636  checkIndices();
637 
638  if (debug)
639  {
640  Pout<< "refinementHistory::refinementHistory :"
641  << " constructed history from IOobject or components :"
642  << " splitCells:" << splitCells_.size()
643  << " visibleCells:" << visibleCells_.size()
644  << endl;
645  }
646 }
647 
648 
649 // Construct from initial number of cells (all visible)
651 (
652  const IOobject& io,
653  const label nCells
654 )
655 :
656  regIOobject(io),
657  refCount(),
658  active_(false),
659  freeSplitCells_(0)
660 {
661  // Temporary warning
663  {
665  << "Specified IOobject::MUST_READ_IF_MODIFIED but class"
666  << " does not support automatic rereading."
667  << endl;
668  }
669 
670  if
671  (
674  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
675  )
676  {
677  readStream(typeName) >> *this;
678  close();
679  }
680  else
681  {
682  visibleCells_.setSize(nCells);
683  splitCells_.setCapacity(nCells);
684 
685  for (label cellI = 0; cellI < nCells; cellI++)
686  {
687  visibleCells_[cellI] = cellI;
688  splitCells_.append(splitCell8());
689  }
690  }
691 
692  active_ = (returnReduce(visibleCells_.size(), sumOp<label>()) > 0);
693 
694 
695  // Check indices.
696  checkIndices();
697 
698  if (debug)
699  {
700  Pout<< "refinementHistory::refinementHistory :"
701  << " constructed history from IOobject or initial size :"
702  << " splitCells:" << splitCells_.size()
703  << " visibleCells:" << visibleCells_.size()
704  << endl;
705  }
706 }
707 
708 
709 // Construct from initial number of cells (all visible)
711 (
712  const IOobject& io,
713  const label nCells,
714  const bool active
715 )
716 :
717  regIOobject(io),
718  refCount(),
719  active_(active),
720  freeSplitCells_(0)
721 {
722  // Temporary warning
724  {
726  << "Specified IOobject::MUST_READ_IF_MODIFIED but class"
727  << " does not support automatic rereading."
728  << endl;
729  }
730 
731  if
732  (
735  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
736  )
737  {
738  readStream(typeName) >> *this;
739  close();
740  }
741  else
742  {
743  visibleCells_.setSize(nCells);
744  splitCells_.setCapacity(nCells);
745 
746  for (label cellI = 0; cellI < nCells; cellI++)
747  {
748  visibleCells_[cellI] = cellI;
749  splitCells_.append(splitCell8());
750  }
751  }
752 
753  // Check indices.
754  checkIndices();
755 
756  if (debug)
757  {
758  Pout<< "refinementHistory::refinementHistory :"
759  << " constructed history from IOobject or initial size :"
760  << " splitCells:" << splitCells_.size()
761  << " visibleCells:" << visibleCells_.size()
762  << endl;
763  }
764 }
765 
766 
767 // Construct as copy
769 (
770  const IOobject& io,
771  const refinementHistory& rh
772 )
773 :
774  regIOobject(io),
775  refCount(),
776  active_(rh.active_),
777  splitCells_(rh.splitCells()),
778  freeSplitCells_(rh.freeSplitCells()),
779  visibleCells_(rh.visibleCells())
780 {
781  if (debug)
782  {
783  Pout<< "refinementHistory::refinementHistory : constructed initial"
784  << " history." << endl;
785  }
786 }
787 
788 
789 // Construct from multiple
791 (
792  const IOobject& io,
793  const UPtrList<const labelList>& cellMaps,
795 )
796 :
797  regIOobject(io),
798  refCount(),
799  active_(false)
800 {
801  if
802  (
805  || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
806  )
807  {
809  << "read option IOobject::MUST_READ, READ_IF_PRESENT or "
810  << "MUST_READ_IF_MODIFIED"
811  << " suggests that a read constructor would be more appropriate."
812  << endl;
813  }
814 
815  const polyMesh& mesh = dynamic_cast<const polyMesh&>(db());
816 
817 
818  // Determine offsets into splitCells
819  labelList offsets(refs.size()+1);
820  offsets[0] = 0;
821  forAll(refs, refI)
822  {
823  const DynamicList<splitCell8>& subSplits = refs[refI].splitCells();
824  offsets[refI+1] = offsets[refI]+subSplits.size();
825  }
826 
827  // Construct merged splitCells
828  splitCells_.setSize(offsets.last());
829  forAll(refs, refI)
830  {
831  const DynamicList<splitCell8>& subSplits = refs[refI].splitCells();
832  forAll(subSplits, i)
833  {
834  splitCell8& newSplit = splitCells_[offsets[refI]+i];
835 
836  // Copy
837  newSplit = subSplits[i];
838 
839  // Offset indices
840  if (newSplit.parent_ >= 0)
841  {
842  newSplit.parent_ += offsets[refI];
843  }
844 
845  if (newSplit.addedCellsPtr_.valid())
846  {
847  FixedList<label, 8>& splits = newSplit.addedCellsPtr_();
848 
849  forAll(splits, i)
850  {
851  if (splits[i] >= 0)
852  {
853  splits[i] += offsets[refI];
854  }
855  }
856  }
857  }
858  }
859 
860 
861  // Construct merged visibleCells
862  visibleCells_.setSize(mesh.nCells(), -1);
863  forAll(refs, refI)
864  {
865  const labelList& cellMap = cellMaps[refI];
866  const labelList& subVis = refs[refI].visibleCells();
867 
868  forAll(subVis, i)
869  {
870  label& newVis = visibleCells_[cellMap[i]];
871 
872  newVis = subVis[i];
873  if (newVis >= 0)
874  {
875  newVis += offsets[refI];
876  }
877  }
878  }
879 
880 
881  // Is active if any of the refinementHistories is active (assumes active
882  // flag parallel synchronised)
883  active_ = false;
884  forAll(refs, refI)
885  {
886  if (refs[refI].active())
887  {
888  active_ = true;
889  break;
890  }
891  }
892 
893  // Check indices.
894  checkIndices();
895 
896  if (debug)
897  {
898  Pout<< "refinementHistory::refinementHistory :"
899  << " constructed history from multiple refinementHistories :"
900  << " splitCells:" << splitCells_.size()
901  << " visibleCells:" << visibleCells_.size()
902  << endl;
903  }
904 }
905 
906 
907 // Construct from Istream
909 :
910  regIOobject(io),
911  refCount(),
912  splitCells_(is),
913  freeSplitCells_(0),
914  visibleCells_(is)
915 {
917 
918  // Check indices.
919  checkIndices();
920 
921  if (debug)
922  {
923  Pout<< "refinementHistory::refinementHistory :"
924  << " constructed history from Istream"
925  << " splitCells:" << splitCells_.size()
926  << " visibleCells:" << visibleCells_.size()
927  << endl;
928  }
929 }
930 
931 
932 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
933 
935 (
936  const IOobject& io,
937  // Per visible cell the processor it is going to
938  const labelList& decomposition,
939  // Per splitCell entry the processor it moves to
940  const labelList& splitCellProc,
941  // Per splitCell entry the number of live cells that move to that processor
942  const labelList& splitCellNum,
943 
944  const label procI,
945 
946  // From old to new splitCells
947  labelList& oldToNewSplit
948 ) const
949 {
950  oldToNewSplit.setSize(splitCells_.size());
951  oldToNewSplit = -1;
952 
953  // Compacted splitCells
954  DynamicList<splitCell8> newSplitCells(splitCells_.size());
955 
956  // Loop over all entries. Note: could recurse like countProc so only
957  // visit used entries but is probably not worth it.
958 
959  forAll(splitCells_, index)
960  {
961  if (splitCellProc[index] == procI && splitCellNum[index] == 8)
962  {
963  // Entry moves in its whole to procI
964  oldToNewSplit[index] = newSplitCells.size();
965  newSplitCells.append(splitCells_[index]);
966  }
967  }
968 
969  // Add live cells that are subsetted.
970  forAll(visibleCells_, cellI)
971  {
972  label index = visibleCells_[cellI];
973 
974  if (index >= 0 && decomposition[cellI] == procI)
975  {
976  label parent = splitCells_[index].parent_;
977 
978  // Create new splitCell with parent
979  oldToNewSplit[index] = newSplitCells.size();
980  newSplitCells.append(splitCell8(parent));
981  }
982  }
983 
984  //forAll(oldToNewSplit, index)
985  //{
986  // Pout<< "old:" << index << " new:" << oldToNewSplit[index]
987  // << endl;
988  //}
989 
990  newSplitCells.shrink();
991 
992  // Renumber contents of newSplitCells
993  forAll(newSplitCells, index)
994  {
995  splitCell8& split = newSplitCells[index];
996 
997  if (split.parent_ >= 0)
998  {
999  split.parent_ = oldToNewSplit[split.parent_];
1000  }
1001  if (split.addedCellsPtr_.valid())
1002  {
1003  FixedList<label, 8>& splits = split.addedCellsPtr_();
1004 
1005  forAll(splits, i)
1006  {
1007  if (splits[i] >= 0)
1008  {
1009  splits[i] = oldToNewSplit[splits[i]];
1010  }
1011  }
1012  }
1013  }
1014 
1015 
1016  // Count number of cells
1017  label nSub = 0;
1018  forAll(decomposition, cellI)
1019  {
1020  if (decomposition[cellI] == procI)
1021  {
1022  nSub++;
1023  }
1024  }
1025 
1026  labelList newVisibleCells(nSub);
1027  nSub = 0;
1028 
1029  forAll(visibleCells_, cellI)
1030  {
1031  if (decomposition[cellI] == procI)
1032  {
1033  label index = visibleCells_[cellI];
1034  if (index >= 0)
1035  {
1036  index = oldToNewSplit[index];
1037  }
1038  newVisibleCells[nSub++] = index;
1039  }
1040  }
1041 
1043  (
1044  new refinementHistory
1045  (
1046  io,
1047  newSplitCells,
1048  newVisibleCells,
1049  active_
1050  )
1051  );
1052 }
1053 
1054 
1057  const IOobject& io,
1058  const labelList& cellMap
1059 ) const
1060 {
1061  if (active_)
1062  {
1063  // Mark selected cells with '1'
1064  labelList decomposition(visibleCells_.size(), 0);
1065  forAll(cellMap, i)
1066  {
1067  decomposition[cellMap[i]] = 1;
1068  }
1069 
1070 
1071  // Per splitCell entry the processor it moves to
1072  labelList splitCellProc(splitCells_.size(), -1);
1073  // Per splitCell entry the number of live cells that move to that
1074  // processor
1075  labelList splitCellNum(splitCells_.size(), 0);
1076 
1077  forAll(visibleCells_, cellI)
1078  {
1079  label index = visibleCells_[cellI];
1080 
1081  if (index >= 0)
1082  {
1083  countProc
1084  (
1085  splitCells_[index].parent_,
1086  decomposition[cellI],
1087  splitCellProc,
1088  splitCellNum
1089  );
1090  }
1091  }
1092 
1093  labelList oldToNewSplit;
1094  return clone
1095  (
1096  io,
1097  decomposition,
1098  splitCellProc,
1099  splitCellNum,
1100  1, //procI,
1101  oldToNewSplit
1102  );
1103  }
1104  else
1105  {
1107  (
1108  new refinementHistory
1109  (
1110  io,
1112  labelList(0),
1113  false
1114  )
1115  );
1116  }
1117 }
1118 
1119 
1121 {
1122  label oldSize = visibleCells_.size();
1123 
1124  if (debug)
1125  {
1126  Pout<< "refinementHistory::resize from " << oldSize << " to " << size
1127  << " cells" << endl;
1128  }
1129 
1130  visibleCells_.setSize(size);
1131 
1132  // Set additional elements to -1.
1133  for (label i = oldSize; i < visibleCells_.size(); i++)
1134  {
1135  visibleCells_[i] = -1;
1136  }
1137 }
1138 
1139 
1141 {
1142  if (active())
1143  {
1144  const labelList& reverseCellMap = map.reverseCellMap();
1145 
1146  // Note that only the live cells need to be renumbered.
1147 
1148  labelList newVisibleCells(map.cellMap().size(), -1);
1149 
1150  forAll(visibleCells_, cellI)
1151  {
1152  if (visibleCells_[cellI] != -1)
1153  {
1154  label index = visibleCells_[cellI];
1155 
1156  // Check not already set
1157  if (splitCells_[index].addedCellsPtr_.valid())
1158  {
1160  << "Problem" << abort(FatalError);
1161  }
1162 
1163  label newCellI = reverseCellMap[cellI];
1164 
1165  if (newCellI >= 0)
1166  {
1167  newVisibleCells[newCellI] = index;
1168  }
1169  }
1170  }
1171 
1172  if (debug)
1173  {
1174  Pout<< "refinementHistory::updateMesh : from "
1175  << visibleCells_.size()
1176  << " to " << newVisibleCells.size()
1177  << " cells" << endl;
1178  }
1179 
1180  visibleCells_.transfer(newVisibleCells);
1181  }
1182 }
1183 
1184 
1185 // Update numbering for subsetting
1188  const labelList& pointMap,
1189  const labelList& faceMap,
1190  const labelList& cellMap
1191 )
1192 {
1193  if (active())
1194  {
1195  labelList newVisibleCells(cellMap.size(), -1);
1196 
1197  forAll(newVisibleCells, cellI)
1198  {
1199  label oldCellI = cellMap[cellI];
1200 
1201  label index = visibleCells_[oldCellI];
1202 
1203  // Check that cell is live (so its parent has no refinement)
1204  if (index >= 0 && splitCells_[index].addedCellsPtr_.valid())
1205  {
1207  << "Problem" << abort(FatalError);
1208  }
1209 
1210  newVisibleCells[cellI] = index;
1211  }
1212 
1213  if (debug)
1214  {
1215  Pout<< "refinementHistory::updateMesh : from "
1216  << visibleCells_.size()
1217  << " to " << newVisibleCells.size()
1218  << " cells" << endl;
1219  }
1220 
1221  visibleCells_.transfer(newVisibleCells);
1222  }
1223 }
1224 
1225 
1228  const label index,
1229  const label newProcNo,
1230  labelList& splitCellProc,
1231  labelList& splitCellNum
1232 ) const
1233 {
1234  if (splitCellProc[index] != newProcNo)
1235  {
1236  // Different destination processor from other cells using this
1237  // parent. Reset count.
1238  splitCellProc[index] = newProcNo;
1239  splitCellNum[index] = 1;
1240  }
1241  else
1242  {
1243  splitCellNum[index]++;
1244 
1245  // Increment parent if whole splitCell moves to same processor
1246  if (splitCellNum[index] == 8)
1247  {
1248  if (debug)
1249  {
1250  Pout<< "Moving " << splitCellNum[index]
1251  << " cells originating from cell " << index
1252  << " from processor " << Pstream::myProcNo()
1253  << " to processor " << splitCellProc[index]
1254  << endl;
1255  }
1256 
1257  label parent = splitCells_[index].parent_;
1258 
1259  if (parent >= 0)
1260  {
1261  countProc(parent, newProcNo, splitCellProc, splitCellNum);
1262  }
1263  }
1264  }
1265 }
1266 
1267 
1269 {
1270  if (!active())
1271  {
1273  << "Calling distribute on inactive history" << abort(FatalError);
1274  }
1275 
1276 
1277  if (!Pstream::parRun())
1278  {
1279  return;
1280  }
1281 
1282  // Remove unreferenced history.
1283  compact();
1284 
1285  //Pout<< nl << "--BEFORE:" << endl;
1286  //writeDebug();
1287  //Pout<< "---------" << nl << endl;
1288 
1289 
1290  // Distribution is only partially functional.
1291  // If all 8 cells resulting from a single parent are sent across in one
1292  // go it will also send across that part of the refinement history.
1293  // If however e.g. first 1 and then the other 7 are sent across the
1294  // history will not be reconstructed.
1295 
1296  // Determine clusters. This is per every entry in splitCells_ (that is
1297  // a parent of some refinement) a label giving the processor it goes to
1298  // if all its children are going to the same processor.
1299 
1300  // Per visible cell the processor it goes to.
1301  labelList destination(visibleCells_.size());
1302 
1303  const labelListList& subCellMap = map.cellMap().subMap();
1304 
1305  forAll(subCellMap, procI)
1306  {
1307  const labelList& newToOld = subCellMap[procI];
1308 
1309  forAll(newToOld, i)
1310  {
1311  label oldCellI = newToOld[i];
1312 
1313  destination[oldCellI] = procI;
1314  }
1315  }
1316 
1317  // Per splitCell entry the processor it moves to
1318  labelList splitCellProc(splitCells_.size(), -1);
1319  // Per splitCell entry the number of live cells that move to that processor
1320  labelList splitCellNum(splitCells_.size(), 0);
1321 
1322  forAll(visibleCells_, cellI)
1323  {
1324  label index = visibleCells_[cellI];
1325 
1326  if (index >= 0)
1327  {
1328  countProc
1329  (
1330  splitCells_[index].parent_,
1331  destination[cellI],
1332  splitCellProc,
1333  splitCellNum
1334  );
1335  }
1336  }
1337 
1338  //Pout<< "refinementHistory::distribute :"
1339  // << " splitCellProc:" << splitCellProc << endl;
1340  //
1341  //Pout<< "refinementHistory::distribute :"
1342  // << " splitCellNum:" << splitCellNum << endl;
1343 
1344 
1345  // Create subsetted refinement tree consisting of all parents that
1346  // move in their whole to other processor.
1347  for (label procI = 0; procI < Pstream::nProcs(); procI++)
1348  {
1349  //Pout<< "-- Subetting for processor " << procI << endl;
1350 
1351  // From uncompacted to compacted splitCells.
1352  labelList oldToNew(splitCells_.size(), -1);
1353 
1354  // Compacted splitCells. Similar to subset routine below.
1355  DynamicList<splitCell8> newSplitCells(splitCells_.size());
1356 
1357  // Loop over all entries. Note: could recurse like countProc so only
1358  // visit used entries but is probably not worth it.
1359 
1360  forAll(splitCells_, index)
1361  {
1362  if (splitCellProc[index] == procI && splitCellNum[index] == 8)
1363  {
1364  // Entry moves in its whole to procI
1365  oldToNew[index] = newSplitCells.size();
1366  newSplitCells.append(splitCells_[index]);
1367  }
1368  }
1369 
1370  // Add live cells that are subsetted.
1371  forAll(visibleCells_, cellI)
1372  {
1373  label index = visibleCells_[cellI];
1374 
1375  if (index >= 0 && destination[cellI] == procI)
1376  {
1377  label parent = splitCells_[index].parent_;
1378 
1379  // Create new splitCell with parent
1380  oldToNew[index] = newSplitCells.size();
1381  newSplitCells.append(splitCell8(parent));
1382  }
1383  }
1384 
1385  //forAll(oldToNew, index)
1386  //{
1387  // Pout<< "old:" << index << " new:" << oldToNew[index]
1388  // << endl;
1389  //}
1390 
1391  newSplitCells.shrink();
1392 
1393  // Renumber contents of newSplitCells
1394  forAll(newSplitCells, index)
1395  {
1396  splitCell8& split = newSplitCells[index];
1397 
1398  if (split.parent_ >= 0)
1399  {
1400  split.parent_ = oldToNew[split.parent_];
1401  }
1402  if (split.addedCellsPtr_.valid())
1403  {
1404  FixedList<label, 8>& splits = split.addedCellsPtr_();
1405 
1406  forAll(splits, i)
1407  {
1408  if (splits[i] >= 0)
1409  {
1410  splits[i] = oldToNew[splits[i]];
1411  }
1412  }
1413  }
1414  }
1415 
1416 
1417  const labelList& subMap = subCellMap[procI];
1418 
1419  // New visible cells.
1420  labelList newVisibleCells(subMap.size(), -1);
1421 
1422  forAll(subMap, newCellI)
1423  {
1424  label oldCellI = subMap[newCellI];
1425 
1426  label oldIndex = visibleCells_[oldCellI];
1427 
1428  if (oldIndex >= 0)
1429  {
1430  newVisibleCells[newCellI] = oldToNew[oldIndex];
1431  }
1432  }
1433 
1434  //Pout<< nl << "--Subset for domain:" << procI << endl;
1435  //writeDebug(newVisibleCells, newSplitCells);
1436  //Pout<< "---------" << nl << endl;
1437 
1438 
1439  // Send to neighbours
1440  OPstream toNbr(Pstream::blocking, procI);
1441  toNbr << newSplitCells << newVisibleCells;
1442  }
1443 
1444 
1445  // Receive from neighbours and merge
1446  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1447 
1448  // Remove all entries. Leave storage intact.
1449  splitCells_.clear();
1450 
1451  const polyMesh& mesh = dynamic_cast<const polyMesh&>(db());
1452 
1453  visibleCells_.setSize(mesh.nCells());
1454  visibleCells_ = -1;
1455 
1456  for (label procI = 0; procI < Pstream::nProcs(); procI++)
1457  {
1458  IPstream fromNbr(Pstream::blocking, procI);
1459  List<splitCell8> newSplitCells(fromNbr);
1460  labelList newVisibleCells(fromNbr);
1461 
1462  //Pout<< nl << "--Received from domain:" << procI << endl;
1463  //writeDebug(newVisibleCells, newSplitCells);
1464  //Pout<< "---------" << nl << endl;
1465 
1466 
1467  // newSplitCells contain indices only into newSplitCells so
1468  // renumbering can be done here.
1469  label offset = splitCells_.size();
1470 
1471  //Pout<< "**Renumbering data from proc " << procI << " with offset "
1472  // << offset << endl;
1473 
1474  forAll(newSplitCells, index)
1475  {
1476  splitCell8& split = newSplitCells[index];
1477 
1478  if (split.parent_ >= 0)
1479  {
1480  split.parent_ += offset;
1481  }
1482  if (split.addedCellsPtr_.valid())
1483  {
1484  FixedList<label, 8>& splits = split.addedCellsPtr_();
1485 
1486  forAll(splits, i)
1487  {
1488  if (splits[i] >= 0)
1489  {
1490  splits[i] += offset;
1491  }
1492  }
1493  }
1494 
1495  splitCells_.append(split);
1496  }
1497 
1498 
1499  // Combine visibleCell.
1500  const labelList& constructMap = map.cellMap().constructMap()[procI];
1501 
1502  forAll(newVisibleCells, i)
1503  {
1504  if (newVisibleCells[i] >= 0)
1505  {
1506  visibleCells_[constructMap[i]] = newVisibleCells[i] + offset;
1507  }
1508  }
1509  }
1510  splitCells_.shrink();
1511 
1512  //Pout<< nl << "--AFTER:" << endl;
1513  //writeDebug();
1514  //Pout<< "---------" << nl << endl;
1515 }
1516 
1517 
1519 {
1520  if (debug)
1521  {
1522  Pout<< "refinementHistory::compact() Entering with:"
1523  << " freeSplitCells_:" << freeSplitCells_.size()
1524  << " splitCells_:" << splitCells_.size()
1525  << " visibleCells_:" << visibleCells_.size()
1526  << endl;
1527 
1528  // Check all free splitCells are marked as such
1529  forAll(freeSplitCells_, i)
1530  {
1531  label index = freeSplitCells_[i];
1532 
1533  if (splitCells_[index].parent_ != -2)
1534  {
1536  << "Problem index:" << index
1537  << abort(FatalError);
1538  }
1539  }
1540 
1541  // Check none of the visible cells are marked as free
1542  forAll(visibleCells_, cellI)
1543  {
1544  if
1545  (
1546  visibleCells_[cellI] >= 0
1547  && splitCells_[visibleCells_[cellI]].parent_ == -2
1548  )
1549  {
1551  << "Problem : visible cell:" << cellI
1552  << " is marked as being free." << abort(FatalError);
1553  }
1554  }
1555  }
1556 
1557  DynamicList<splitCell8> newSplitCells(splitCells_.size());
1558 
1559  // From uncompacted to compacted splitCells.
1560  labelList oldToNew(splitCells_.size(), -1);
1561 
1562  // Mark all used splitCell entries. These are either indexed by visibleCells
1563  // or indexed from other splitCell entries.
1564 
1565  // Mark from visibleCells
1566  forAll(visibleCells_, cellI)
1567  {
1568  label index = visibleCells_[cellI];
1569 
1570  if (index >= 0)
1571  {
1572  // Make sure we only mark visible indices if they either have a
1573  // parent or subsplits.
1574  if
1575  (
1576  splitCells_[index].parent_ != -1
1577  || splitCells_[index].addedCellsPtr_.valid()
1578  )
1579  {
1580  markSplit(index, oldToNew, newSplitCells);
1581  }
1582  }
1583  }
1584 
1585  // Mark from splitCells
1586  forAll(splitCells_, index)
1587  {
1588  if (splitCells_[index].parent_ == -2)
1589  {
1590  // freed cell.
1591  }
1592  else if
1593  (
1594  splitCells_[index].parent_ == -1
1595  && splitCells_[index].addedCellsPtr_.empty()
1596  )
1597  {
1598  // recombined cell. No need to keep since no parent and no subsplits
1599  // Note that gets marked if reachable from other index!
1600  }
1601  else
1602  {
1603  // Is used element.
1604  markSplit(index, oldToNew, newSplitCells);
1605  }
1606  }
1607 
1608 
1609  // Now oldToNew is fully complete and compacted elements are in
1610  // newSplitCells.
1611  // Renumber contents of newSplitCells and visibleCells.
1612  forAll(newSplitCells, index)
1613  {
1614  splitCell8& split = newSplitCells[index];
1615 
1616  if (split.parent_ >= 0)
1617  {
1618  split.parent_ = oldToNew[split.parent_];
1619  }
1620  if (split.addedCellsPtr_.valid())
1621  {
1622  FixedList<label, 8>& splits = split.addedCellsPtr_();
1623 
1624  forAll(splits, i)
1625  {
1626  if (splits[i] >= 0)
1627  {
1628  splits[i] = oldToNew[splits[i]];
1629  }
1630  }
1631  }
1632  }
1633 
1634 
1635  if (debug)
1636  {
1637  Pout<< "refinementHistory::compact : compacted splitCells from "
1638  << splitCells_.size() << " to " << newSplitCells.size() << endl;
1639  }
1640 
1641  splitCells_.transfer(newSplitCells);
1642  freeSplitCells_.clearStorage();
1643 
1644 
1645  if (debug)
1646  {
1647  Pout<< "refinementHistory::compact() NOW:"
1648  << " freeSplitCells_:" << freeSplitCells_.size()
1649  << " splitCells_:" << splitCells_.size()
1650  << " newSplitCells:" << newSplitCells.size()
1651  << " visibleCells_:" << visibleCells_.size()
1652  << endl;
1653  }
1654 
1655 
1656  // Adapt indices in visibleCells_
1657  forAll(visibleCells_, cellI)
1658  {
1659  label index = visibleCells_[cellI];
1660 
1661  if (index >= 0)
1662  {
1663  // Note that oldToNew can be -1 so it resets newVisibleCells.
1664  visibleCells_[cellI] = oldToNew[index];
1665  }
1666  else
1667  {
1668  // Keep -1 value.
1669  }
1670  }
1671 }
1672 
1673 
1675 {
1676  writeDebug(visibleCells_, splitCells_);
1677 }
1678 
1679 
1682  const label cellI,
1683  const labelList& addedCells
1684 )
1685 {
1686  label parentIndex = -1;
1687 
1688  if (visibleCells_[cellI] != -1)
1689  {
1690  // Was already live. The current live cell becomes the
1691  // parent of the cells split off from it.
1692 
1693  parentIndex = visibleCells_[cellI];
1694 
1695  // It is no longer live (note that actually cellI gets alive
1696  // again below since is addedCells[0])
1697  visibleCells_[cellI] = -1;
1698  }
1699  else
1700  {
1701  // Create 0th level. -1 parent to denote this.
1702  parentIndex = allocateSplitCell(-1, -1);
1703  }
1704 
1705  // Create live entries for added cells that point to the
1706  // cell they were created from (parentIndex)
1707  forAll(addedCells, i)
1708  {
1709  label addedCellI = addedCells[i];
1710 
1711  // Create entries for the split off cells. All of them
1712  // are visible.
1713  visibleCells_[addedCellI] = allocateSplitCell(parentIndex, i);
1714  }
1715 }
1716 
1717 
1720  const label masterCellI,
1721  const labelList& combinedCells
1722 )
1723 {
1724  // Save the parent structure
1725  label parentIndex = splitCells_[visibleCells_[masterCellI]].parent_;
1726 
1727  // Remove the information for the combined cells
1728  forAll(combinedCells, i)
1729  {
1730  label cellI = combinedCells[i];
1731 
1732  freeSplitCell(visibleCells_[cellI]);
1733  visibleCells_[cellI] = -1;
1734  }
1735 
1736  splitCell8& parentSplit = splitCells_[parentIndex];
1737  parentSplit.addedCellsPtr_.reset(NULL);
1738  visibleCells_[masterCellI] = parentIndex;
1739 }
1740 
1741 
1743 {
1744  bool ok = readData(readStream(typeName));
1745  close();
1746 
1747  active_ = (returnReduce(visibleCells_.size(), sumOp<label>()) > 0);
1748 
1749  return ok;
1750 }
1751 
1752 
1754 {
1755  is >> *this;
1756  return !is.bad();
1757 }
1758 
1759 
1761 {
1762  os << *this;
1763 
1764  return os.good();
1765 }
1766 
1767 
1768 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
1769 
1771 {
1773 
1774  is >> rh.splitCells_ >> rh.visibleCells_;
1775 
1776  // Check indices.
1777  rh.checkIndices();
1778 
1779  return is;
1780 }
1781 
1782 
1783 Foam::Ostream& Foam::operator<<(Ostream& os, const refinementHistory& rh)
1784 {
1785  const_cast<refinementHistory&>(rh).compact();
1786 
1787  return os << "// splitCells" << nl
1788  << rh.splitCells_ << nl
1789  << "// visibleCells" << nl
1790  << rh.visibleCells_;
1791 }
1792 
1793 
1794 // ************************************************************************* //
Foam::refinementHistory::visibleCells
const labelList & visibleCells() const
Per cell in the current mesh (i.e. visible) either -1 (unrefined)
Definition: refinementHistory.H:261
Foam::mapDistributeBase::subMap
const labelListList & subMap() const
From subsetted data back to original data.
Definition: mapDistributeBase.H:256
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::refinementHistory::refinementHistory
refinementHistory(const IOobject &)
Construct (read) given an IOobject. If global number of visible.
Definition: refinementHistory.C:557
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:90
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:497
Foam::labelList
List< label > labelList
A List of labels.
Definition: labelList.H:56
Foam::returnReduce
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Definition: PstreamReduceOps.H:86
Foam::refinementHistory::read
virtual bool read()
Read object. If global number of visible cells > 0 becomes active.
Definition: refinementHistory.C:1742
Foam::refinementHistory::active_
bool active_
Is active?
Definition: refinementHistory.H:143
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::findIndex
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
Foam::refCount
Reference counter for various OpenFOAM components.
Definition: refCount.H:45
Foam::DynamicList
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:56
Foam::OPstream
Output inter-processor communications stream.
Definition: OPstream.H:50
Foam::refinementHistory::compact
void compact()
Compact splitCells_. Removes all freeSplitCells_ elements.
Definition: refinementHistory.C:1518
Foam::refinementHistory::markSplit
void markSplit(const label, labelList &oldToNew, DynamicList< splitCell8 > &) const
Mark entry in splitCells. Recursively mark its parent and subs.
Definition: refinementHistory.C:340
mapPolyMesh.H
Foam::UPstream::nProcs
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:387
Foam::refinementHistory::splitCells_
DynamicList< splitCell8 > splitCells_
Storage for splitCells.
Definition: refinementHistory.H:146
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:377
Foam::operator==
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Foam::refinementHistory::writeEntry
static void writeEntry(const List< splitCell8 > &, const splitCell8 &)
Debug write.
Definition: refinementHistory.C:176
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:108
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::refinementHistory::storeSplit
void storeSplit(const label cellI, const labelList &addedCells)
Store splitting of cell into 8.
Definition: refinementHistory.C:1681
Foam::refinementHistory::writeData
virtual bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
Definition: refinementHistory.C:1760
Foam::refinementHistory::splitCell8
Definition: refinementHistory.H:102
polyMesh.H
Foam::refinementHistory::splitCell8::parent_
label parent_
Definition: refinementHistory.H:109
syncTools.H
Foam::refinementHistory::splitCell8::operator==
bool operator==(const splitCell8 &s) const
Definition: refinementHistory.C:101
Foam::refinementHistory::countProc
void countProc(const label index, const label newProcNo, labelList &splitCellProc, labelList &splitCellNum) const
Definition: refinementHistory.C:1227
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::refinementHistory::freeSplitCells
const DynamicList< label > & freeSplitCells() const
Cache of unused indices in splitCells.
Definition: refinementHistory.H:273
Foam::mapDistributePolyMesh::cellMap
const mapDistribute & cellMap() const
Cell distribute map.
Definition: mapDistributePolyMesh.H:214
Foam::IOobject::db
const objectRegistry & db() const
Return the local objectRegistry.
Definition: IOobject.C:239
Foam::refinementHistory::checkIndices
void checkIndices() const
Check consistency of structure, i.e. indices into splitCells_.
Definition: refinementHistory.C:239
Foam::refinementHistory::mark
void mark(const label, const label, labelList &) const
Mark index and all its descendants.
Definition: refinementHistory.C:377
Foam::primitiveMesh::nCells
label nCells() const
Definition: primitiveMeshI.H:64
Foam::IOobject::headerOk
bool headerOk()
Read and check header info.
Definition: IOobject.C:439
Foam::refinementHistory
All refinement history. Used in unrefinement.
Definition: refinementHistory.H:95
Foam::IOobject::MUST_READ_IF_MODIFIED
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:109
Foam::UPstream::blocking
@ blocking
Definition: UPstream.H:66
mapDistributePolyMesh.H
Foam::refinementHistory::splitCell8::splitCell8
splitCell8()
Construct null (parent = -1)
Definition: refinementHistory.C:42
Foam::refinementHistory::writeDebug
void writeDebug() const
Debug write.
Definition: refinementHistory.C:1674
Foam::reduce
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
Definition: PstreamReduceOps.H:43
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:59
Foam::IOobject::readOpt
readOption readOpt() const
Definition: IOobject.H:317
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::UPtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: UPtrList.H:53
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
Foam::DynamicList::shrink
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
Definition: DynamicListI.H:258
Foam::operator<<
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:130
refinementHistory.H
Foam::refinementHistory::splitCell8::operator!=
bool operator!=(const splitCell8 &s) const
Definition: refinementHistory.C:122
Foam::FatalError
error FatalError
Foam::FixedList::setSize
void setSize(const label)
Dummy setSize function.
Definition: FixedListI.H:177
Foam::IOstream::bad
bool bad() const
Return true if stream is corrupted.
Definition: IOstream.H:351
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::refinementHistory::resize
void resize(const label nCells)
Extend/shrink storage. additional visibleCells_ elements get.
Definition: refinementHistory.C:1120
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
s
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))
Foam::DynamicList::append
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Foam::UPstream::myProcNo
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:405
Foam::refinementHistory::readData
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation. Note:
Definition: refinementHistory.C:1753
Foam::List::setSize
void setSize(const label)
Reset size of List.
Foam::refinementHistory::markCommonCells
label markCommonCells(labelList &cellToCluster) const
Mark cells according to top parent. Return number of clusters.
Definition: refinementHistory.C:403
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
Foam::mapPolyMesh::reverseCellMap
const labelList & reverseCellMap() const
Reverse cell map.
Definition: mapPolyMesh.H:528
Foam::refinementHistory::freeSplitCells_
DynamicList< label > freeSplitCells_
Unused indices in splitCells.
Definition: refinementHistory.H:149
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::refinementHistory::splitCell8::addedCellsPtr_
autoPtr< FixedList< label, 8 > > addedCellsPtr_
Cells this cell was refined into.
Definition: refinementHistory.H:112
Foam::regIOobject::readStream
Istream & readStream()
Return Istream.
Definition: regIOobjectRead.C:34
Foam::refinementHistory::add
void add(boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Add my decomposition constraints.
Definition: refinementHistory.C:451
Foam::sumOp
Definition: ops.H:162
Foam::Pout
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
Foam::regIOobject::close
void close()
Close Istream.
Definition: regIOobjectRead.C:148
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::IOobject::clone
Foam::autoPtr< IOobject > clone() const
Clone.
Definition: IOobject.H:252
Foam::refinementHistory::combineCells
void combineCells(const label masterCellI, const labelList &combinedCells)
Store combining 8 cells into master.
Definition: refinementHistory.C:1719
Foam::FixedList
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:53
Foam::autoPtr::valid
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set).
Definition: autoPtrI.H:83
Foam::List::clear
void clear()
Clear the list, i.e. set size to zero.
Definition: List.C:379
Foam::DynamicList::clearStorage
void clearStorage()
Clear the list and delete storage.
Definition: DynamicListI.H:249
Foam::operator>>
Istream & operator>>(Istream &, edgeMesh &)
Definition: edgeMeshIO.C:141
Foam::DynamicList::remove
T remove()
Remove and return the top element.
Definition: DynamicListI.H:365
Foam::refinementHistory::subset
void subset(const labelList &pointMap, const labelList &faceMap, const labelList &cellMap)
Update numbering for subsetting.
Definition: refinementHistory.C:1187
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::refinementHistory::splitCell8::operator=
void operator=(const splitCell8 &s)
Copy operator since autoPtr otherwise 'steals' storage.
Definition: refinementHistory.C:80
Foam::refinementHistory::splitCells
const DynamicList< splitCell8 > & splitCells() const
Storage for splitCell8s.
Definition: refinementHistory.H:267
Foam::refinementHistory::distribute
void distribute(const mapDistributePolyMesh &)
Update local numbering for mesh redistribution.
Definition: refinementHistory.C:1268
Foam::refinementHistory::updateMesh
void updateMesh(const mapPolyMesh &)
Update numbering for mesh changes.
Definition: refinementHistory.C:1140
Foam::IPstream
Input inter-processor communications stream.
Definition: IPstream.H:50
Foam::syncTools::syncFaceList
static void syncFaceList(const polyMesh &mesh, UList< T > &l, const CombineOp &cop)
Synchronize values on all mesh faces.
Definition: syncTools.H:381
Foam::refinementHistory::allocateSplitCell
label allocateSplitCell(const label parent, const label i)
Allocate a splitCell. Return index in splitCells_.
Definition: refinementHistory.C:258
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::mapDistributePolyMesh
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Definition: mapDistributePolyMesh.H:57
Foam::IOstream::good
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::mapDistributeBase::constructMap
const labelListList & constructMap() const
From subsetted data to new reconstructed data.
Definition: mapDistributeBase.H:268
Foam::IOobject::READ_IF_PRESENT
@ READ_IF_PRESENT
Definition: IOobject.H:110
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::refinementHistory::visibleCells_
labelList visibleCells_
Currently visible cells. Indices into splitCells.
Definition: refinementHistory.H:152
Foam::refinementHistory::freeSplitCell
void freeSplitCell(const label index)
Free a splitCell.
Definition: refinementHistory.C:301
Foam::DynamicList::setSize
void setSize(const label)
Alter the addressed list size.
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::prefixOSstream::prefix
const string & prefix() const
Return the prefix of the stream.
Definition: prefixOSstream.H:86
Foam::mapPolyMesh::cellMap
const labelList & cellMap() const
Old cell map.
Definition: mapPolyMesh.H:431
Foam::UPtrList::size
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:31
Foam::andEqOp
Definition: ops.H:81
Foam::token::SPACE
@ SPACE
Definition: token.H:95