Commit 80ffdfb1 authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: AMIInterpolation - updated to use Enum class

parent e3d306d3
......@@ -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;
}
......
......@@ -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
(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment