ENH: use pointer checks for dynamicCast, refCast

- avoids try/catch exception handling

STYLE: prefer refCast (shorter) to dynamicCast where possible
This commit is contained in:
Mark Olesen
2022-09-15 10:20:57 +02:00
parent 512f558549
commit b9ca63b118
11 changed files with 120 additions and 132 deletions

View File

@ -411,7 +411,7 @@ combineSurfaceGeometry
{
if (stObject == regionType_)
{
const polySurface& s = dynamicCast<const polySurface>(obr());
const auto& s = refCast<const polySurface>(obr());
if (Pstream::parRun())
{
@ -471,7 +471,7 @@ Foam::functionObjects::fieldValues::surfaceFieldValue::totalArea() const
if (stObject == regionType_)
{
const polySurface& s = dynamicCast<const polySurface>(obr());
const auto& s = refCast<const polySurface>(obr());
totalArea = gSum(s.magSf());
}
@ -536,7 +536,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::update()
}
case stObject:
{
const polySurface& s = dynamicCast<const polySurface>(obr());
const auto& s = refCast<const polySurface>(obr());
nFaces_ = returnReduce(s.size(), sumOp<label>());
break;
}
@ -1206,7 +1206,7 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::write()
{
if (stObject == regionType_)
{
const polySurface& s = dynamicCast<const polySurface>(obr());
const auto& s = refCast<const polySurface>(obr());
Sf = s.Sf();
}
else if (sampledPtr_)