53void 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];
69 const auto iter = splitMap.cfind(refCell.cellNo());
74 <<
"Problem : cannot find added cell for cell "
75 << refCell.cellNo() <<
endl
79 refCells[newRefI++] = refineCell(iter.val(), refCell.direction());
86void Foam::multiDirRefinement::update
102void Foam::multiDirRefinement::addCells
108 label newCelli = labels.size();
110 labels.setSize(labels.size() + splitMap.size());
114 labels[newCelli++] = iter.val();
121void Foam::multiDirRefinement::addCells
130 forAll(addedCells_, celli)
132 const labelList& added = addedCells_[celli];
136 label slave = added[i];
138 if (origCell[slave] == -1)
140 origCell[slave] = celli;
142 else if (origCell[slave] != celli)
145 <<
"Added cell " << slave <<
" has two different masters:"
146 << origCell[slave] <<
" , " << celli
155 label masterI = iter.key();
156 const label newCelli = iter.val();
158 while (origCell[masterI] != -1 && origCell[masterI] != masterI)
160 masterI = origCell[masterI];
163 if (masterI >= addedCells_.size())
166 <<
"Map of added cells contains master cell " << masterI
167 <<
" which is not a valid cell number" <<
endl
168 <<
"This means that the mesh is not consistent with the"
169 <<
" done refinement" <<
endl
181 else if (!added.found(newCelli))
183 const label sz = added.size();
184 added.setSize(sz + 1);
185 added[sz] = newCelli;
199 labelList nonHexLabels(cellLabels_.size());
207 label celli = cellLabels_[i];
211 hexLabels[hexI++] = celli;
215 nonHexLabels[nonHexI++] = celli;
219 nonHexLabels.setSize(nonHexI);
221 cellLabels_.transfer(nonHexLabels);
223 hexLabels.setSize(hexI);
229void Foam::multiDirRefinement::refineHex8
238 Pout<<
"multiDirRefinement : Refining hexes " << hexCells.size()
269 hexRefiner.consistentRefinement
280 for (
const label celli : hexCells)
282 hexCellSet.insert(celli, 1);
286 for (
const label celli : consistentCells)
288 auto iter = hexCellSet.find(celli);
297 <<
"Resulting mesh would not satisfy 2:1 ratio"
309 <<
"Resulting mesh would not satisfy 2:1 ratio"
310 <<
" when refining cell " << iter.key()
317 hexRefiner.setRefinement(consistentCells, meshMod);
323 if (morphMap.hasMotionPoints())
335 Pout<<
"multiDirRefinement : updated mesh at time "
339 hexRefiner.updateMesh(morphMap);
343 forAll(consistentCells, i)
345 addedCells_[consistentCells[i]].setSize(8);
349 const labelList& cellMap = morphMap.cellMap();
353 const label oldCelli = cellMap[celli];
355 if (addedCells_[oldCelli].size())
357 addedCells_[oldCelli][nAddedCells[oldCelli]++] = celli;
363void Foam::multiDirRefinement::refineAllDirs
375 forAll(cellDirections, dirI)
379 Pout<<
"multiDirRefinement : Refining " << cellLabels_.size()
380 <<
" cells in direction " << dirI <<
endl
384 const vectorField& dirField = cellDirections[dirI];
391 if (dirField.size() == 1)
396 Pout<<
"multiDirRefinement : Uniform refinement:"
397 << dirField[0] <<
endl;
402 const label celli = cellLabels_[refI];
404 refCells[refI] =
refineCell(celli, dirField[0]);
412 const label celli = cellLabels_[refI];
414 refCells[refI] =
refineCell(celli, dirField[celli]);
419 Map<label> splitMap = refiner.setRefinement(refCells);
422 addCells(
mesh, splitMap);
425 addCells(splitMap, cellLabels_);
428 if (dirField.size() != 1)
432 update(splitMap, cellDirections[i]);
438 Pout<<
"multiDirRefinement : Done refining direction " << dirI
439 <<
" resulting in " << cellLabels_.size() <<
" cells" <<
nl
446void Foam::multiDirRefinement::refineFromDict
455 const bool pureGeomCut(
dict.
get<
bool>(
"geometricCut"));
473 refineAllDirs(
mesh, cellDirections, cellWalker(), cutter, writeMesh);
481Foam::multiDirRefinement::multiDirRefinement
488 cellLabels_(cellLabels),
489 addedCells_(
mesh.nCells())
491 const bool useHex(
dict.get<
bool>(
"useHexTopology"));
493 const bool writeMesh(
dict.get<
bool>(
"writeMesh"));
497 if (useHex && dirNames.
size() == 3)
502 refineHex8(
mesh, hexCells, writeMesh);
511 directions cellDirections(
mesh,
dict);
513 refineFromDict(
mesh, cellDirections,
dict, writeMesh);
519Foam::multiDirRefinement::multiDirRefinement
523 const List<vectorField>& cellDirs,
527 cellLabels_(cellLabels),
528 addedCells_(
mesh.nCells())
530 const bool useHex(
dict.get<
bool>(
"useHexTopology"));
532 const bool writeMesh(
dict.get<
bool>(
"writeMesh"));
536 if (useHex && dirNames.
size() == 3)
541 refineHex8(
mesh, hexCells, writeMesh);
549 List<vectorField> cellDirections(cellDirs);
551 refineFromDict(
mesh, cellDirections,
dict, writeMesh);
557Foam::multiDirRefinement::multiDirRefinement
560 undoableMeshCutter& cutter,
561 const cellLooper& cellWalker,
564 const List<vectorField>& cellDirs,
568 cellLabels_(cellLabels),
569 addedCells_(
mesh.nCells())
572 List<vectorField> cellDirections(cellDirs);
574 refineAllDirs(
mesh, cellDirections, cellWalker, cutter, writeMesh);
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A HashTable to objects of type <T> with a label key.
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
void size(const label n)
Older name for setAddressableSize.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Abstract base class. Concrete implementations know how to cut a cell (i.e. determine a loop around th...
Maps a geometry to a set of cell primitives.
static const cellModel & ref(const modelType model)
Look up reference to cellModel by enumeration. Fatal on failure.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
Set of directions for each cell in the mesh. Either uniform and size=1 or one set of directions per c...
const Time & time() const
Return the top-level database.
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
Implementation of cellLooper. Does pure geometric cut through cell.
Implementation of cellLooper.
Refinement of (split) hexes using polyTopoChange.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Does multiple pass refinement to refine cells in multiple directions.
Mesh consisting of general polyhedral cells.
const fileName & facesInstance() const
Return the current instance directory for faces.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh").
Direct mesh changes based on v1.3 polyTopoChange syntax.
Cell-face mesh analysis engine.
const cellShapeList & cellShapes() const
Return cell shapes.
label nPoints() const noexcept
Number of mesh points.
label nCells() const noexcept
Number of mesh cells.
Container with cells to refine. Refinement given as single direction.
All refinement history. Used in unrefinement.
Utility class to do iterating meshCutter until all requests satisfied.
The main refinement handler. Gets cellCuts which is structure that describes which cells are to be cu...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Namespace for handling debugging switches.
List< word > wordList
List of word.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
List< label > labelList
A List of labels.
IOstream & hex(IOstream &io)
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
List< cellShape > cellShapeList
List of cellShape.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.