Handle missing flux field phi

This commit is contained in:
Hrvoje Jasak 2015-07-15 14:32:58 +01:00
parent 1ce14c5e16
commit c5a9ceb3a0

View file

@ -83,83 +83,99 @@ bool Foam::ggiCheckFunctionObject::execute()
const objectRegistry& mesh =
time_.lookupObject<objectRegistry>(regionName_);
const surfaceScalarField& phi =
mesh.lookupObject<surfaceScalarField>(phiName_);
boolList visited(phi.boundaryField().size(), false);
forAll (phi.boundaryField(), patchI)
if (mesh.foundObject<surfaceScalarField>(phiName_))
{
if (isA<ggiFvsPatchScalarField>(phi.boundaryField()[patchI]))
const surfaceScalarField& phi =
mesh.lookupObject<surfaceScalarField>(phiName_);
boolList visited(phi.boundaryField().size(), false);
forAll (phi.boundaryField(), patchI)
{
if (!visited[patchI])
if (isA<ggiFvsPatchScalarField>(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<const ggiPolyPatch>
(
phi.boundaryField()[patchI].patch().patch()
);
const ggiPolyPatch& ggiPatch =
refCast<const ggiPolyPatch>
(
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<cyclicGgiFvsPatchScalarField>(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<const cyclicGgiPolyPatch>
(
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<cyclicGgiFvsPatchScalarField>(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<const cyclicGgiPolyPatch>
(
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;
}
}