53 void Foam::multiDirRefinement::addCells
55 const Map<label>& splitMap,
56 List<refineCell>& refCells
59 label newRefI = refCells.size();
61 label oldSize = refCells.size();
63 refCells.setSize(newRefI + splitMap.size());
65 for (
label refI = 0; refI < oldSize; refI++)
67 const refineCell& refCell = refCells[refI];
71 if (iter == splitMap.end())
75 "multiDirRefinement::addCells(const Map<label>&" 76 ", List<refineCell>&)" 77 ) <<
"Problem : cannot find added cell for cell " 81 refCells[newRefI++] = refineCell(iter(), refCell.direction());
88 void Foam::multiDirRefinement::update
90 const Map<label>& splitMap,
94 field.setSize(field.size() + splitMap.size());
98 field[iter()] = field[iter.key()];
104 void Foam::multiDirRefinement::addCells
106 const Map<label>& splitMap,
110 label newCellI = labels.size();
112 labels.setSize(labels.size() + splitMap.size());
116 labels[newCellI++] = iter();
123 void Foam::multiDirRefinement::addCells
125 const primitiveMesh& mesh,
126 const Map<label>& splitMap
132 forAll(addedCells_, cellI)
134 const labelList& added = addedCells_[cellI];
138 label slave = added[i];
140 if (origCell[slave] == -1)
142 origCell[slave] = cellI;
144 else if (origCell[slave] != cellI)
148 "multiDirRefinement::addCells(const primitiveMesh&" 149 ", const Map<label>&" 150 ) <<
"Added cell " << slave <<
" has two different masters:" 151 << origCell[slave] <<
" , " << cellI
160 label masterI = iter.key();
161 label newCellI = iter();
163 while (origCell[masterI] != -1 && origCell[masterI] != masterI)
165 masterI = origCell[masterI];
168 if (masterI >= addedCells_.size())
172 "multiDirRefinement::addCells(const primitiveMesh&" 173 ", const Map<label>&" 174 ) <<
"Map of added cells contains master cell " << masterI
175 <<
" which is not a valid cell number" <<
endl 176 <<
"This means that the mesh is not consistent with the" 177 <<
" done refinement" <<
endl 189 else if (
findIndex(added, newCellI) == -1)
191 label sz = added.size();
192 added.setSize(sz + 1);
193 added[sz] = newCellI;
199 Foam::labelList Foam::multiDirRefinement::splitOffHex(
const primitiveMesh& mesh)
207 labelList nonHexLabels(cellLabels_.size());
215 label cellI = cellLabels_[i];
217 if (cellShapes[cellI].model() == hex)
219 hexLabels[hexI++] = cellI;
223 nonHexLabels[nonHexI++] = cellI;
227 nonHexLabels.setSize(nonHexI);
229 cellLabels_.transfer(nonHexLabels);
231 hexLabels.setSize(hexI);
237 void Foam::multiDirRefinement::refineHex8
246 Pout<<
"multiDirRefinement : Refining hexes " << hexCells.size()
260 mesh.facesInstance(),
267 List<refinementHistory::splitCell8>(0),
272 polyTopoChange meshMod(mesh);
276 hexRefiner.consistentRefinement
286 Map<label> hexCellSet(2*hexCells.size());
289 hexCellSet.insert(hexCells[i], 1);
293 forAll(consistentCells, i)
295 const label cellI = consistentCells[i];
299 if (iter == hexCellSet.end())
303 "multiDirRefinement::refineHex8" 304 "(polyMesh&, const labelList&, const bool)" 305 ) <<
"Resulting mesh would not satisfy 2:1 ratio" 322 "multiDirRefinement::refineHex8" 323 "(polyMesh&, const labelList&, const bool)" 324 ) <<
"Resulting mesh would not satisfy 2:1 ratio" 325 <<
" when refining cell " << iter.key()
332 hexRefiner.setRefinement(consistentCells, meshMod);
335 autoPtr<mapPolyMesh> morphMapPtr = meshMod.changeMesh(mesh,
false,
true);
336 const mapPolyMesh& morphMap = morphMapPtr();
338 if (morphMap.hasMotionPoints())
340 mesh.movePoints(morphMap.preMotionPoints());
350 Pout<<
"multiDirRefinement : updated mesh at time " 351 << mesh.time().timeName() <<
endl;
354 hexRefiner.updateMesh(morphMap);
358 forAll(consistentCells, i)
360 addedCells_[consistentCells[i]].setSize(8);
362 labelList nAddedCells(addedCells_.size(), 0);
364 const labelList& cellMap = morphMap.cellMap();
368 const label oldCellI = cellMap[cellI];
370 if (addedCells_[oldCellI].size())
372 addedCells_[oldCellI][nAddedCells[oldCellI]++] = cellI;
378 void Foam::multiDirRefinement::refineAllDirs
381 List<vectorField>& cellDirections,
382 const cellLooper& cellWalker,
383 undoableMeshCutter& cutter,
388 refinementIterator refiner(mesh, cutter, cellWalker, writeMesh);
390 forAll(cellDirections, dirI)
394 Pout<<
"multiDirRefinement : Refining " << cellLabels_.size()
395 <<
" cells in direction " << dirI <<
endl 399 const vectorField& dirField = cellDirections[dirI];
404 List<refineCell> refCells(cellLabels_.size());
406 if (dirField.size() == 1)
411 Pout<<
"multiDirRefinement : Uniform refinement:" 412 << dirField[0] <<
endl;
417 label cellI = cellLabels_[refI];
419 refCells[refI] = refineCell(cellI, dirField[0]);
427 const label cellI = cellLabels_[refI];
429 refCells[refI] = refineCell(cellI, dirField[cellI]);
434 Map<label> splitMap = refiner.setRefinement(refCells);
437 addCells(mesh, splitMap);
440 addCells(splitMap, cellLabels_);
443 if (dirField.size() != 1)
447 update(splitMap, cellDirections[i]);
453 Pout<<
"multiDirRefinement : Done refining direction " << dirI
454 <<
" resulting in " << cellLabels_.size() <<
" cells" <<
nl 461 void Foam::multiDirRefinement::refineFromDict
464 List<vectorField>& cellDirections,
465 const dictionary& dict,
470 Switch pureGeomCut(dict.lookup(
"geometricCut"));
472 autoPtr<cellLooper> cellWalker(NULL);
475 cellWalker.reset(
new geomCellLooper(mesh));
479 cellWalker.reset(
new hexCellLooper(mesh));
486 undoableMeshCutter cutter(mesh,
false);
488 refineAllDirs(mesh, cellDirections, cellWalker(), cutter, writeMesh);
496 Foam::multiDirRefinement::multiDirRefinement
503 cellLabels_(cellLabels),
504 addedCells_(mesh.
nCells())
512 if (useHex && dirNames.size() == 3)
517 refineHex8(mesh, hexCells, writeMesh);
520 label nRemainingCells = cellLabels_.size();
524 if (nRemainingCells > 0)
532 refineFromDict(mesh, cellDirections, dict, writeMesh);
538 Foam::multiDirRefinement::multiDirRefinement
546 cellLabels_(cellLabels),
547 addedCells_(mesh.
nCells())
555 if (useHex && dirNames.size() == 3)
560 refineHex8(mesh, hexCells, writeMesh);
563 label nRemainingCells = cellLabels_.size();
567 if (nRemainingCells > 0)
574 refineFromDict(mesh, cellDirections, dict, writeMesh);
580 Foam::multiDirRefinement::multiDirRefinement
591 cellLabels_(cellLabels),
592 addedCells_(mesh.
nCells())
597 refineAllDirs(mesh, cellDirections, cellWalker, cutter, writeMesh);
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
The main refinement handler. Gets cellCuts which is structure that describes which cells are to be cu...
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Various functions to operate on Lists.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none.
A list of keyword definitions, which are a keyword followed by any number of values (e...
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Field< vector > vectorField
Specialisation of Field<T> for vector.
errorManip< error > abort(error &err)
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Abstract base class. Concrete implementations know how to cut a cell (i.e. determine a loop around th...
Mesh consisting of general polyhedral cells.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
List< label > labelList
A List of labels.
HashTable< label, label, Hash< label > >::iterator iterator
static const cellModel * lookup(const word &)
Look up a model by name and return a pointer to the model or NULL.
List< cellShape > cellShapeList
List of cellShapes and PtrList of List of cellShape.
HashTable< label, label, Hash< label > >::const_iterator const_iterator
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout,"Pout")