Periodic oscillation translational constraint

This commit is contained in:
Vuko Vukcevic 2017-03-09 10:08:39 +01:00 committed by Hrvoje Jasak
parent ca5c3600fe
commit d4e6ec34c3
7 changed files with 323 additions and 4 deletions

View file

@ -21,6 +21,7 @@ $(sixDOF)/constraints/rotationalConstraints/constantAngularAcceleration/constant
$(sixDOF)/constraints/translationalConstraints/translationalConstraint/translationalConstraint.C
$(sixDOF)/constraints/translationalConstraints/constantTranslationalAcceleration/constantTranslationalAcceleration.C
$(sixDOF)/constraints/translationalConstraints/periodicOscillation/periodicOscillation.C
$(sixDOF)/sixDOFODE/sixDOFODE.C
$(sixDOF)/sixDOFODE/newSixDOFODE.C

View file

@ -51,7 +51,26 @@ Foam::constantAngularAcceleration::constantAngularAcceleration
dir_(dict.lookup("constraintDirection")),
alpha_(readScalar(dict.lookup("angularAcceleration"))),
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>

View file

@ -59,7 +59,7 @@ class constantAngularAcceleration
// Private data
//- Direction of the constraint (unit vector)
const vector dir_;
vector dir_;
//- Constant value of angular acceleration
const scalar alpha_;

View file

@ -50,7 +50,26 @@ Foam::constantTranslationalAcceleration::constantTranslationalAcceleration
translationalConstraint(name, dict),
dir_(dict.lookup("constraintDirection")),
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>

View file

@ -59,7 +59,7 @@ class constantTranslationalAcceleration
// Private data
//- Direction of the constraint (unit vector)
const vector dir_;
vector dir_;
//- Constant value of the translational acceleration
const scalar a_;

View file

@ -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;
}
// ************************************************************************* //

View file

@ -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
// ************************************************************************* //