mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: tabulated6DoFMotion: add optional linear interpolation scheme
This commit is contained in:
@ -31,6 +31,7 @@ License
|
|||||||
#include "Tuple2.H"
|
#include "Tuple2.H"
|
||||||
#include "IFstream.H"
|
#include "IFstream.H"
|
||||||
#include "interpolateSplineXY.H"
|
#include "interpolateSplineXY.H"
|
||||||
|
#include "interpolateXY.H"
|
||||||
#include "unitConversion.H"
|
#include "unitConversion.H"
|
||||||
|
|
||||||
|
|
||||||
@ -51,6 +52,17 @@ namespace solidBodyMotionFunctions
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::Enum
|
||||||
|
<
|
||||||
|
Foam::solidBodyMotionFunctions::tabulated6DoFMotion::interpolationType
|
||||||
|
>
|
||||||
|
Foam::solidBodyMotionFunctions::tabulated6DoFMotion::interpolationTypeNames
|
||||||
|
({
|
||||||
|
{ interpolationType::SPLINE, "spline" },
|
||||||
|
{ interpolationType::LINEAR, "linear" }
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::solidBodyMotionFunctions::tabulated6DoFMotion::tabulated6DoFMotion
|
Foam::solidBodyMotionFunctions::tabulated6DoFMotion::tabulated6DoFMotion
|
||||||
@ -90,12 +102,28 @@ Foam::solidBodyMotionFunctions::tabulated6DoFMotion::transformation() const
|
|||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
translationRotationVectors TRV = interpolateSplineXY
|
translationRotationVectors TRV;
|
||||||
(
|
switch (interpolator_)
|
||||||
t,
|
{
|
||||||
times_,
|
case interpolationType::SPLINE:
|
||||||
values_
|
{
|
||||||
);
|
TRV = interpolateSplineXY(t, times_, values_);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case interpolationType::LINEAR:
|
||||||
|
{
|
||||||
|
TRV = interpolateXY(t, times_, values_);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Unrecognised 'interpolationScheme' option: "
|
||||||
|
<< interpolationTypeNames[interpolator_]
|
||||||
|
<< exit(FatalError);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Convert the rotational motion from deg to rad
|
// Convert the rotational motion from deg to rad
|
||||||
TRV[1] *= degToRad();
|
TRV[1] *= degToRad();
|
||||||
@ -155,6 +183,14 @@ bool Foam::solidBodyMotionFunctions::tabulated6DoFMotion::read
|
|||||||
|
|
||||||
SBMFCoeffs_.readEntry("CofG", CofG_);
|
SBMFCoeffs_.readEntry("CofG", CofG_);
|
||||||
|
|
||||||
|
interpolator_ =
|
||||||
|
interpolationTypeNames.getOrDefault
|
||||||
|
(
|
||||||
|
"interpolationScheme",
|
||||||
|
SBMFCoeffs_,
|
||||||
|
interpolationType::SPLINE
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,7 +61,23 @@ class tabulated6DoFMotion
|
|||||||
:
|
:
|
||||||
public solidBodyMotionFunction
|
public solidBodyMotionFunction
|
||||||
{
|
{
|
||||||
// Private data
|
// Private Enumerations
|
||||||
|
|
||||||
|
//- Options for the interpolation algorithm
|
||||||
|
enum class interpolationType : char
|
||||||
|
{
|
||||||
|
SPLINE = 0, //!< "Spline interpolation method"
|
||||||
|
LINEAR //!< "Linear interpolation method"
|
||||||
|
};
|
||||||
|
|
||||||
|
//- Names for interpolationType
|
||||||
|
static const Enum<interpolationType> interpolationTypeNames;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Interpolation algorithm
|
||||||
|
interpolationType interpolator_;
|
||||||
|
|
||||||
//- Time data file name read from dictionary
|
//- Time data file name read from dictionary
|
||||||
fileName timeDataFileName_;
|
fileName timeDataFileName_;
|
||||||
|
|||||||
Reference in New Issue
Block a user