From 9170cf2d97c31067522ef0cdfbbc20eb619b3d30 Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Fri, 2 Mar 2018 13:15:22 +0100 Subject: [PATCH] Output bugfix in ggiCheckFunctionObject --- .../check/ggiCheck/ggiCheckFunctionObject.C | 66 +++++++++---------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/src/postProcessing/functionObjects/check/ggiCheck/ggiCheckFunctionObject.C b/src/postProcessing/functionObjects/check/ggiCheck/ggiCheckFunctionObject.C index c8dc9a3a3..c367d9b5e 100644 --- a/src/postProcessing/functionObjects/check/ggiCheck/ggiCheckFunctionObject.C +++ b/src/postProcessing/functionObjects/check/ggiCheck/ggiCheckFunctionObject.C @@ -86,6 +86,7 @@ bool Foam::ggiCheckFunctionObject::execute(const bool forceWrite) if (mesh.foundObject(phiName_)) { + Info<< "Checking flux " << phiName_ << " GGI balance." << endl; const surfaceScalarField& phi = mesh.lookupObject(phiName_); @@ -110,24 +111,22 @@ bool Foam::ggiCheckFunctionObject::execute(const bool forceWrite) visited[patchI] = true; visited[shadowPatchI] = true; - // Calculate local and shadow flux - scalar localArea = + // Calculate local flux and area + const scalar localArea = gSum(phi.mesh().magSf().boundaryField()[patchI]); - scalar localFlux = gSum(phi.boundaryField()[patchI]); - scalar localFluxMag = gSumMag(phi.boundaryField()[patchI]); + const scalar localFlux = gSum(phi.boundaryField()[patchI]); + const scalar localFluxMag = mag(localFlux); - - - scalar shadowArea = + // Calculate shadow flux and area + const scalar shadowArea = gSum(phi.mesh().magSf().boundaryField()[shadowPatchI]); - scalar shadowFlux = + const scalar shadowFlux = gSum(phi.boundaryField()[shadowPatchI]); + const scalar shadowFluxMag = mag(shadowFlux); - scalar shadowFluxMag = - gSumMag(phi.boundaryField()[shadowPatchI]); - + // Report Info<< "GGI pair (" << ggiPatch.name() << ", " << ggiPatch.shadow().name() << ")" << nl << "Area: " << localArea << " " << shadowArea @@ -138,7 +137,7 @@ bool Foam::ggiCheckFunctionObject::execute(const bool forceWrite) << "Flux: " << localFluxMag << " " << shadowFluxMag << " Diff = " << localFlux + shadowFlux << " or " << mag(localFlux + shadowFlux)/ - (localFluxMag + SMALL)*100 + (Foam::max(localFluxMag, shadowFluxMag) + SMALL)*100 << " %" << endl; } else if @@ -157,22 +156,22 @@ bool Foam::ggiCheckFunctionObject::execute(const bool forceWrite) visited[patchI] = true; visited[shadowPatchI] = true; - // Calculate local and shadow flux - scalar localArea = + // Calculate local flux and area + const scalar localArea = gSum(phi.mesh().magSf().boundaryField()[patchI]); - scalar localFlux = gSum(phi.boundaryField()[patchI]); - scalar localFluxMag = gSumMag(phi.boundaryField()[patchI]); + const scalar localFlux = gSum(phi.boundaryField()[patchI]); + const scalar localFluxMag = mag(localFlux); - scalar shadowArea = + // Calculate shadow flux and area + const scalar shadowArea = gSum(phi.mesh().magSf().boundaryField()[shadowPatchI]); - scalar shadowFlux = + const scalar shadowFlux = gSum(phi.boundaryField()[shadowPatchI]); + const scalar shadowFluxMag = mag(shadowFlux); - scalar shadowFluxMag = - gSumMag(phi.boundaryField()[shadowPatchI]); - + // Report Info<< "Cyclic GGI pair (" << ggiPatch.name() << ", " << ggiPatch.shadow().name() << ")" << nl << "Area: " << localArea << " " << shadowArea @@ -183,7 +182,7 @@ bool Foam::ggiCheckFunctionObject::execute(const bool forceWrite) << "Flux: " << localFluxMag << " " << shadowFluxMag << " Diff = " << localFlux + shadowFlux << " or " << mag(localFlux + shadowFlux)/ - (localFluxMag + SMALL)*100 + (Foam::max(localFluxMag, shadowFluxMag) + SMALL)*100 << " %" << endl; } else if @@ -208,30 +207,25 @@ bool Foam::ggiCheckFunctionObject::execute(const bool forceWrite) visited[patchI] = true; visited[shadowPatchI] = true; - // Calculate local and shadow flux - scalar localArea = + // Calculate local flux and area + const scalar localArea = gSum(phi.mesh().magSf().boundaryField()[patchI]) *ggiPatch.nCopies(); - scalar localFlux = + const scalar localFlux = gSum(phi.boundaryField()[patchI]) *ggiPatch.nCopies(); + const scalar localFluxMag = mag(localFlux); - scalar localFluxMag = - gSumMag(phi.boundaryField()[patchI]) - *ggiPatch.nCopies(); - - scalar shadowArea = + // Calculate shadow flux and area + const scalar shadowArea = gSum(phi.mesh().magSf().boundaryField()[shadowPatchI]) *ggiShadowPatch.nCopies(); - scalar shadowFlux = + const scalar shadowFlux = gSum(phi.boundaryField()[shadowPatchI]) *ggiShadowPatch.nCopies(); - - scalar shadowFluxMag = - gSumMag(phi.boundaryField()[shadowPatchI]) - *ggiShadowPatch.nCopies(); + const scalar shadowFluxMag = mag(shadowFlux); Info<< "Overlap GGI pair (" << ggiPatch.name() << ", " << ggiPatch.shadow().name() << ")" << nl @@ -253,7 +247,7 @@ bool Foam::ggiCheckFunctionObject::execute(const bool forceWrite) else { InfoIn("bool ggiCheckFunctionObject::execute(const bool forceWrite)") - << "Cannot find flux field phi" + << "Cannot find flux field " << phiName_ << endl; return false;