ENH: AMIInterpolation - updated to use Enum class

This commit is contained in:
Andrew Heather
2017-08-17 11:11:26 +01:00
parent e3d306d3cf
commit 80ffdfb149
2 changed files with 21 additions and 73 deletions

View File

@ -31,6 +31,20 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class SourcePatch, class TargetPatch>
const Foam::Enum
<
typename Foam::AMIInterpolation<SourcePatch, TargetPatch>::
interpolationMethod
>
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolationMethodNames_
{
{ interpolationMethod::imDirect, "directAMI" },
{ interpolationMethod::imMapNearest, "mapNearestAMI" },
{ interpolationMethod::imFaceAreaWeight, "faceAreaWeightAMI" },
{ interpolationMethod::imPartialFaceAreaWeight, "partialFaceAreaWeightAMI" }
};
template<class SourcePatch, class TargetPatch>
Foam::word
Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolationMethodToWord
@ -38,39 +52,7 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::interpolationMethodToWord
const interpolationMethod& im
)
{
word method = "unknown-interpolationMethod";
switch (im)
{
case imDirect:
{
method = "directAMI";
break;
}
case imMapNearest:
{
method = "mapNearestAMI";
break;
}
case imFaceAreaWeight:
{
method = "faceAreaWeightAMI";
break;
}
case imPartialFaceAreaWeight:
{
method = "partialFaceAreaWeightAMI";
break;
}
default:
{
FatalErrorInFunction
<< "Unhandled interpolationMethod enumeration " << method
<< abort(FatalError);
}
}
return method;
return interpolationMethodNames_[im];
}
@ -81,41 +63,7 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::wordTointerpolationMethod
const word& im
)
{
interpolationMethod method = imDirect;
const wordList methods
{
"directAMI",
"mapNearestAMI",
"faceAreaWeightAMI",
"partialFaceAreaWeightAMI"
};
if (im == "directAMI")
{
method = imDirect;
}
else if (im == "mapNearestAMI")
{
method = imMapNearest;
}
else if (im == "faceAreaWeightAMI")
{
method = imFaceAreaWeight;
}
else if (im == "partialFaceAreaWeightAMI")
{
method = imPartialFaceAreaWeight;
}
else
{
FatalErrorInFunction
<< "Invalid interpolationMethod " << im
<< ". Valid methods are:" << methods
<< exit(FatalError);
}
return method;
return interpolationMethodNames_[im];
}
@ -910,11 +858,8 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
if (srcTotalSize == 0)
{
if (debug)
{
Info<< "AMI: no source faces present - no addressing constructed"
<< endl;
}
DebugInfo<< "AMI: no source faces present - no addressing constructed"
<< endl;
return;
}

View File

@ -57,6 +57,7 @@ SourceFiles
#include "faceAreaIntersect.H"
#include "globalIndex.H"
#include "ops.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -92,6 +93,8 @@ public:
imPartialFaceAreaWeight
};
static const Enum<interpolationMethod> interpolationMethodNames_;
//- Convert interpolationMethod to word representation
static word interpolationMethodToWord
(