dynamicMesh::sixDoFMotion: Generalised replacement for tabulated6DoFMotion
using Function1 and supporting all the standard Function1s including tabulated and coded. tutorials/multiphase/interFoam/laminar/sloshingTank3D6DoF updated to use sixDoFMotion.
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -140,6 +140,12 @@ public:
|
||||
TableReader<Type>::adddictionaryConstructorToTable<TableReaders::SS<Type>> \
|
||||
add##SS##Type##ConstructorToTable_;
|
||||
|
||||
#define makeTableReaders(Type) \
|
||||
defineTableReader(Type); \
|
||||
makeTableReader(Foam, Type); \
|
||||
makeTableReader(Csv, Type)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -30,11 +30,6 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define makeTableReaders(Type) \
|
||||
defineTableReader(Type); \
|
||||
makeTableReader(Foam, Type); \
|
||||
makeTableReader(Csv, Type)
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeTableReaders(scalar);
|
||||
|
||||
@ -116,7 +116,7 @@ solidBodyMotionFunctions = motionSolvers/displacement/solidBody/solidBodyMotionF
|
||||
$(solidBodyMotionFunctions)/solidBodyMotionFunction/solidBodyMotionFunction.C
|
||||
$(solidBodyMotionFunctions)/solidBodyMotionFunction/solidBodyMotionFunctionNew.C
|
||||
$(solidBodyMotionFunctions)/SDA/SDA.C
|
||||
$(solidBodyMotionFunctions)/tabulated6DoFMotion/tabulated6DoFMotion.C
|
||||
$(solidBodyMotionFunctions)/sixDoFMotion/sixDoFMotion.C
|
||||
$(solidBodyMotionFunctions)/linearMotion/linearMotion.C
|
||||
$(solidBodyMotionFunctions)/rotatingMotion/rotatingMotion.C
|
||||
$(solidBodyMotionFunctions)/axisRotationMotion/axisRotationMotion.C
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,12 +23,9 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "tabulated6DoFMotion.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "Tuple2.H"
|
||||
#include "IFstream.H"
|
||||
#include "interpolateSplineXY.H"
|
||||
#include "sixDoFMotion.H"
|
||||
#include "mathematicalConstants.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
using namespace Foam::constant::mathematical;
|
||||
|
||||
@ -38,20 +35,71 @@ namespace Foam
|
||||
{
|
||||
namespace solidBodyMotionFunctions
|
||||
{
|
||||
defineTypeNameAndDebug(tabulated6DoFMotion, 0);
|
||||
defineTypeNameAndDebug(sixDoFMotion, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
solidBodyMotionFunction,
|
||||
tabulated6DoFMotion,
|
||||
sixDoFMotion,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "Constant.H"
|
||||
#include "Uniform.H"
|
||||
#include "ZeroConstant.H"
|
||||
#include "OneConstant.H"
|
||||
#include "PolynomialEntry.H"
|
||||
#include "Sine.H"
|
||||
#include "Square.H"
|
||||
#include "Table.H"
|
||||
#include "TableFile.H"
|
||||
#include "FoamTableReader.H"
|
||||
#include "Scale.H"
|
||||
#include "CodedFunction1.H"
|
||||
|
||||
typedef Foam::solidBodyMotionFunctions::sixDoFMotion::translationRotationVectors
|
||||
trvType;
|
||||
|
||||
template<>
|
||||
const char* const trvType::vsType::typeName = "vector2Vector";
|
||||
|
||||
template<>
|
||||
const char* const trvType::vsType::componentNames[] = {"x", "y"};
|
||||
|
||||
template<>
|
||||
const trvType trvType::vsType::vsType::zero(vector::zero, vector::zero);
|
||||
|
||||
template<>
|
||||
const trvType trvType::vsType::one(vector::one, vector::one);
|
||||
|
||||
template<>
|
||||
const trvType trvType::vsType::max(vector::max, vector::max);
|
||||
|
||||
template<>
|
||||
const trvType trvType::vsType::min(vector::min, vector::min);
|
||||
|
||||
template<>
|
||||
const trvType trvType::vsType::rootMax(vector::rootMax, vector::rootMax);
|
||||
|
||||
template<>
|
||||
const trvType trvType::vsType::rootMin(vector::rootMin, vector::rootMin);
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makeFunction1s(trvType);
|
||||
|
||||
defineTableReader(trvType);
|
||||
makeTableReader(Foam, trvType);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::solidBodyMotionFunctions::tabulated6DoFMotion::tabulated6DoFMotion
|
||||
Foam::solidBodyMotionFunctions::sixDoFMotion::sixDoFMotion
|
||||
(
|
||||
const dictionary& SBMFCoeffs,
|
||||
const Time& runTime
|
||||
@ -65,41 +113,18 @@ Foam::solidBodyMotionFunctions::tabulated6DoFMotion::tabulated6DoFMotion
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::solidBodyMotionFunctions::tabulated6DoFMotion::~tabulated6DoFMotion()
|
||||
Foam::solidBodyMotionFunctions::sixDoFMotion::~sixDoFMotion()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::septernion
|
||||
Foam::solidBodyMotionFunctions::tabulated6DoFMotion::transformation() const
|
||||
Foam::solidBodyMotionFunctions::sixDoFMotion::transformation() const
|
||||
{
|
||||
scalar t = time_.value();
|
||||
const scalar t = time_.value();
|
||||
|
||||
if (t < times_[0])
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "current time (" << t
|
||||
<< ") is less than the minimum in the data table ("
|
||||
<< times_[0] << ')'
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
if (t > times_.last())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "current time (" << t
|
||||
<< ") is greater than the maximum in the data table ("
|
||||
<< times_.last() << ')'
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
translationRotationVectors TRV = interpolateSplineXY
|
||||
(
|
||||
t,
|
||||
times_,
|
||||
values_
|
||||
);
|
||||
translationRotationVectors TRV = translationRotation_->value(t);
|
||||
|
||||
// Convert the rotational motion from deg to rad
|
||||
TRV[1] *= pi/180.0;
|
||||
@ -113,50 +138,19 @@ Foam::solidBodyMotionFunctions::tabulated6DoFMotion::transformation() const
|
||||
}
|
||||
|
||||
|
||||
bool Foam::solidBodyMotionFunctions::tabulated6DoFMotion::read
|
||||
bool Foam::solidBodyMotionFunctions::sixDoFMotion::read
|
||||
(
|
||||
const dictionary& SBMFCoeffs
|
||||
)
|
||||
{
|
||||
solidBodyMotionFunction::read(SBMFCoeffs);
|
||||
|
||||
// If the timeDataFileName has changed read the file
|
||||
|
||||
fileName newTimeDataFileName
|
||||
translationRotation_ = Function1<translationRotationVectors>::New
|
||||
(
|
||||
fileName(SBMFCoeffs_.lookup("timeDataFileName")).expand()
|
||||
"translationRotation",
|
||||
SBMFCoeffs
|
||||
);
|
||||
|
||||
if (newTimeDataFileName != timeDataFileName_)
|
||||
{
|
||||
timeDataFileName_ = newTimeDataFileName;
|
||||
|
||||
IFstream dataStream(timeDataFileName_);
|
||||
|
||||
if (dataStream.good())
|
||||
{
|
||||
List<Tuple2<scalar, translationRotationVectors>> timeValues
|
||||
(
|
||||
dataStream
|
||||
);
|
||||
|
||||
times_.setSize(timeValues.size());
|
||||
values_.setSize(timeValues.size());
|
||||
|
||||
forAll(timeValues, i)
|
||||
{
|
||||
times_[i] = timeValues[i].first();
|
||||
values_[i] = timeValues[i].second();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Cannot open time data file " << timeDataFileName_
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
SBMFCoeffs_.lookup("CofG") >> CofG_;
|
||||
|
||||
return true;
|
||||
@ -22,7 +22,7 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::solidBodyMotionFunctions::tabulated6DoFMotion
|
||||
Foam::solidBodyMotionFunctions::sixDoFMotion
|
||||
|
||||
Description
|
||||
Tabulated 6DoF motion function.
|
||||
@ -32,16 +32,17 @@ Description
|
||||
pitch (rotation about y) and yaw (rotation about z).
|
||||
|
||||
SourceFiles
|
||||
tabulated6DoFMotion.C
|
||||
sixDoFMotion.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef tabulated6DoFMotion_H
|
||||
#define tabulated6DoFMotion_H
|
||||
#ifndef sixDoFMotion_H
|
||||
#define sixDoFMotion_H
|
||||
|
||||
#include "solidBodyMotionFunction.H"
|
||||
#include "primitiveFields.H"
|
||||
#include "Function1.H"
|
||||
#include "Vector2D.H"
|
||||
#include "primitiveFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -51,48 +52,47 @@ namespace solidBodyMotionFunctions
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class tabulated6DoFMotion Declaration
|
||||
Class sixDoFMotion Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class tabulated6DoFMotion
|
||||
class sixDoFMotion
|
||||
:
|
||||
public solidBodyMotionFunction
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Time data file name read from dictionary
|
||||
fileName timeDataFileName_;
|
||||
|
||||
//- Center of gravity read from dictionary
|
||||
vector CofG_;
|
||||
public:
|
||||
|
||||
//- Type used to read in the translation and rotation "vectors"
|
||||
typedef Vector2D<vector> translationRotationVectors;
|
||||
|
||||
//- Field of times
|
||||
scalarField times_;
|
||||
|
||||
//- Field of translation and rotation "vectors"
|
||||
Field<translationRotationVectors> values_;
|
||||
private:
|
||||
|
||||
// Private Data
|
||||
|
||||
//- Center of gravity read from dictionary
|
||||
vector CofG_;
|
||||
|
||||
//- Translation and rotation function
|
||||
autoPtr<Function1<translationRotationVectors>> translationRotation_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("tabulated6DoFMotion");
|
||||
TypeName("sixDoFMotion");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
tabulated6DoFMotion
|
||||
sixDoFMotion
|
||||
(
|
||||
const dictionary& SBMFCoeffs,
|
||||
const Time& runTime
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
tabulated6DoFMotion(const tabulated6DoFMotion&);
|
||||
sixDoFMotion(const sixDoFMotion&);
|
||||
|
||||
|
||||
//- Construct and return a clone
|
||||
@ -100,7 +100,7 @@ public:
|
||||
{
|
||||
return autoPtr<solidBodyMotionFunction>
|
||||
(
|
||||
new tabulated6DoFMotion
|
||||
new sixDoFMotion
|
||||
(
|
||||
SBMFCoeffs_,
|
||||
time_
|
||||
@ -110,7 +110,7 @@ public:
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~tabulated6DoFMotion();
|
||||
virtual ~sixDoFMotion();
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -125,7 +125,7 @@ public:
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const tabulated6DoFMotion&) = delete;
|
||||
void operator=(const sixDoFMotion&) = delete;
|
||||
};
|
||||
|
||||
|
||||
@ -56,15 +56,58 @@ namespace fv
|
||||
#include "Square.H"
|
||||
#include "Table.H"
|
||||
#include "TableFile.H"
|
||||
#include "FoamTableReader.H"
|
||||
#include "Scale.H"
|
||||
#include "CodedFunction1.H"
|
||||
|
||||
typedef Foam::fv::sixDoFAccelerationSource::accelerationVectors avType;
|
||||
|
||||
template<>
|
||||
const char* const avType::vsType::typeName = "vectorVector";
|
||||
|
||||
template<>
|
||||
const char* const avType::vsType::componentNames[] = {"x", "y", "z"};
|
||||
|
||||
template<>
|
||||
const avType avType::vsType::vsType::zero
|
||||
(
|
||||
vector::zero,
|
||||
vector::zero,
|
||||
vector::zero
|
||||
);
|
||||
|
||||
template<>
|
||||
const avType avType::vsType::one(vector::one, vector::one, vector::one);
|
||||
|
||||
template<>
|
||||
const avType avType::vsType::max(vector::max, vector::max, vector::max);
|
||||
|
||||
template<>
|
||||
const avType avType::vsType::min(vector::min, vector::min, vector::min);
|
||||
|
||||
template<>
|
||||
const avType avType::vsType::rootMax
|
||||
(
|
||||
vector::rootMax,
|
||||
vector::rootMax,
|
||||
vector::rootMax
|
||||
);
|
||||
|
||||
template<>
|
||||
const avType avType::vsType::rootMin
|
||||
(
|
||||
vector::rootMin,
|
||||
vector::rootMin,
|
||||
vector::rootMin
|
||||
);
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
typedef fv::sixDoFAccelerationSource::accelerationVectors
|
||||
sixDoFAccelerationSourceAccelerationVectors;
|
||||
|
||||
makeFunction1s(sixDoFAccelerationSourceAccelerationVectors);
|
||||
makeFunction1s(avType);
|
||||
|
||||
defineTableReader(avType);
|
||||
makeTableReader(Foam, avType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -19,10 +19,13 @@ dynamicFvMesh dynamicMotionSolverFvMesh;
|
||||
|
||||
motionSolver solidBody;
|
||||
|
||||
solidBodyMotionFunction tabulated6DoFMotion;
|
||||
solidBodyMotionFunction sixDoFMotion;
|
||||
|
||||
CofG (0 0 0);
|
||||
timeDataFileName "$FOAM_CASE/constant/6DoF.dat";
|
||||
|
||||
translationRotation tableFile;
|
||||
// interpolationScheme spline;
|
||||
file "$FOAM_CASE/constant/6DoF.dat";
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user