Skip to content
Snippets Groups Projects
Commit 776e82f3 authored by Henry's avatar Henry
Browse files

tabulatedAccelerationSource: New fvOption to support 6-DoF solid-body motion

Example usage:

SBM
{
    type            tabulatedAccelerationSource;
    active          true;
    selectionMode   all;

    tabulatedAccelerationSourceCoeffs
    {
        timeDataFileName "constant/acceleration.dat";
    }
}

Where the file constant/acceleration.dat contains a list of tuples
containing time and a vector of the linear acceleration, angular
velocity and angular acceleration e.g.

100
(
(0 ((0 0 0) (0 0 0) (0 0 0)))
(0.001 ((-0.0001 0 4e-05) (5e-5 -0.0002 -3e-8) (0.24 -0.8 -1e-4)))
.
.
.
)
parent cfe1163d
Branches
Tags
No related merge requests found
......@@ -30,6 +30,8 @@ $(derivedSources)/rotorDiskSource/trimModel/fixed/fixedTrim.C
$(derivedSources)/rotorDiskSource/trimModel/targetCoeff/targetCoeffTrim.C
$(derivedSources)/solidificationMeltingSource/solidificationMeltingSource.C
$(derivedSources)/solidificationMeltingSource/solidificationMeltingSourceIO.C
$(derivedSources)/tabulatedAccelerationSource/tabulatedAccelerationSource.C
$(derivedSources)/tabulatedAccelerationSource/tabulated6DoFAcceleration/tabulated6DoFAcceleration.C
interRegion = sources/interRegion
$(interRegion)/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.C
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "tabulated6DoFAcceleration.H"
#include "Tuple2.H"
#include "IFstream.H"
#include "interpolateSplineXY.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(tabulated6DoFAcceleration, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::tabulated6DoFAcceleration::tabulated6DoFAcceleration
(
const dictionary& accelerationCoeffs,
const Time& runTime
)
:
time_(runTime),
accelerationCoeffs_(accelerationCoeffs)
{
read(accelerationCoeffs);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::tabulated6DoFAcceleration::~tabulated6DoFAcceleration()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::tabulated6DoFAcceleration::accelerationVectors
Foam::tabulated6DoFAcceleration::acceleration() const
{
scalar t = time_.value();
if (t < times_[0])
{
FatalErrorIn
(
"tabulated6DoFAcceleration::acceleration()"
) << "current time (" << t
<< ") is less than the minimum in the data table ("
<< times_[0] << ')'
<< exit(FatalError);
}
if (t > times_.last())
{
FatalErrorIn
(
"tabulated6DoFAcceleration::acceleration()"
) << "current time (" << t
<< ") is greater than the maximum in the data table ("
<< times_.last() << ')'
<< exit(FatalError);
}
accelerationVectors avs = interpolateSplineXY
(
t,
times_,
values_
);
Info<< "tabulated6DoFAcceleration::acceleration(): "
<< "Time = " << t << " accelerations: " << avs << endl;
return avs;
}
bool Foam::tabulated6DoFAcceleration::read
(
const dictionary& accelerationCoeffs
)
{
accelerationCoeffs_ = accelerationCoeffs;
// If the timeDataFileName has changed read the file
fileName newTimeDataFileName
(
fileName(accelerationCoeffs_.lookup("timeDataFileName")).expand()
);
if (newTimeDataFileName != timeDataFileName_)
{
timeDataFileName_ = newTimeDataFileName;
IFstream dataStream(timeDataFileName_);
if (dataStream.good())
{
List<Tuple2<scalar, accelerationVectors> > timeValues
(
dataStream
);
times_.setSize(timeValues.size());
values_.setSize(timeValues.size());
forAll(timeValues, i)
{
times_[i] = timeValues[i].first();
values_[i] = timeValues[i].second();
}
}
else
{
FatalErrorIn
(
"tabulated6DoFAcceleration::read(const dictionary&)"
) << "Cannot open time data file " << timeDataFileName_
<< exit(FatalError);
}
}
return true;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::tabulated6DoFAcceleration
Description
Tabulated 6DoF acceleration.
Obtained by interpolating tabulated data for linear acceleration,
angular velocity and angular acceleration.
SourceFiles
tabulated6DoFAcceleration.C
\*---------------------------------------------------------------------------*/
#ifndef tabulated6DoFAcceleration_H
#define tabulated6DoFAcceleration_H
#include "primitiveFields.H"
#include "Vector2D.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class tabulated6DoFAcceleration Declaration
\*---------------------------------------------------------------------------*/
class tabulated6DoFAcceleration
{
// Private data
const Time& time_;
dictionary accelerationCoeffs_;
//- Time data file name read from dictionary
fileName timeDataFileName_;
//- Type used to read in the acceleration "vectors"
typedef Vector<vector> accelerationVectors;
//- Field of times
scalarField times_;
//- Field of acceleration "vectors"
Field<accelerationVectors> values_;
// Private Member Functions
//- Disallow copy construct
tabulated6DoFAcceleration(const tabulated6DoFAcceleration&);
//- Disallow default bitwise assignment
void operator=(const tabulated6DoFAcceleration&);
public:
//- Runtime type information
TypeName("tabulated6DoFAcceleration");
// Constructors
//- Construct from components
tabulated6DoFAcceleration
(
const dictionary& accelerationCoeffs,
const Time& runTime
);
//- Destructor
virtual ~tabulated6DoFAcceleration();
// Member Functions
//- Return the solid-body accelerations
virtual Vector<vector> acceleration() const;
//- Update properties from given dictionary
virtual bool read(const dictionary& accelerationCoeffs);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "tabulatedAccelerationSource.H"
#include "fvMesh.H"
#include "fvMatrices.H"
#include "geometricOneField.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
defineTypeNameAndDebug(tabulatedAccelerationSource, 0);
addToRunTimeSelectionTable
(
option,
tabulatedAccelerationSource,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fv::tabulatedAccelerationSource::tabulatedAccelerationSource
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
)
:
option(name, modelType, dict, mesh),
motion_(coeffs_, mesh.time()),
UName_(coeffs_.lookupOrDefault<word>("UName", "U")),
g0_("g0", dimAcceleration, vector::zero)
{
fieldNames_.setSize(1, UName_);
applied_.setSize(1, false);
if (mesh.foundObject<uniformDimensionedVectorField>("g"))
{
g0_ = mesh.lookupObject<uniformDimensionedVectorField>("g");
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fv::tabulatedAccelerationSource::addSup
(
fvMatrix<vector>& eqn,
const label fieldi
)
{
addSup<geometricOneField>(geometricOneField(), eqn, fieldi);
}
void Foam::fv::tabulatedAccelerationSource::addSup
(
const volScalarField& rho,
fvMatrix<vector>& eqn,
const label fieldi
)
{
addSup<volScalarField>(rho, eqn, fieldi);
}
void Foam::fv::tabulatedAccelerationSource::writeData(Ostream& os) const
{
os << indent << name_ << endl;
dict_.write(os);
}
bool Foam::fv::tabulatedAccelerationSource::read(const dictionary& dict)
{
if (option::read(dict))
{
return motion_.read(coeffs_);
}
else
{
return false;
}
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::fv::tabulatedAccelerationSource
Description
Solid-body 6-DoF acceleration source
\heading Source usage
Example usage:
\verbatim
SBM
{
type tabulatedAccelerationSource;
active true;
selectionMode all;
tabulatedAccelerationSourceCoeffs
{
timeDataFileName "constant/acceleration-terms.dat";
}
}
\endverbatim
SourceFiles
tabulatedAccelerationSource.C
\*---------------------------------------------------------------------------*/
#ifndef tabulatedAccelerationSource_H
#define tabulatedAccelerationSource_H
#include "fvOption.H"
#include "tabulated6DoFAcceleration.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace fv
{
/*---------------------------------------------------------------------------*\
Class tabulatedAccelerationSource Declaration
\*---------------------------------------------------------------------------*/
class tabulatedAccelerationSource
:
public option
{
protected:
// Protected data
//- Run-time selectable acceleration model
tabulated6DoFAcceleration motion_;
//- Velocity field name, default = U
word UName_;
dimensionedVector g0_;
private:
// Private Member Functions
//- Disallow default bitwise copy construct
tabulatedAccelerationSource(const tabulatedAccelerationSource&);
//- Disallow default bitwise assignment
void operator=(const tabulatedAccelerationSource&);
//- Source term to momentum equation
template<class RhoFieldType>
void addSup
(
const RhoFieldType& rho,
fvMatrix<vector>& eqn,
const label fieldi
);
public:
//- Runtime type information
TypeName("tabulatedAccelerationSource");
// Constructors
//- Construct from components
tabulatedAccelerationSource
(
const word& name,
const word& modelType,
const dictionary& dict,
const fvMesh& mesh
);
//- Destructor
virtual ~tabulatedAccelerationSource()
{}
// Member Functions
//- Source term to momentum equation
virtual void addSup
(
fvMatrix<vector>& eqn,
const label fieldi
);
//- Source term to compressible momentum equation
virtual void addSup
(
const volScalarField& rho,
fvMatrix<vector>& eqn,
const label fieldi
);
//- Write data
virtual void writeData(Ostream&) const;
//- Read dictionary
virtual bool read(const dictionary& dict);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace fv
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "tabulatedAccelerationSourceTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "tabulatedAccelerationSource.H"
#include "fvMesh.H"
#include "fvMatrices.H"
#include "uniformDimensionedFields.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class RhoFieldType>
void Foam::fv::tabulatedAccelerationSource::addSup
(
const RhoFieldType& rho,
fvMatrix<vector>& eqn,
const label fieldi
)
{
Vector<vector> acceleration(motion_.acceleration());
// If gravitational force is present combine with the linear acceleration
if (mesh_.foundObject<uniformDimensionedVectorField>("g"))
{
uniformDimensionedVectorField& g =
const_cast<uniformDimensionedVectorField&>
(
mesh_.lookupObject<uniformDimensionedVectorField>("g")
);
const uniformDimensionedScalarField& hRef =
mesh_.lookupObject<uniformDimensionedScalarField>("hRef");
g = g0_ - dimensionedVector("a", dimAcceleration, acceleration.x());
dimensionedScalar ghRef
(
mag(g.value()) > SMALL
? g & (cmptMag(g.value())/mag(g.value()))*hRef
: dimensionedScalar("ghRef", g.dimensions()*dimLength, 0)
);
const_cast<volScalarField&>
(
mesh_.lookupObject<volScalarField>("gh")
) = (g & mesh_.C()) - ghRef;
const_cast<surfaceScalarField&>
(
mesh_.lookupObject<surfaceScalarField>("ghf")
) = (g & mesh_.Cf()) - ghRef;
}
// ... otherwise include explicitly in the momentum equation
else
{
eqn -= rho*dimensionedVector("a", dimAcceleration, acceleration.x());
}
dimensionedVector Omega
(
"Omega",
dimensionSet(0, 0, -1, 0, 0),
acceleration.y()
);
dimensionedVector dOmegaDT
(
"dOmegaDT",
dimensionSet(0, 0, -2, 0, 0),
acceleration.z()
);
eqn -=
(
rho*(2*Omega ^ eqn.psi()) // Coriolis force
+ rho*(Omega ^ (Omega ^ mesh_.C())) // Centrifugal force
+ rho*(dOmegaDT ^ mesh_.C()) // Angular tabulatedAcceleration force
);
}
// ************************************************************************* //
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