mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Updated cyclicACMIPolyPatch following changes to geometry updates
The cell volumes are no longer deleted if already present; instead, cells next to the patch are updated locally.
This commit is contained in:
committed by
Andrew Heather
parent
2493102044
commit
f1dfaa90a7
@ -30,6 +30,7 @@ License
|
|||||||
#include "SubField.H"
|
#include "SubField.H"
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "primitiveMeshTools.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -191,8 +192,7 @@ void Foam::cyclicACMIPolyPatch::scalePatchFaceAreas
|
|||||||
const vectorList& noFaceArea // nonOverlapPatch.faceAreas()
|
const vectorList& noFaceArea // nonOverlapPatch.faceAreas()
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Primitive patch face areas have been cleared/reset based on the raw
|
// Set/scale polyPatch face areas to avoid double-accounting of face areas
|
||||||
// points - need to reset to avoid double-accounting of face areas
|
|
||||||
|
|
||||||
const scalar maxTol = scalar(1) - tolerance_;
|
const scalar maxTol = scalar(1) - tolerance_;
|
||||||
|
|
||||||
@ -251,14 +251,31 @@ void Foam::cyclicACMIPolyPatch::scalePatchFaceAreas
|
|||||||
{
|
{
|
||||||
scalar& sum = weightsSum[i];
|
scalar& sum = weightsSum[i];
|
||||||
|
|
||||||
forAll(wghts, j)
|
for (scalar& w : wghts)
|
||||||
{
|
{
|
||||||
wghts[j] /= sum;
|
w /= sum;
|
||||||
}
|
}
|
||||||
sum = 1.0;
|
sum = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const polyMesh& mesh = boundaryMesh().mesh();
|
||||||
|
|
||||||
|
// Recompute the cell volumes adjacent to the patches since the cells with
|
||||||
|
// duplicate faces are only closed after the duplicate faces have been
|
||||||
|
// scaled.
|
||||||
|
|
||||||
|
primitiveMeshTools::updateCellCentresAndVols
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
mesh.faceCentres(),
|
||||||
|
mesh.faceAreas(), // already scaled
|
||||||
|
uniqueSort(acmipp.faceCells()), // unique cells only
|
||||||
|
mesh.cells(),
|
||||||
|
const_cast<vectorField&>(mesh.cellCentres()),
|
||||||
|
const_cast<scalarField&>(mesh.cellVolumes())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -284,22 +301,6 @@ void Foam::cyclicACMIPolyPatch::resetAMI(const UList<point>& points) const
|
|||||||
|
|
||||||
const polyMesh& mesh = boundaryMesh().mesh();
|
const polyMesh& mesh = boundaryMesh().mesh();
|
||||||
|
|
||||||
if (!createAMIFaces_ && mesh.hasCellCentres())
|
|
||||||
{
|
|
||||||
DebugPout
|
|
||||||
<< "cyclicACMIPolyPatch::resetAMI : clearing cellCentres"
|
|
||||||
<< " for " << name() << " and " << nonOverlapPatch.name() << nl
|
|
||||||
<< "The mesh already has cellCentres calculated when"
|
|
||||||
<< " resetting ACMI " << name() << "." << nl
|
|
||||||
<< "This is a problem since ACMI adapts the face areas"
|
|
||||||
<< " (to close cells) so this has" << nl
|
|
||||||
<< "to be done before cell centre calculation." << nl
|
|
||||||
<< "This can happen if e.g. the cyclicACMI is after"
|
|
||||||
<< " any processor patches in the boundary." << endl;
|
|
||||||
|
|
||||||
const_cast<polyMesh&>(mesh).primitiveMesh::clearCellGeom();
|
|
||||||
}
|
|
||||||
|
|
||||||
// At this point we want face geometry but not cell geometry since we want
|
// At this point we want face geometry but not cell geometry since we want
|
||||||
// correct the face area on duplicate baffles before calculating the cell
|
// correct the face area on duplicate baffles before calculating the cell
|
||||||
// centres and volumes.
|
// centres and volumes.
|
||||||
@ -363,6 +364,8 @@ void Foam::cyclicACMIPolyPatch::scalePatchFaceAreas()
|
|||||||
|
|
||||||
if (srcScalePtr_)
|
if (srcScalePtr_)
|
||||||
{
|
{
|
||||||
|
// Use primitivePatch::faceAreas() to avoid need for additional copy?
|
||||||
|
|
||||||
// Save overlap geometry for later scaling
|
// Save overlap geometry for later scaling
|
||||||
thisSf_ = this->faceAreas();
|
thisSf_ = this->faceAreas();
|
||||||
thisNoSf_ = nonOverlapPatch.faceAreas();
|
thisNoSf_ = nonOverlapPatch.faceAreas();
|
||||||
@ -370,24 +373,53 @@ void Foam::cyclicACMIPolyPatch::scalePatchFaceAreas()
|
|||||||
nbrNoSf_ = nbrNonOverlapPatch.faceAreas();
|
nbrNoSf_ = nbrNonOverlapPatch.faceAreas();
|
||||||
}
|
}
|
||||||
|
|
||||||
// In-place scale the patch areas
|
// In-place scale the polyPatch face areas
|
||||||
|
|
||||||
|
// Note
|
||||||
|
// - using primitivePatch face areas since these are based on the raw
|
||||||
|
// point locations (not affected by ACMI scaling)
|
||||||
scalePatchFaceAreas
|
scalePatchFaceAreas
|
||||||
(
|
(
|
||||||
*this,
|
*this,
|
||||||
srcMask_, // unscaled mask
|
srcMask_, // unscaled mask
|
||||||
this->faceAreas(),
|
this->primitivePatch::faceAreas(),
|
||||||
nonOverlapPatch.faceAreas()
|
nonOverlapPatch.primitivePatch::faceAreas()
|
||||||
);
|
);
|
||||||
scalePatchFaceAreas
|
scalePatchFaceAreas
|
||||||
(
|
(
|
||||||
nbrPatch,
|
nbrPatch,
|
||||||
tgtMask_, // unscaled mask
|
tgtMask_, // unscaled mask
|
||||||
nbrPatch.faceAreas(),
|
nbrPatch.primitivePatch::faceAreas(),
|
||||||
nbrNonOverlapPatch.faceAreas()
|
nbrNonOverlapPatch.primitivePatch::faceAreas()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Mark current AMI as up to date with points
|
// Mark current AMI as up to date with points
|
||||||
boundaryMesh().mesh().setUpToDatePoints(AMITime_);
|
boundaryMesh().mesh().setUpToDatePoints(AMITime_);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
const auto& acmipp = *this;
|
||||||
|
const auto& mesh = boundaryMesh().mesh();
|
||||||
|
const auto& vols = mesh.cellVolumes();
|
||||||
|
|
||||||
|
Info<< "cyclicACMI PP: " << acmipp.name()
|
||||||
|
<< " V:" << sum(scalarField(vols, acmipp.faceCells()))
|
||||||
|
<< nl
|
||||||
|
<< "cyclicACMI N-O PP: " << nonOverlapPatch.name()
|
||||||
|
<< " V:" << sum(scalarField(vols, nonOverlapPatch.faceCells()))
|
||||||
|
<< nl
|
||||||
|
<< "cyclicACMI NBR PP: " << nbrPatch.name()
|
||||||
|
<< " V:" << sum(scalarField(vols, nbrPatch.faceCells()))
|
||||||
|
<< nl
|
||||||
|
<< "cyclicACMI NBR N-O PP: " << nbrNonOverlapPatch.name()
|
||||||
|
<< " V:" << sum(scalarField(vols, nbrNonOverlapPatch.faceCells()))
|
||||||
|
<< nl
|
||||||
|
<< "cyclicACMI PP+N-O AREA: "
|
||||||
|
<< sum(faceAreas() + nonOverlapPatch.faceAreas()) << nl
|
||||||
|
<< "cyclicACMI NBR PP+N-O AREA: "
|
||||||
|
<< sum(nbrPatch.faceAreas() + nbrNonOverlapPatch.faceAreas())
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -761,7 +793,8 @@ void Foam::cyclicACMIPolyPatch::newInternalProcFaces
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::refPtr<Foam::labelListList> Foam::cyclicACMIPolyPatch::mapCollocatedFaces() const
|
Foam::refPtr<Foam::labelListList>
|
||||||
|
Foam::cyclicACMIPolyPatch::mapCollocatedFaces() const
|
||||||
{
|
{
|
||||||
const scalarField& fMask = srcMask();
|
const scalarField& fMask = srcMask();
|
||||||
const labelListList& srcFaces = AMI().srcAddress();
|
const labelListList& srcFaces = AMI().srcAddress();
|
||||||
|
|||||||
@ -106,7 +106,7 @@ private:
|
|||||||
//- Weighting for target mask
|
//- Weighting for target mask
|
||||||
mutable autoPtr<PatchFunction1<scalar>> tgtScalePtr_;
|
mutable autoPtr<PatchFunction1<scalar>> tgtScalePtr_;
|
||||||
|
|
||||||
//- Stored face areas
|
//- Stored raw/non-scaled face areas
|
||||||
mutable vectorField thisSf_;
|
mutable vectorField thisSf_;
|
||||||
mutable vectorField thisNoSf_;
|
mutable vectorField thisNoSf_;
|
||||||
mutable vectorField nbrSf_;
|
mutable vectorField nbrSf_;
|
||||||
|
|||||||
Reference in New Issue
Block a user