functionObjects, layerAverage: Permit layers that do not span the mesh

This commit is contained in:
Will Bainbridge
2021-12-09 16:08:01 +00:00
parent da18afe589
commit b65f8a1e37

View File

@ -87,12 +87,13 @@ void Foam::functionObjects::layerAverage::walkOppositeFaces
syncTools::swapBoundaryFaceList(mesh_, bndFaceIsFront); syncTools::swapBoundaryFaceList(mesh_, bndFaceIsFront);
// Set new front faces // Set new front faces
forAll(bndFaceIsFront, i) forAll(bndFaceIsFront, bndFacei)
{ {
const label facei = mesh_.nInternalFaces() + i; const label facei = mesh_.nInternalFaces() + bndFacei;
if (bndFaceIsFront[i] && !blockedFace[facei]) if (bndFaceIsFront[bndFacei] && !blockedFace[facei])
{ {
blockedFace[facei] = true;
frontFaces.append(facei); frontFaces.append(facei);
frontFaceIntoOwners.append(true); frontFaceIntoOwners.append(true);
} }
@ -141,6 +142,39 @@ void Foam::functionObjects::layerAverage::walkOppositeFaces
frontFaces.transfer(newFrontFaces); frontFaces.transfer(newFrontFaces);
frontFaceIntoOwners.transfer(newFrontFaceIntoOwners); frontFaceIntoOwners.transfer(newFrontFaceIntoOwners);
} }
// Determine whether cells on the other sides of couplings are in layers
boolList bndCellIsLayer(mesh_.nFaces() - mesh_.nInternalFaces(), false);
forAll(bndCellIsLayer, bndFacei)
{
const label facei = mesh_.nInternalFaces() + bndFacei;
const label owni = mesh_.faceOwner()[facei];
bndCellIsLayer[bndFacei] = cellIsLayer[owni];
}
syncTools::swapBoundaryFaceList(mesh_, bndCellIsLayer);
// Block faces where one adjacent cell is in a layer and the other is not
forAll(mesh_.faces(), facei)
{
const label owni = mesh_.faceOwner()[facei];
if (mesh_.isInternalFace(facei))
{
const label nbri = mesh_.faceNeighbour()[facei];
if (cellIsLayer[owni] != cellIsLayer[nbri])
{
blockedFace[facei] = true;
}
}
else
{
const label bndFacei = facei - mesh_.nInternalFaces();
if (cellIsLayer[owni] != bndCellIsLayer[bndFacei])
{
blockedFace[facei] = true;
}
}
}
} }
@ -225,7 +259,7 @@ void Foam::functionObjects::layerAverage::calcLayers()
x_ = layerCentres.component(axis_); x_ = layerCentres.component(axis_);
sortMap_ = identity(layerCentres.size()); sortMap_ = identity(layerCentres.size());
stableSort(sortMap_, UList<scalar>::less(x_)); stableSort(sortMap_, UList<scalar>::less(x_));
inplaceReorder(sortMap_, x_); x_.map(x_, sortMap_);
// If symmetric, keep only half of the coordinates // If symmetric, keep only half of the coordinates
if (symmetric_) if (symmetric_)
@ -388,6 +422,8 @@ bool Foam::functionObjects::layerAverage::write()
} }
// Write // Write
if (Pstream::master() && x_.size())
{
formatter_->write formatter_->write
( (
outputPath/mesh_.time().timeName(), outputPath/mesh_.time().timeName(),
@ -398,6 +434,7 @@ bool Foam::functionObjects::layerAverage::write()
FOR_ALL_FIELD_TYPES(TypeValueSetsParameter) FOR_ALL_FIELD_TYPES(TypeValueSetsParameter)
#undef TypeValueSetsParameter #undef TypeValueSetsParameter
); );
}
return true; return true;
} }