Periodic oscillation translational constraint
This commit is contained in:
parent
65b54e96d0
commit
9caa3ceb3b
7 changed files with 323 additions and 4 deletions
|
@ -21,6 +21,7 @@ $(sixDOF)/constraints/rotationalConstraints/constantAngularAcceleration/constant
|
||||||
|
|
||||||
$(sixDOF)/constraints/translationalConstraints/translationalConstraint/translationalConstraint.C
|
$(sixDOF)/constraints/translationalConstraints/translationalConstraint/translationalConstraint.C
|
||||||
$(sixDOF)/constraints/translationalConstraints/constantTranslationalAcceleration/constantTranslationalAcceleration.C
|
$(sixDOF)/constraints/translationalConstraints/constantTranslationalAcceleration/constantTranslationalAcceleration.C
|
||||||
|
$(sixDOF)/constraints/translationalConstraints/periodicOscillation/periodicOscillation.C
|
||||||
|
|
||||||
$(sixDOF)/sixDOFODE/sixDOFODE.C
|
$(sixDOF)/sixDOFODE/sixDOFODE.C
|
||||||
$(sixDOF)/sixDOFODE/newSixDOFODE.C
|
$(sixDOF)/sixDOFODE/newSixDOFODE.C
|
||||||
|
|
|
@ -51,7 +51,26 @@ Foam::constantAngularAcceleration::constantAngularAcceleration
|
||||||
dir_(dict.lookup("constraintDirection")),
|
dir_(dict.lookup("constraintDirection")),
|
||||||
alpha_(readScalar(dict.lookup("angularAcceleration"))),
|
alpha_(readScalar(dict.lookup("angularAcceleration"))),
|
||||||
inGlobal_(dict.lookup("inGlobalCoordinateSystem"))
|
inGlobal_(dict.lookup("inGlobalCoordinateSystem"))
|
||||||
{}
|
{
|
||||||
|
// Rescale direction
|
||||||
|
if (mag(dir_) < SMALL)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"Foam::constantTranslationalAcceleration::"
|
||||||
|
"constantTranslationalAcceleration"
|
||||||
|
"\n("
|
||||||
|
"\n const word& name,"
|
||||||
|
"\n const dictionary& dict"
|
||||||
|
"\n)"
|
||||||
|
) << "Zero direction specified. This is not allowed."
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dir_ /= mag(dir_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::autoPtr<Foam::rotationalConstraint>
|
Foam::autoPtr<Foam::rotationalConstraint>
|
||||||
|
|
|
@ -59,7 +59,7 @@ class constantAngularAcceleration
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Direction of the constraint (unit vector)
|
//- Direction of the constraint (unit vector)
|
||||||
const vector dir_;
|
vector dir_;
|
||||||
|
|
||||||
//- Constant value of angular acceleration
|
//- Constant value of angular acceleration
|
||||||
const scalar alpha_;
|
const scalar alpha_;
|
||||||
|
|
|
@ -50,7 +50,26 @@ Foam::constantTranslationalAcceleration::constantTranslationalAcceleration
|
||||||
translationalConstraint(name, dict),
|
translationalConstraint(name, dict),
|
||||||
dir_(dict.lookup("constraintDirection")),
|
dir_(dict.lookup("constraintDirection")),
|
||||||
a_(readScalar(dict.lookup("translationalAcceleration")))
|
a_(readScalar(dict.lookup("translationalAcceleration")))
|
||||||
{}
|
{
|
||||||
|
// Rescale direction
|
||||||
|
if (mag(dir_) < SMALL)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"Foam::constantTranslationalAcceleration::"
|
||||||
|
"constantTranslationalAcceleration"
|
||||||
|
"\n("
|
||||||
|
"\n const word& name,"
|
||||||
|
"\n const dictionary& dict"
|
||||||
|
"\n)"
|
||||||
|
) << "Zero direction specified. This is not allowed."
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dir_ /= mag(dir_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::autoPtr<Foam::translationalConstraint>
|
Foam::autoPtr<Foam::translationalConstraint>
|
||||||
|
|
|
@ -59,7 +59,7 @@ class constantTranslationalAcceleration
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
//- Direction of the constraint (unit vector)
|
//- Direction of the constraint (unit vector)
|
||||||
const vector dir_;
|
vector dir_;
|
||||||
|
|
||||||
//- Constant value of the translational acceleration
|
//- Constant value of the translational acceleration
|
||||||
const scalar a_;
|
const scalar a_;
|
||||||
|
|
|
@ -0,0 +1,136 @@
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | foam-extend: Open Source CFD
|
||||||
|
\\ / O peration | Version: 4.0
|
||||||
|
\\ / A nd | Web: http://www.foam-extend.org
|
||||||
|
\\/ M anipulation | For copyright notice see file Copyright
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of foam-extend.
|
||||||
|
|
||||||
|
foam-extend 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.
|
||||||
|
|
||||||
|
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "periodicOscillation.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "mathematicalConstants.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(periodicOscillation, 0);
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
translationalConstraint,
|
||||||
|
periodicOscillation,
|
||||||
|
word
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::periodicOscillation::periodicOscillation
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
translationalConstraint(name, dict),
|
||||||
|
dir_(dict.lookup("direction")),
|
||||||
|
a_(readScalar(dict.lookup("motionAmplitude"))),
|
||||||
|
period_(readScalar(dict.lookup("period"))),
|
||||||
|
omega_(mathematicalConstant::twoPi/period_),
|
||||||
|
phi_(readScalar(dict.lookup("phaseShift"))*mathematicalConstant::pi/180.0)
|
||||||
|
{
|
||||||
|
// Rescale direction
|
||||||
|
if (mag(dir_) < SMALL)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"Foam::periodicOscillation::periodicOscillation"
|
||||||
|
"\n("
|
||||||
|
"\n const word& name,"
|
||||||
|
"\n const dictionary& dict"
|
||||||
|
"\n)"
|
||||||
|
) << "Zero direction specified. This is not allowed."
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dir_ /= mag(dir_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::autoPtr<Foam::translationalConstraint>
|
||||||
|
Foam::periodicOscillation::clone() const
|
||||||
|
{
|
||||||
|
return autoPtr<translationalConstraint>
|
||||||
|
(
|
||||||
|
new periodicOscillation(*this)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::periodicOscillation::~periodicOscillation()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::vector Foam::periodicOscillation::matrixContribution
|
||||||
|
(
|
||||||
|
const scalar,
|
||||||
|
const tensor&,
|
||||||
|
const vector&,
|
||||||
|
const vector&
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return dir_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::scalar Foam::periodicOscillation::sourceContribution
|
||||||
|
(
|
||||||
|
const scalar t,
|
||||||
|
const tensor&,
|
||||||
|
const vector&,
|
||||||
|
const vector&
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return -a_*sqr(omega_)*(sin(omega_*t + phi_));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::periodicOscillation::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
os.writeKeyword("type") << tab << type()
|
||||||
|
<< token::END_STATEMENT << nl << nl;
|
||||||
|
|
||||||
|
os.writeKeyword("direction") << tab << dir_
|
||||||
|
<< token::END_STATEMENT << nl;
|
||||||
|
os.writeKeyword("motionAmplitude") << tab << a_
|
||||||
|
<< token::END_STATEMENT << nl;
|
||||||
|
os.writeKeyword("period") << tab << period_
|
||||||
|
<< token::END_STATEMENT << nl;
|
||||||
|
os.writeKeyword("phaseShift") << tab
|
||||||
|
<< phi_*180.0/mathematicalConstant::pi << token::END_STATEMENT << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
|
@ -0,0 +1,144 @@
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | foam-extend: Open Source CFD
|
||||||
|
\\ / O peration | Version: 4.0
|
||||||
|
\\ / A nd | Web: http://www.foam-extend.org
|
||||||
|
\\/ M anipulation | For copyright notice see file Copyright
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of foam-extend.
|
||||||
|
|
||||||
|
foam-extend 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.
|
||||||
|
|
||||||
|
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::periodicOscillation
|
||||||
|
|
||||||
|
Description
|
||||||
|
Periodic translational motion given by:
|
||||||
|
|
||||||
|
g(vDot, t) = vDot + a*omega^2*sin(omega*t + phi) = 0,
|
||||||
|
|
||||||
|
where a is the amplitude of oscillation, omega radial frequency and phi is
|
||||||
|
the phase shift.
|
||||||
|
|
||||||
|
Author
|
||||||
|
Viktor Pandza, FSB Zagreb. All rights reserved.
|
||||||
|
Vuko Vukcevic, FSB Zagreb. All rights reserved.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
periodicOscillation.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef periodicOscillation_H
|
||||||
|
#define periodicOscillation_H
|
||||||
|
|
||||||
|
#include "translationalConstraint.H"
|
||||||
|
#include "OFstream.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class periodicOscillation Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class periodicOscillation
|
||||||
|
:
|
||||||
|
public translationalConstraint
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Direction
|
||||||
|
vector dir_;
|
||||||
|
|
||||||
|
//- Amplitude of the motion
|
||||||
|
const scalar a_;
|
||||||
|
|
||||||
|
//- Period of the motion
|
||||||
|
const scalar period_;
|
||||||
|
|
||||||
|
//- Radian frequency of the motion
|
||||||
|
const scalar omega_;
|
||||||
|
|
||||||
|
//- Phase shift (in degrees)
|
||||||
|
const scalar phi_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("periodicOscillation");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
periodicOscillation
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const dictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Construct and return a clone
|
||||||
|
virtual autoPtr<translationalConstraint> clone() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
|
||||||
|
virtual ~periodicOscillation();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Constraint specific functions
|
||||||
|
|
||||||
|
//- Return matrix contribution defined by constraint, f(t)
|
||||||
|
virtual vector matrixContribution
|
||||||
|
(
|
||||||
|
const scalar,
|
||||||
|
const tensor&,
|
||||||
|
const vector&,
|
||||||
|
const vector&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Return source contribution defined by constraint, a(t)
|
||||||
|
virtual scalar sourceContribution
|
||||||
|
(
|
||||||
|
const scalar t,
|
||||||
|
const tensor&,
|
||||||
|
const vector&,
|
||||||
|
const vector&
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// I-O Functions
|
||||||
|
|
||||||
|
//- Virtual write function
|
||||||
|
virtual void write(Ostream& os) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
Reference in a new issue