Updates to polyhedralRefinement and dynamicPolyRefinementFvMesh
1. Switched from pointBasedConsistency to edgeBasedConsistency in order to allow more than 2 refinement levels in a correct way (hopefully), 2. Note on parallelisation: getting edge cell addressing across processor boundaries is tricky, but if we use more stringent 1:1 face refinement across coupled boundaries, then the edge based consistency becomes a local operation (at least I'm 99% sure it does: hard to think of all variants with arbitrary polyhedra), 3. Added an option to skip unrefinement if both refinement/unrefinement are triggered for a single step. This is switched off by default since performing refinement/unrefinement in a single go should work without issues.
This commit is contained in:
parent
4a4056f9f5
commit
9ee5d49575
5 changed files with 219 additions and 182 deletions
|
@ -2930,15 +2930,19 @@ Foam::label Foam::polyhedralRefinement::faceConsistentRefinement
|
||||||
const label curOwnLevel =
|
const label curOwnLevel =
|
||||||
cellsToRefine[own] ? cellLevel_[own] + 1 : cellLevel_[own];
|
cellsToRefine[own] ? cellLevel_[own] + 1 : cellLevel_[own];
|
||||||
|
|
||||||
if (neiLevel[i] > (curOwnLevel + 1))
|
// Note: we are using more stringent 1:1 consistency across coupled
|
||||||
|
// boundaries in order to simplify handling of edge based consistency
|
||||||
|
// checks for parallel runs
|
||||||
|
if (neiLevel[i] > curOwnLevel)
|
||||||
{
|
{
|
||||||
// Neighbour level is higher than owner level + 1, owner must be
|
// Neighbour level is higher than owner level, owner must be
|
||||||
// marked for refinement
|
// marked for refinement
|
||||||
cellsToRefine[own] = true;
|
cellsToRefine[own] = true;
|
||||||
++nAddCells;
|
++nAddCells;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: other possibility (that owner level is higher than neighbour
|
// Note: other possibility (that owner level is higher than neighbour
|
||||||
// level + 1) is taken into account on the other side automatically
|
// level) is taken into account on the other side automatically
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return number of added cells
|
// Return number of added cells
|
||||||
|
@ -2946,7 +2950,7 @@ Foam::label Foam::polyhedralRefinement::faceConsistentRefinement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::polyhedralRefinement::pointConsistentRefinement
|
Foam::label Foam::polyhedralRefinement::edgeConsistentRefinement
|
||||||
(
|
(
|
||||||
boolList& cellsToRefine
|
boolList& cellsToRefine
|
||||||
) const
|
) const
|
||||||
|
@ -2954,92 +2958,75 @@ Foam::label Foam::polyhedralRefinement::pointConsistentRefinement
|
||||||
// Count number of cells that will be added
|
// Count number of cells that will be added
|
||||||
label nAddCells = 0;
|
label nAddCells = 0;
|
||||||
|
|
||||||
// Maximum surrounding cell refinement level for each point
|
// Algorithm: loop over all edges and visit all unique cell pairs sharing
|
||||||
labelList maxRefLevel(mesh_.nPoints(), 0);
|
// this particular edge. Then, ensure 2:1 edge consistency by marking
|
||||||
|
// cell with lower level for refinement
|
||||||
|
|
||||||
// Get point cells
|
// Get edge cells
|
||||||
const labelListList& meshPointCells = mesh_.pointCells();
|
const labelListList& meshEdgeCells = mesh_.edgeCells();
|
||||||
|
|
||||||
// Loop through all points and collect maximum point level for each point
|
// Loop through all mesh edges
|
||||||
forAll (maxRefLevel, pointI)
|
forAll (meshEdgeCells, edgeI)
|
||||||
{
|
{
|
||||||
// Get the cells for this point
|
// Get current edge cells
|
||||||
const labelList& curCells = meshPointCells[pointI];
|
const labelList& curEdgeCells = meshEdgeCells[edgeI];
|
||||||
|
|
||||||
// Get reference to maximum pooint level for this point
|
// Loop through all edge cells
|
||||||
label& curMaxPointLevel = maxRefLevel[pointI];
|
forAll (curEdgeCells, i)
|
||||||
|
|
||||||
// Find maximum refinement level for this point
|
|
||||||
forAll (curCells, i)
|
|
||||||
{
|
{
|
||||||
// Get cell index and "future" cell level
|
// Get first cell index
|
||||||
const label& curCellI = curCells[i];
|
const label& cellI = curEdgeCells[i];
|
||||||
const label curCellLevel =
|
|
||||||
cellsToRefine[curCellI]
|
|
||||||
? cellLevel_[curCellI] + 1
|
|
||||||
: cellLevel_[curCellI];
|
|
||||||
|
|
||||||
// Update maximum point level if the curCellLevel is higher
|
// Loop through remaining edge cells
|
||||||
curMaxPointLevel = max(curMaxPointLevel, curCellLevel);
|
for (label j = i + 1; j < curEdgeCells.size(); ++j)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sync maximum refinement level across coupled boundaries
|
|
||||||
syncTools::syncPointList
|
|
||||||
(
|
|
||||||
mesh_,
|
|
||||||
maxRefLevel,
|
|
||||||
maxEqOp<label>(),
|
|
||||||
0, // Null value
|
|
||||||
true // Apply separation for parallel cyclics
|
|
||||||
);
|
|
||||||
|
|
||||||
// Now that the levels are synced, go through all points and add cells to
|
|
||||||
// refine
|
|
||||||
forAll (maxRefLevel, pointI)
|
|
||||||
{
|
|
||||||
// Get the cells for this point
|
|
||||||
const labelList& curCells = meshPointCells[pointI];
|
|
||||||
|
|
||||||
// Loop through these point cells and set cells for refinement which
|
|
||||||
// would end up having refinement level smaller than maximum level - 1
|
|
||||||
forAll (curCells, i)
|
|
||||||
{
|
|
||||||
// Get cell index, reference to refinement flag and "future" cell
|
|
||||||
// level
|
|
||||||
const label& curCellI = curCells[i];
|
|
||||||
bool& willBeRefined = cellsToRefine[curCellI];
|
|
||||||
const label curCellLevel =
|
|
||||||
willBeRefined
|
|
||||||
? cellLevel_[curCellI] + 1
|
|
||||||
: cellLevel_[curCellI];
|
|
||||||
|
|
||||||
if (curCellLevel < maxRefLevel[pointI] - 1)
|
|
||||||
{
|
{
|
||||||
if (!willBeRefined)
|
// Get second cell index
|
||||||
|
const label& cellJ = curEdgeCells[j];
|
||||||
|
|
||||||
|
// Get levels of the two cells. If the cell is marked for
|
||||||
|
// refinement, the level is current level + 1, otherwise it is
|
||||||
|
// equal to the current level
|
||||||
|
|
||||||
|
// Note: cellsToRefine flag for both cellI and cellJ might
|
||||||
|
// change, this is why we need to recalculate cellI level here
|
||||||
|
const label cellILevel =
|
||||||
|
cellsToRefine[cellI]
|
||||||
|
? cellLevel_[cellI] + 1
|
||||||
|
: cellLevel_[cellI];
|
||||||
|
|
||||||
|
const label cellJLevel =
|
||||||
|
cellsToRefine[cellJ]
|
||||||
|
? cellLevel_[cellJ] + 1
|
||||||
|
: cellLevel_[cellJ];
|
||||||
|
|
||||||
|
if (cellILevel > cellJLevel + 1)
|
||||||
{
|
{
|
||||||
// Cell has not been marked for refinement, mark the cell
|
// Level of cellI is higher than level of cellJ + 1, cellJ
|
||||||
// for refinement and increment the counter
|
// must be marked for refinement
|
||||||
willBeRefined = true;
|
cellsToRefine[cellJ] = true;
|
||||||
++nAddCells;
|
++nAddCells;
|
||||||
}
|
}
|
||||||
else
|
else if (cellJLevel > cellILevel + 1)
|
||||||
{
|
{
|
||||||
FatalErrorIn
|
// Level of cellJ is higher than level of cellI + 1, cellI
|
||||||
(
|
// must be marked for refinement
|
||||||
"label polyhedralRefinement::pointConsistentRefinement"
|
cellsToRefine[cellI] = true;
|
||||||
"(boolList cellsToRefine) const"
|
++nAddCells;
|
||||||
) << "Cell: " << curCellI << " is marked for refinement,"
|
|
||||||
<< "but the 4:1 consistency cannot be ensured." << nl
|
|
||||||
<< "This is probably because the refinement and "
|
|
||||||
<< "unrefinement regions are very close." << nl
|
|
||||||
<< "Try increasing nUnrefinementBufferLayers. "
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: in order to avoid very difficult and time-consuming parallelisation
|
||||||
|
// of edge cell connectivity and edge cell values, we enforce a more
|
||||||
|
// stringent face-based consistency across processor boundaries. Basically,
|
||||||
|
// if a face-based consistency of 1:1 (not 2:1 as for ordinary faces) is
|
||||||
|
// ensured, the edge-based consistency becomes a local operation (I'm not
|
||||||
|
// 100% sure to be honest since there are countless variants when dealing
|
||||||
|
// with arbitrary polyhedral cells).
|
||||||
|
// See faceConsistentRefinement for details. VV, 17/Apr/2018.
|
||||||
|
|
||||||
|
// Return number of added cells
|
||||||
return nAddCells;
|
return nAddCells;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3074,7 +3061,7 @@ Foam::label Foam::polyhedralRefinement::faceConsistentUnrefinement
|
||||||
const label neiLevel =
|
const label neiLevel =
|
||||||
cellsToUnrefine[nei] ? cellLevel_[nei] - 1 : cellLevel_[nei];
|
cellsToUnrefine[nei] ? cellLevel_[nei] - 1 : cellLevel_[nei];
|
||||||
|
|
||||||
if (ownLevel < (neiLevel -1))
|
if (ownLevel < (neiLevel - 1))
|
||||||
{
|
{
|
||||||
// Owner level is smaller than neighbour level - 1, we must not
|
// Owner level is smaller than neighbour level - 1, we must not
|
||||||
// unrefine owner
|
// unrefine owner
|
||||||
|
@ -3158,9 +3145,12 @@ Foam::label Foam::polyhedralRefinement::faceConsistentUnrefinement
|
||||||
const label curOwnLevel =
|
const label curOwnLevel =
|
||||||
cellsToUnrefine[own] ? cellLevel_[own] - 1 : cellLevel_[own];
|
cellsToUnrefine[own] ? cellLevel_[own] - 1 : cellLevel_[own];
|
||||||
|
|
||||||
if (curOwnLevel < (neiLevel[i] - 1))
|
// Note: we are using more stringent 1:1 consistency across coupled
|
||||||
|
// boundaries in order to simplify handling of edge based consistency
|
||||||
|
// checkes for parallel runs
|
||||||
|
if (curOwnLevel < neiLevel[i])
|
||||||
{
|
{
|
||||||
// Owner level is smaller than neighbour level - 1, we must not
|
// Owner level is smaller than neighbour level, we must not
|
||||||
// unrefine owner
|
// unrefine owner
|
||||||
|
|
||||||
// Check whether the cell has not been marked for unrefinement
|
// Check whether the cell has not been marked for unrefinement
|
||||||
|
@ -3188,7 +3178,7 @@ Foam::label Foam::polyhedralRefinement::faceConsistentUnrefinement
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: other possibility (that neighbour level is smaller than owner
|
// Note: other possibility (that neighbour level is smaller than owner
|
||||||
// level - 1) is taken into account on the other side automatically
|
// level) is taken into account on the other side automatically
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return number of local cells removed from unrefinement
|
// Return number of local cells removed from unrefinement
|
||||||
|
@ -3196,107 +3186,129 @@ Foam::label Foam::polyhedralRefinement::faceConsistentUnrefinement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::polyhedralRefinement::pointConsistentUnrefinement
|
Foam::label Foam::polyhedralRefinement::edgeConsistentUnrefinement
|
||||||
(
|
(
|
||||||
boolList& cellsToUnrefine
|
boolList& cellsToUnrefine
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
// Count number of cells removed from unrefinement
|
// Count number of cells that will be removed
|
||||||
label nRemCells = 0;
|
label nRemCells = 0;
|
||||||
|
|
||||||
// Minimum cell refinement level for each point. Note: initialise with
|
// Algorithm: loop over all edges and visit all unique cell pairs sharing
|
||||||
// labelMax
|
// this particular edge. Then, ensure 2:1 edge consistency by protecting the
|
||||||
labelList minRefLevel(mesh_.nPoints(), labelMax);
|
// cell with lower level from unrefinement
|
||||||
|
|
||||||
// Get point cells
|
// Get edge cells
|
||||||
const labelListList& meshPointCells = mesh_.pointCells();
|
const labelListList& meshEdgeCells = mesh_.edgeCells();
|
||||||
|
|
||||||
// Loop through all points and collect minimum point level for each point
|
// Loop through all mesh edges
|
||||||
forAll (minRefLevel, pointI)
|
forAll (meshEdgeCells, edgeI)
|
||||||
{
|
{
|
||||||
// Get the cell for this point
|
// Get current edge cells
|
||||||
const labelList& curCells = meshPointCells[pointI];
|
const labelList& curEdgeCells = meshEdgeCells[edgeI];
|
||||||
|
|
||||||
// Get reference to minimum point level for this point
|
// Loop through all edge cells
|
||||||
label& curMinPointLevel = minRefLevel[pointI];
|
forAll (curEdgeCells, i)
|
||||||
|
|
||||||
// Find minimum refinement level for this point
|
|
||||||
forAll (curCells, i)
|
|
||||||
{
|
{
|
||||||
// Get cell index and "future" cell level
|
// Get first cell index
|
||||||
const label& curCellI = curCells[i];
|
const label& cellI = curEdgeCells[i];
|
||||||
const label curCellLevel =
|
|
||||||
cellsToUnrefine[curCellI]
|
|
||||||
? cellLevel_[curCellI] - 1
|
|
||||||
: cellLevel_[curCellI];
|
|
||||||
|
|
||||||
// Update minimum point level if the curCellLevel is smaller
|
// Loop through remaining edge cells
|
||||||
curMinPointLevel = min(curMinPointLevel, curCellLevel);
|
for (label j = i + 1; j < curEdgeCells.size(); ++j)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sync minimum refinement level across coupled boundaries
|
|
||||||
syncTools::syncPointList
|
|
||||||
(
|
|
||||||
mesh_,
|
|
||||||
minRefLevel,
|
|
||||||
minEqOp<label>(),
|
|
||||||
0, // Null value
|
|
||||||
true // Apply separation for parallel cyclics
|
|
||||||
);
|
|
||||||
|
|
||||||
// Now that the levels are synced, go through all points and protect some
|
|
||||||
// cells from unrefinement
|
|
||||||
forAll (minRefLevel, pointI)
|
|
||||||
{
|
|
||||||
// Get the cells for this point
|
|
||||||
const labelList& curCells = meshPointCells[pointI];
|
|
||||||
|
|
||||||
// Loop through these point cells and protected cells from unrefinement
|
|
||||||
// which would end up having refinement level greater than level + 1
|
|
||||||
forAll (curCells, i)
|
|
||||||
{
|
|
||||||
// Get cell index, reference to unrefinement flag and "future" cell
|
|
||||||
// level
|
|
||||||
const label& curCellI = curCells[i];
|
|
||||||
bool& willBeUnrefined = cellsToUnrefine[curCellI];
|
|
||||||
const label curCellLevel =
|
|
||||||
willBeUnrefined
|
|
||||||
? cellLevel_[curCellI] - 1
|
|
||||||
: cellLevel_[curCellI];
|
|
||||||
|
|
||||||
if (curCellLevel > minRefLevel[pointI] + 1)
|
|
||||||
{
|
{
|
||||||
if (willBeUnrefined)
|
// Get second cell index
|
||||||
|
const label& cellJ = curEdgeCells[j];
|
||||||
|
|
||||||
|
// Get levels of the two cells. If the cell is marked for
|
||||||
|
// unrefinement, the level is current level - 1, otherwise it is
|
||||||
|
// equal to the current level
|
||||||
|
|
||||||
|
// Note: cellsToUnrefine flag for both cellI and cellJ might
|
||||||
|
// change, this is why we need to recalculate cellI level here
|
||||||
|
const label cellILevel =
|
||||||
|
cellsToUnrefine[cellI]
|
||||||
|
? cellLevel_[cellI] - 1
|
||||||
|
: cellLevel_[cellI];
|
||||||
|
|
||||||
|
const label cellJLevel =
|
||||||
|
cellsToUnrefine[cellJ]
|
||||||
|
? cellLevel_[cellJ] - 1
|
||||||
|
: cellLevel_[cellJ];
|
||||||
|
|
||||||
|
if (cellILevel < cellJLevel - 1)
|
||||||
{
|
{
|
||||||
// Cell has been marked for unrefinement, protect the cell
|
// Level of cellI is smaller than level of cellJ - 1, cellI
|
||||||
// from unrefinement and increment the counter
|
// must be protected from unrefinement
|
||||||
willBeUnrefined = false;
|
|
||||||
|
// Check whether the cell has not been marked for
|
||||||
|
// unrefinement
|
||||||
|
if (!cellsToUnrefine[cellI])
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"label polyhedralRefinement::"
|
||||||
|
"edgeConsistentUnrefinement"
|
||||||
|
"(boolList& cellsToUnrefine)"
|
||||||
|
) << "Cell not marked for unrefinement, indicating a"
|
||||||
|
<< " previous unnoticed problem with unrefinement."
|
||||||
|
<< nl
|
||||||
|
<< "cellI: " << cellI << ", cellJ: " << cellJ
|
||||||
|
<< nl
|
||||||
|
<< "Level of cellI: " << cellILevel
|
||||||
|
<< ", level of cellJ: " << cellJLevel << nl
|
||||||
|
<< "This is probably because the refinement and "
|
||||||
|
<< "unrefinement regions are very close." << nl
|
||||||
|
<< "Try increasing nUnrefinementBufferLayers. "
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
cellsToUnrefine[cellI] = false;
|
||||||
|
++nRemCells;
|
||||||
|
}
|
||||||
|
else if (cellJLevel < cellILevel - 1)
|
||||||
|
{
|
||||||
|
// Level of cellJ is smaller than level of cellI - 1, cellJ
|
||||||
|
// must be protected from unrefinement
|
||||||
|
|
||||||
|
// Check whether the cell has not been marked for
|
||||||
|
// unrefinement
|
||||||
|
if (!cellsToUnrefine[cellJ])
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"label polyhedralRefinement::"
|
||||||
|
"edgeConsistentUnrefinement"
|
||||||
|
"(boolList& cellsToUnrefine)"
|
||||||
|
) << "Cell not marked for unrefinement, indicating a"
|
||||||
|
<< " previous unnoticed problem with unrefinement."
|
||||||
|
<< nl
|
||||||
|
<< "cellI: " << cellI << ", cellJ: " << cellJ
|
||||||
|
<< nl
|
||||||
|
<< "Level of cellI: " << cellILevel
|
||||||
|
<< ", level of cellJ: " << cellJLevel << nl
|
||||||
|
<< "This is probably because the refinement and "
|
||||||
|
<< "unrefinement regions are very close." << nl
|
||||||
|
<< "Try increasing nUnrefinementBufferLayers. "
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
cellsToUnrefine[cellJ] = false;
|
||||||
++nRemCells;
|
++nRemCells;
|
||||||
}
|
}
|
||||||
// Note: I am pretty sure that this check is redundant and
|
|
||||||
// causes unnecessary issues when more than 2 maximum refinement
|
|
||||||
// levels are used. In case of problems, take a detailed look
|
|
||||||
// here. VV, 22/Mar/2018.
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// FatalErrorIn
|
|
||||||
// (
|
|
||||||
// "label polyhedralRefinement::"
|
|
||||||
// "pointConsistentUnrefinement"
|
|
||||||
// "(boolList cellsToRefine) const"
|
|
||||||
// ) << "Cell: " << curCellI << " is not marked for "
|
|
||||||
// << "unrefinement, but the 4:1"
|
|
||||||
// << " point consistency cannot be ensured." << nl
|
|
||||||
// << "This is probably because the refinement and "
|
|
||||||
// << "unrefinement regions are very close." << nl
|
|
||||||
// << "Try increasing nUnrefinementBufferLayers. "
|
|
||||||
// << abort(FatalError);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Note: in order to avoid very difficult and time-consuming parallelisation
|
||||||
|
// of edge cell connectivity and edge cell values, we enforce a more
|
||||||
|
// stringent face-based consistency across processor boundaries. Basically,
|
||||||
|
// if a face-based consistency of 1:1 (not 2:1 as for ordinary faces) is
|
||||||
|
// ensured, the edge-based consistency becomes a local operation (I'm not
|
||||||
|
// 100% sure to be honest whether this is true all the time since there are
|
||||||
|
// countless variants when dealing with arbitrary polyhedral cells).
|
||||||
|
// See faceConsistentRefinement for details. VV, 3/Apr/2018.
|
||||||
|
|
||||||
|
// Return number of removed cells
|
||||||
return nRemCells;
|
return nRemCells;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3346,9 +3358,9 @@ Foam::polyhedralRefinement::polyhedralRefinement
|
||||||
faceRemover_(mesh_, GREAT), // Merge boundary faces wherever possible
|
faceRemover_(mesh_, GREAT), // Merge boundary faces wherever possible
|
||||||
maxCells_(readLabel(dict.lookup("maxCells"))),
|
maxCells_(readLabel(dict.lookup("maxCells"))),
|
||||||
maxRefinementLevel_(readLabel(dict.lookup("maxRefinementLevel"))),
|
maxRefinementLevel_(readLabel(dict.lookup("maxRefinementLevel"))),
|
||||||
pointBasedConsistency_
|
edgeBasedConsistency_
|
||||||
(
|
(
|
||||||
dict.lookupOrDefault<Switch>("pointBasedConsistency", true)
|
dict.lookupOrDefault<Switch>("edgeBasedConsistency", true)
|
||||||
),
|
),
|
||||||
nRefinementBufferLayers_
|
nRefinementBufferLayers_
|
||||||
(
|
(
|
||||||
|
@ -3426,7 +3438,7 @@ Foam::polyhedralRefinement::polyhedralRefinement
|
||||||
|
|
||||||
// If the maximum refinementLevel is greater than 2 and the user insists on
|
// If the maximum refinementLevel is greater than 2 and the user insists on
|
||||||
// not using point based refinement strategy, issue a warning
|
// not using point based refinement strategy, issue a warning
|
||||||
if (!pointBasedConsistency_ && maxRefinementLevel_ > 2)
|
if (!edgeBasedConsistency_ && maxRefinementLevel_ > 2)
|
||||||
{
|
{
|
||||||
WarningIn
|
WarningIn
|
||||||
(
|
(
|
||||||
|
@ -3445,7 +3457,7 @@ Foam::polyhedralRefinement::polyhedralRefinement
|
||||||
<< " 8:1 point conflicts."
|
<< " 8:1 point conflicts."
|
||||||
<< nl
|
<< nl
|
||||||
<< "In order to supress this message and use point based"
|
<< "In order to supress this message and use point based"
|
||||||
<< " consistency checks, set pointBasedConsistency to true."
|
<< " consistency checks, set edgeBasedConsistency to true."
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3583,11 +3595,11 @@ void Foam::polyhedralRefinement::setCellsToRefine
|
||||||
// Reset counter at the beginning of each iteration
|
// Reset counter at the beginning of each iteration
|
||||||
nAddCells = 0;
|
nAddCells = 0;
|
||||||
|
|
||||||
if (pointBasedConsistency_)
|
if (edgeBasedConsistency_)
|
||||||
{
|
{
|
||||||
// Check for 4:1 point based consistent refinement. Updates
|
// Check for 4:1 edge based consistent refinement. Updates
|
||||||
// cellsToRefine and returns number of cells added in this iteration
|
// cellsToRefine and returns number of cells added in this iteration
|
||||||
nAddCells += pointConsistentRefinement(refineCell);
|
nAddCells += edgeConsistentRefinement(refineCell);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for 2:1 face based consistent refinement. Updates cellsToRefine
|
// Check for 2:1 face based consistent refinement. Updates cellsToRefine
|
||||||
|
@ -3836,12 +3848,12 @@ void Foam::polyhedralRefinement::setSplitPointsToUnrefine
|
||||||
// Reset number of removed cells from unrefinement for this iteration
|
// Reset number of removed cells from unrefinement for this iteration
|
||||||
nRemCells = 0;
|
nRemCells = 0;
|
||||||
|
|
||||||
if (pointBasedConsistency_)
|
if (edgeBasedConsistency_)
|
||||||
{
|
{
|
||||||
// Check for 4:1 point based consistent unrefinement. Updates
|
// Check for 4:1 edge based consistent unrefinement. Updates
|
||||||
// cellsToUnrefine and returns number of removed cells from
|
// cellsToUnrefine and returns number of removed cells from
|
||||||
// unrefinement in this iteration
|
// unrefinement in this iteration
|
||||||
nRemCells += pointConsistentUnrefinement(cellsToUnrefine);
|
nRemCells += edgeConsistentUnrefinement(cellsToUnrefine);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for 2:1 face based consistent unrefinement. Updates
|
// Check for 2:1 face based consistent unrefinement. Updates
|
||||||
|
@ -4126,7 +4138,7 @@ void Foam::polyhedralRefinement::write(Ostream& os) const
|
||||||
<< name() << nl
|
<< name() << nl
|
||||||
<< maxCells_ << nl
|
<< maxCells_ << nl
|
||||||
<< maxRefinementLevel_ << nl
|
<< maxRefinementLevel_ << nl
|
||||||
<< pointBasedConsistency_ << nl
|
<< edgeBasedConsistency_ << nl
|
||||||
<< nRefinementBufferLayers_ << nl
|
<< nRefinementBufferLayers_ << nl
|
||||||
<< nUnrefinementBufferLayers_ << endl;
|
<< nUnrefinementBufferLayers_ << endl;
|
||||||
}
|
}
|
||||||
|
@ -4145,7 +4157,7 @@ void Foam::polyhedralRefinement::writeDict(Ostream& os) const
|
||||||
<< token::END_STATEMENT << nl
|
<< token::END_STATEMENT << nl
|
||||||
<< " maxRefinementLevel " << maxRefinementLevel_
|
<< " maxRefinementLevel " << maxRefinementLevel_
|
||||||
<< token::END_STATEMENT << nl
|
<< token::END_STATEMENT << nl
|
||||||
<< " pointBasedConsistency " << pointBasedConsistency_
|
<< " edgeBasedConsistency " << edgeBasedConsistency_
|
||||||
<< token::END_STATEMENT << nl
|
<< token::END_STATEMENT << nl
|
||||||
<< " nRefinementBufferLayers " << nRefinementBufferLayers_
|
<< " nRefinementBufferLayers " << nRefinementBufferLayers_
|
||||||
<< token::END_STATEMENT << nl
|
<< token::END_STATEMENT << nl
|
||||||
|
|
|
@ -124,8 +124,8 @@ private:
|
||||||
//- Maximum number of refinement levels for a given cell
|
//- Maximum number of refinement levels for a given cell
|
||||||
label maxRefinementLevel_;
|
label maxRefinementLevel_;
|
||||||
|
|
||||||
//- Switch whether to use point based consistency on refinement
|
//- Switch whether to use edge based consistency on refinement
|
||||||
Switch pointBasedConsistency_;
|
Switch edgeBasedConsistency_;
|
||||||
|
|
||||||
//- Number of buffer layers for refinement
|
//- Number of buffer layers for refinement
|
||||||
label nRefinementBufferLayers_;
|
label nRefinementBufferLayers_;
|
||||||
|
@ -363,17 +363,17 @@ private:
|
||||||
// is obtained. Returns local number of cells changed
|
// is obtained. Returns local number of cells changed
|
||||||
label faceConsistentRefinement(boolList& cellsToRefine) const;
|
label faceConsistentRefinement(boolList& cellsToRefine) const;
|
||||||
|
|
||||||
//- Updates cellsToRefine such that a point consistent 4:1 refinement
|
//- Updates cellsToRefine such that an edge consistent 4:1 refinement
|
||||||
// is obtained. Returns local number of cells changed
|
// is obtained. Returns local number of cells changed
|
||||||
label pointConsistentRefinement(boolList& cellsToRefine) const;
|
label edgeConsistentRefinement(boolList& cellsToRefine) const;
|
||||||
|
|
||||||
//- Updates cellsToUnrefine such that a face consistent 2:1
|
//- Updates cellsToUnrefine such that a face consistent 2:1
|
||||||
// unrefinement is obtained. Returns local number of cells changed
|
// unrefinement is obtained. Returns local number of cells changed
|
||||||
label faceConsistentUnrefinement(boolList& cellsToUnrefine) const;
|
label faceConsistentUnrefinement(boolList& cellsToUnrefine) const;
|
||||||
|
|
||||||
//- Updates cellsToUnrefine such that a point consistent 4:1
|
//- Updates cellsToUnrefine such that an edge consistent 4:1
|
||||||
// unrefinement is obtained. Returns local number of cells changed
|
// unrefinement is obtained. Returns local number of cells changed
|
||||||
label pointConsistentUnrefinement(boolList& cellsToUnrefine) const;
|
label edgeConsistentUnrefinement(boolList& cellsToUnrefine) const;
|
||||||
|
|
||||||
|
|
||||||
// Copy control
|
// Copy control
|
||||||
|
|
|
@ -27,6 +27,12 @@ dynamicPolyRefinementFvMeshCoeffs
|
||||||
// Unrefine every unrefineInterval step
|
// Unrefine every unrefineInterval step
|
||||||
unrefineInterval 1;
|
unrefineInterval 1;
|
||||||
|
|
||||||
|
// Separate refinement/unrefinement steps. In case this is switched on,
|
||||||
|
// if both refinement and unrefinement should have been performed in a
|
||||||
|
// single step, unrefinement is skipped. Switched off by default, meaning
|
||||||
|
// that it should be safe to perform both at the same time
|
||||||
|
separateUpdates false;
|
||||||
|
|
||||||
// Refinement selection criteria
|
// Refinement selection criteria
|
||||||
refinementSelection
|
refinementSelection
|
||||||
{
|
{
|
||||||
|
@ -59,9 +65,9 @@ dynamicPolyRefinementFvMeshCoeffs
|
||||||
// level inconsistencies
|
// level inconsistencies
|
||||||
nUnrefinementBufferLayers 4;
|
nUnrefinementBufferLayers 4;
|
||||||
|
|
||||||
// Whether to use point based consistency check. Needed when one allows more
|
// Whether to use edge based consistency check. Needed when one allows more
|
||||||
// than 2 refinement levels (automatically switched on in that case)
|
// than 2 refinement levels (automatically switched on)
|
||||||
pointBasedRefinement yes;
|
edgeBasedConsistency yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ void Foam::dynamicPolyRefinementFvMesh::readDict()
|
||||||
<< " trigerring within a certain time step and should be > 0"
|
<< " trigerring within a certain time step and should be > 0"
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
unrefineInterval_ = readLabel(refinementDict_.lookup("unrefineInterval"));
|
unrefineInterval_ = readLabel(refinementDict_.lookup("unrefineInterval"));
|
||||||
if (refineInterval_ < 1)
|
if (refineInterval_ < 1)
|
||||||
{
|
{
|
||||||
|
@ -69,6 +69,10 @@ void Foam::dynamicPolyRefinementFvMesh::readDict()
|
||||||
<< " trigerring within a certain time step and should be > 0"
|
<< " trigerring within a certain time step and should be > 0"
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read separate updates switch
|
||||||
|
separateUpdates_ =
|
||||||
|
refinementDict_.lookupOrDefault<Switch>("separateUpdates", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,6 +101,10 @@ Foam::dynamicPolyRefinementFvMesh::dynamicPolyRefinementFvMesh
|
||||||
),
|
),
|
||||||
refineInterval_(readLabel(refinementDict_.lookup("refineInterval"))),
|
refineInterval_(readLabel(refinementDict_.lookup("refineInterval"))),
|
||||||
unrefineInterval_(readLabel(refinementDict_.lookup("unrefineInterval"))),
|
unrefineInterval_(readLabel(refinementDict_.lookup("unrefineInterval"))),
|
||||||
|
separateUpdates_
|
||||||
|
(
|
||||||
|
refinementDict_.lookupOrDefault<Switch>("separateUpdates", false)
|
||||||
|
),
|
||||||
curTimeIndex_(-1),
|
curTimeIndex_(-1),
|
||||||
|
|
||||||
refinementSelectionPtr_(refinementSelection::New(*this, refinementDict_))
|
refinementSelectionPtr_(refinementSelection::New(*this, refinementDict_))
|
||||||
|
@ -148,7 +156,14 @@ bool Foam::dynamicPolyRefinementFvMesh::update()
|
||||||
|
|
||||||
// Check whether to perform refinement and/or unrefinement
|
// Check whether to perform refinement and/or unrefinement
|
||||||
const bool performRefinement = timeID % refineInterval_ == 0;
|
const bool performRefinement = timeID % refineInterval_ == 0;
|
||||||
const bool performUnrefinement = timeID % unrefineInterval_ == 0;
|
|
||||||
|
// Skip performing refinement/unrefinement in the same step if
|
||||||
|
// separateUpdates flag is switched on
|
||||||
|
bool performUnrefinement = timeID % unrefineInterval_ == 0;
|
||||||
|
if (performRefinement && separateUpdates_)
|
||||||
|
{
|
||||||
|
performUnrefinement = false;
|
||||||
|
}
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
|
|
|
@ -68,6 +68,10 @@ class dynamicPolyRefinementFvMesh
|
||||||
//- Unrefinement interval
|
//- Unrefinement interval
|
||||||
label unrefineInterval_;
|
label unrefineInterval_;
|
||||||
|
|
||||||
|
//- Separate refinement/unrefinement: off by default, meaning that
|
||||||
|
// refinement and unrefinement can be performed in the same step
|
||||||
|
Switch separateUpdates_;
|
||||||
|
|
||||||
//- Current time index (helper variable to skip multiple topo changes in
|
//- Current time index (helper variable to skip multiple topo changes in
|
||||||
// a single time step)
|
// a single time step)
|
||||||
label curTimeIndex_;
|
label curTimeIndex_;
|
||||||
|
|
Reference in a new issue