Commit 53be1998 authored by mattijs's avatar mattijs Committed by Andrew Heather
Browse files

CONTRIBUTION: overset: handling patch interactions. See #1288.

- in case of cell overlapping a patch : set cell to hole always
- in case of cell changing from hole to calculated: set to hole
  and continue. Do so before 'flood filling' holes.
Patch supplied by Nicolas Edh.
parent cad37cf6
......@@ -585,18 +585,24 @@ void Foam::cellCellStencils::cellVolumeWeight::combineCellTypes
case PATCH:
{
if (allCellTypes[cellI] != HOLE)
{
scalar overlapVol = sum(weights[subCellI]);
scalar v = mesh_.V()[cellI];
if (overlapVol < (1.0-overlapTolerance_)*v)
{
//Pout<< "** Patch overlap:" << cellI
// << " at:" << mesh_.cellCentres()[cellI] << endl;
allCellTypes[cellI] = HOLE;
validDonors = false;
}
}
// Patch-patch interaction... For now disable always
allCellTypes[cellI] = HOLE;
validDonors = false;
// Alternative is to look at the amount of overlap but this
// is not very robust
//if (allCellTypes[cellI] != HOLE)
//{
// scalar overlapVol = sum(weights[subCellI]);
// scalar v = mesh_.V()[cellI];
// if (overlapVol < (1.0-overlapTolerance_)*v)
// {
// //Pout<< "** Patch overlap:" << cellI
// // << " at:" << mesh_.cellCentres()[cellI] << endl;
// allCellTypes[cellI] = HOLE;
// validDonors = false;
// }
//}
}
break;
......@@ -994,6 +1000,41 @@ bool Foam::cellCellStencils::cellVolumeWeight::update()
}
// Check previous iteration cellTypes_ for any hole->calculated changes
// If so set the cell either to interpolated (if there are donors) or
// holes (if there are no donors). Note that any interpolated cell might
// still be overwritten by the flood filling
{
label nCalculated = 0;
forAll(cellTypes_, celli)
{
if (allCellTypes[celli] == CALCULATED && cellTypes_[celli] == HOLE)
{
if (allStencil[celli].size() == 0)
{
// Reset to hole
allCellTypes[celli] = HOLE;
allWeights[celli].clear();
allStencil[celli].clear();
}
else
{
allCellTypes[celli] = INTERPOLATED;
nCalculated++;
}
}
}
if (debug)
{
Pout<< "Detected " << nCalculated << " cells changing from hole"
<< " to calculated. Changed these to interpolated"
<< endl;
}
}
// Mark unreachable bits
findHoles(globalCells, mesh_, zoneID, allStencil, allCellTypes);
......@@ -1022,40 +1063,6 @@ bool Foam::cellCellStencils::cellVolumeWeight::update()
tfld().write();
}
// Check previous iteration cellTypes_ for any hole->calculated changes
{
label nCalculated = 0;
forAll(cellTypes_, celli)
{
if (allCellTypes[celli] == CALCULATED && cellTypes_[celli] == HOLE)
{
if (allStencil[celli].size() == 0)
{
FatalErrorInFunction
<< "Cell:" << celli
<< " at:" << mesh_.cellCentres()[celli]
<< " zone:" << zoneID[celli]
<< " changed from hole to calculated"
<< " but there is no donor"
<< exit(FatalError);
}
else
{
allCellTypes[celli] = INTERPOLATED;
nCalculated++;
}
}
}
if (debug)
{
Pout<< "Detected " << nCalculated << " cells changing from hole"
<< " to calculated. Changed these to interpolated"
<< endl;
}
}
// Normalise weights, Clear storage
forAll(allCellTypes, cellI)
{
......
......@@ -2048,6 +2048,41 @@ bool Foam::cellCellStencils::inverseDistance::update()
tfld().write();
}
// Check previous iteration cellTypes_ for any hole->calculated changes
// If so set the cell either to interpolated (if there are donors) or
// holes (if there are no donors). Note that any interpolated cell might
// still be overwritten by the flood filling
{
label nCalculated = 0;
forAll(cellTypes_, celli)
{
if (allCellTypes[celli] == CALCULATED && cellTypes_[celli] == HOLE)
{
if (allStencil[celli].size() == 0)
{
// Reset to hole
allCellTypes[celli] = HOLE;
allStencil[celli].clear();
}
else
{
allCellTypes[celli] = INTERPOLATED;
nCalculated++;
}
}
}
if (debug)
{
Pout<< "Detected " << nCalculated << " cells changing from hole"
<< " to calculated. Changed to interpolated"
<< endl;
}
}
// Mark unreachable bits
findHoles(globalCells, mesh_, zoneID, allStencil, allCellTypes);
......@@ -2088,47 +2123,6 @@ bool Foam::cellCellStencils::inverseDistance::update()
}
// Check previous iteration cellTypes_ for any hole->calculated changes
{
label nCalculated = 0;
forAll(cellTypes_, celli)
{
if (allCellTypes[celli] == CALCULATED && cellTypes_[celli] == HOLE)
{
if (allStencil[celli].size() == 0)
{
FatalErrorInFunction
//WarningInFunction
<< "Cell:" << celli
<< " at:" << mesh_.cellCentres()[celli]
<< " zone:" << zoneID[celli]
<< " changed from hole to calculated"
<< " but there is no donor"
//<< endl;
<< exit(FatalError);
}
else
{
//Pout<< "cell:" << mesh_.cellCentres()[celli]
// << " changed from hole to calculated"
// << " using donors:" << allStencil[celli]
// << endl;
allCellTypes[celli] = INTERPOLATED;
nCalculated++;
}
}
}
if (debug)
{
Pout<< "Detected " << nCalculated << " cells changing from hole"
<< " to calculated. Changed to interpolated"
<< endl;
}
}
// Convert cell-cell addressing to stencil in compact notation
cellTypes_.transfer(allCellTypes);
......
......@@ -865,35 +865,10 @@ bool Foam::cellCellStencils::trackingInverseDistance::update()
}
// Mark unreachable bits
findHoles(globalCells_, mesh_, zoneID, allStencil, allCellTypes);
DebugInfo<< FUNCTION_NAME << " : Flood-filled holes" << endl;
if (debug)
{
tmp<volScalarField> tfld
(
createField(mesh_, "allCellTypes_hole", allCellTypes)
);
tfld().write();
}
// Add buffer interpolation layer(s) around holes
scalarField allWeight(mesh_.nCells(), Zero);
walkFront(layerRelax, allStencil, allCellTypes, allWeight);
DebugInfo<< FUNCTION_NAME << " : Implemented layer relaxation" << endl;
if (debug)
{
tmp<volScalarField> tfld
(
createField(mesh_, "allCellTypes_front", allCellTypes)
);
tfld().write();
}
// Check previous iteration cellTypes_ for any hole->calculated changes
// If so set the cell either to interpolated (if there are donors) or
// holes (if there are no donors). Note that any interpolated cell might
// still be overwritten by the flood filling
{
label nCalculated = 0;
......@@ -903,22 +878,12 @@ bool Foam::cellCellStencils::trackingInverseDistance::update()
{
if (allStencil[celli].size() == 0)
{
FatalErrorInFunction
//WarningInFunction
<< "Cell:" << celli
<< " at:" << mesh_.cellCentres()[celli]
<< " zone:" << zoneID[celli]
<< " changed from hole to calculated"
<< " but there is no donor"
//<< endl;
<< exit(FatalError);
// Reset to hole
allCellTypes[celli] = HOLE;
allStencil[celli].clear();
}
else
{
Pout<< "cell:" << mesh_.cellCentres()[celli]
<< " changed from hole to calculated"
<< " using donors:" << allStencil[celli]
<< endl;
allCellTypes[celli] = INTERPOLATED;
nCalculated++;
}
......@@ -934,6 +899,34 @@ bool Foam::cellCellStencils::trackingInverseDistance::update()
}
// Mark unreachable bits
findHoles(globalCells_, mesh_, zoneID, allStencil, allCellTypes);
DebugInfo<< FUNCTION_NAME << " : Flood-filled holes" << endl;
if (debug)
{
tmp<volScalarField> tfld
(
createField(mesh_, "allCellTypes_hole", allCellTypes)
);
tfld().write();
}
// Add buffer interpolation layer(s) around holes
scalarField allWeight(mesh_.nCells(), Zero);
walkFront(layerRelax, allStencil, allCellTypes, allWeight);
DebugInfo<< FUNCTION_NAME << " : Implemented layer relaxation" << endl;
if (debug)
{
tmp<volScalarField> tfld
(
createField(mesh_, "allCellTypes_front", allCellTypes)
);
tfld().write();
}
// Convert cell-cell addressing to stencil in compact notation
cellTypes_.transfer(allCellTypes);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment