From c5a9ceb3a049bb020e494d192d22079f0780c3fa Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Wed, 15 Jul 2015 14:32:58 +0100 Subject: [PATCH] Handle missing flux field phi --- .../check/ggiCheck/ggiCheckFunctionObject.C | 144 ++++++++++-------- 1 file changed, 80 insertions(+), 64 deletions(-) diff --git a/src/postProcessing/functionObjects/check/ggiCheck/ggiCheckFunctionObject.C b/src/postProcessing/functionObjects/check/ggiCheck/ggiCheckFunctionObject.C index 679ee1112..84d7e1be4 100644 --- a/src/postProcessing/functionObjects/check/ggiCheck/ggiCheckFunctionObject.C +++ b/src/postProcessing/functionObjects/check/ggiCheck/ggiCheckFunctionObject.C @@ -83,83 +83,99 @@ bool Foam::ggiCheckFunctionObject::execute() const objectRegistry& mesh = time_.lookupObject(regionName_); - const surfaceScalarField& phi = - mesh.lookupObject(phiName_); - - boolList visited(phi.boundaryField().size(), false); - - forAll (phi.boundaryField(), patchI) + if (mesh.foundObject(phiName_)) { - if (isA(phi.boundaryField()[patchI])) + const surfaceScalarField& phi = + mesh.lookupObject(phiName_); + + boolList visited(phi.boundaryField().size(), false); + + forAll (phi.boundaryField(), patchI) { - if (!visited[patchI]) + if (isA(phi.boundaryField()[patchI])) { - visited[patchI] = true; + if (!visited[patchI]) + { + visited[patchI] = true; - // Calculate local and shadow flux - scalar localFlux = gSum(phi.boundaryField()[patchI]); - scalar localFluxMag = gSumMag(phi.boundaryField()[patchI]); + // Calculate local and shadow flux + scalar localFlux = gSum(phi.boundaryField()[patchI]); + scalar localFluxMag = gSumMag(phi.boundaryField()[patchI]); - const ggiPolyPatch& ggiPatch = - refCast - ( - phi.boundaryField()[patchI].patch().patch() - ); + const ggiPolyPatch& ggiPatch = + refCast + ( + phi.boundaryField()[patchI].patch().patch() + ); - const label shadowPatchI = ggiPatch.shadowIndex(); + const label shadowPatchI = ggiPatch.shadowIndex(); - visited[shadowPatchI] = true; + visited[shadowPatchI] = true; - scalar shadowFlux = gSum(phi.boundaryField()[shadowPatchI]); - scalar shadowFluxMag = - gSumMag(phi.boundaryField()[shadowPatchI]); + scalar shadowFlux = + gSum(phi.boundaryField()[shadowPatchI]); - Info<< "GGI pair (" << ggiPatch.name() << ", " - << ggiPatch.shadow().name() - << ") : " << localFluxMag << " " << shadowFluxMag - << " Diff = " << localFlux + shadowFlux << " or " - << mag(localFlux + shadowFlux)/(localFluxMag + SMALL)*100 - << " %" << endl; - } - } - else if - ( - isA(phi.boundaryField()[patchI]) - ) - { - if (!visited[patchI]) - { - visited[patchI] = true; - - // Calculate local and shadow flux - scalar localFlux = gSum(phi.boundaryField()[patchI]); - scalar localFluxMag = gSumMag(phi.boundaryField()[patchI]); - - const cyclicGgiPolyPatch& ggiPatch = - refCast - ( - phi.boundaryField()[patchI].patch().patch() - ); - - const label shadowPatchI = ggiPatch.shadowIndex(); - - visited[shadowPatchI] = true; - - scalar shadowFlux = gSum(phi.boundaryField()[shadowPatchI]); - scalar shadowFluxMag = - gSumMag(phi.boundaryField()[shadowPatchI]); - - Info<< "Cyclic GGI pair (" << ggiPatch.name() << ", " - << ggiPatch.shadow().name() - << ") : " << localFluxMag << " " << shadowFluxMag - << " Diff = " << localFlux + shadowFlux << " or " - << mag(localFlux + shadowFlux)/(localFluxMag + SMALL)*100 - << " %" << endl; + scalar shadowFluxMag = + gSumMag(phi.boundaryField()[shadowPatchI]); + + Info<< "GGI pair (" << ggiPatch.name() << ", " + << ggiPatch.shadow().name() + << ") : " << localFluxMag << " " << shadowFluxMag + << " Diff = " << localFlux + shadowFlux << " or " + << mag(localFlux + shadowFlux)/ + (localFluxMag + SMALL)*100 + << " %" << endl; + } + } + else if + ( + isA(phi.boundaryField()[patchI]) + ) + { + if (!visited[patchI]) + { + visited[patchI] = true; + + // Calculate local and shadow flux + scalar localFlux = gSum(phi.boundaryField()[patchI]); + scalar localFluxMag = gSumMag(phi.boundaryField()[patchI]); + + const cyclicGgiPolyPatch& ggiPatch = + refCast + ( + phi.boundaryField()[patchI].patch().patch() + ); + + const label shadowPatchI = ggiPatch.shadowIndex(); + + visited[shadowPatchI] = true; + + scalar shadowFlux = + gSum(phi.boundaryField()[shadowPatchI]); + + scalar shadowFluxMag = + gSumMag(phi.boundaryField()[shadowPatchI]); + + Info<< "Cyclic GGI pair (" << ggiPatch.name() << ", " + << ggiPatch.shadow().name() + << ") : " << localFluxMag << " " << shadowFluxMag + << " Diff = " << localFlux + shadowFlux << " or " + << mag(localFlux + shadowFlux)/ + (localFluxMag + SMALL)*100 + << " %" << endl; + } } } + return true; } + else + { + InfoIn("bool ggiCheckFunctionObject::execute()") + << "Cannot find flux field phi" + << endl; - return true; + return false; + } }