From 24043c081773d2093f997b49717b788ee65d24ba Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Fri, 22 Mar 2019 13:33:07 +0000 Subject: [PATCH] Added virtual functions; removed looks in boundary FV data updates for IB patch --- .../immersedBoundaryFvPatch.C | 111 +++++++----------- 1 file changed, 43 insertions(+), 68 deletions(-) diff --git a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatch/immersedBoundaryFvPatch.C b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatch/immersedBoundaryFvPatch.C index e0c608a9e..62219d125 100644 --- a/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatch/immersedBoundaryFvPatch.C +++ b/src/immersedBoundary/immersedBoundary/immersedBoundaryFvPatch/immersedBoundaryFvPatch.C @@ -60,28 +60,10 @@ void Foam::immersedBoundaryFvPatch::makeCf(slicedSurfaceVectorField& Cf) const // Insert the patch data for the immersed boundary // Note: use the face centres from the stand-alone patch within the IB // HJ, 30/Nov/2017 - // NOTE: Loop though all ib boundaries in order to update the fields - // overwritten by reset. Needed for multiple IB patches (IG 2/Nov/2018) - const fvMesh& mesh = boundaryMesh().mesh(); - forAll(mesh.boundary(), patchI) - { - if(isA(mesh.boundary()[patchI])) - { - const immersedBoundaryFvPatch& curIbPatch = refCast - < - const immersedBoundaryFvPatch - >(mesh.boundary()[patchI]); - - Cf.boundaryField()[patchI].UList::operator= - ( - vectorField::subField - ( - curIbPatch.ibPolyPatch().ibPatch().faceCentres(), - curIbPatch.size() - ) - ); - } - } + Cf.boundaryField()[index()].UList::operator= + ( + vectorField::subField(ibPolyPatch_.ibPatch().faceCentres(), size()) + ); } @@ -94,28 +76,10 @@ void Foam::immersedBoundaryFvPatch::makeSf(slicedSurfaceVectorField& Sf) const // Note: use the corrected face areas from immersed boundary instead of // the stand-alone patch areas within the IB // HJ, 30/Nov/2017 - // NOTE: Loop though all ib boundaries in order to update the fields - // overwritten by reset. Needed for multiple IB patches (IG 2/Nov/2018) - const fvMesh& mesh = boundaryMesh().mesh(); - forAll(mesh.boundary(), patchI) - { - if(isA(mesh.boundary()[patchI])) - { - const immersedBoundaryFvPatch& curIbPatch = refCast - < - const immersedBoundaryFvPatch - >(mesh.boundary()[patchI]); - - Sf.boundaryField()[patchI].UList::operator= - ( - vectorField::subField - ( - curIbPatch.ibPolyPatch().correctedIbPatchFaceAreas(), - curIbPatch.size() - ) - ); - } - } + Sf.boundaryField()[index()].UList::operator= + ( + vectorField::subField(ibPolyPatch_.correctedIbPatchFaceAreas(), size()) + ); } @@ -131,28 +95,10 @@ void Foam::immersedBoundaryFvPatch::makeC(slicedVolVectorField& C) const // Insert the patch data for the immersed boundary // Note: use the face centres from the stand-alone patch within the IB // HJ, 30/Nov/2017 - // NOTE: Loop though all ib boundaries in order to update the fields - // overwritten by reset. Needed for multiple IB patches (IG 2/Nov/2018) - const fvMesh& mesh = boundaryMesh().mesh(); - forAll(mesh.boundary(), patchI) - { - if(isA(mesh.boundary()[patchI])) - { - const immersedBoundaryFvPatch& curIbPatch = refCast - < - const immersedBoundaryFvPatch - >(mesh.boundary()[patchI]); - - C.boundaryField()[patchI].UList::operator= - ( - vectorField::subField - ( - curIbPatch.ibPolyPatch().ibPatch().faceCentres(), - curIbPatch.size() - ) - ); - } - } + C.boundaryField()[index()].UList::operator= + ( + vectorField::subField(ibPolyPatch_.ibPatch().faceCentres(), size()) + ); } @@ -285,10 +231,10 @@ void Foam::immersedBoundaryFvPatch::updatePhi scalar corrOldVol = newVols[cellI] - divPhi[cellI]*deltaT; // Info<< "Flux maneouvre for cell " << cellI << ": " + // << " error: " << magDivPhi[cellI] // << " V: " << newVols[cellI] // << " V0: " << oldVols[cellI] - // << " divPhi: " << divPhi[cellI] - // << " error: " << magDivPhi[cellI]; + // << " divPhi: " << divPhi[cellI]; if (corrOldVol < SMALL) { @@ -305,6 +251,17 @@ void Foam::immersedBoundaryFvPatch::updatePhi } +void Foam::immersedBoundaryFvPatch::makeDeltaCoeffs +( + fvsPatchScalarField& dc +) const +{ + const vectorField d = delta(); + + dc = 1.0/max((nf() & d), 0.05*mag(d)); +} + + void Foam::immersedBoundaryFvPatch::makeCorrVecs(fvsPatchVectorField& cv) const { // Set patch non-orthogonality correction to zero @@ -383,4 +340,22 @@ Foam::immersedBoundaryFvPatch::faceCells() const } +Foam::tmp Foam::immersedBoundaryFvPatch::nf() const +{ + // The algorithm has been changed because basic IB patch information + // (nf and delta) is used in assembly of derived information + // (eg. deltaCoeffs) and circular dependency needs to be avoided. + // nf and delta vectors shall be calculated directly from the intersected + // patch. HJ, 21/Mar/2019 + + return ibPolyPatch_.ibPatch().faceNormals(); +} + + +Foam::tmp Foam::immersedBoundaryFvPatch::delta() const +{ + return ibPolyPatch_.ibPatch().faceCentres() - Cn(); +} + + // ************************************************************************* //