engineTime, rotorDisk: Optional angular velocity specification

Angular velocity can be specified either as 'rpm' or 'omega',
consistently with other parts of OpenFOAM.
This commit is contained in:
Will Bainbridge
2024-04-19 16:45:34 +01:00
parent c3f131e816
commit 0b130b5620
16 changed files with 209 additions and 60 deletions

View File

@ -89,6 +89,8 @@ primitives/quaternion/quaternion.C
primitives/septernion/septernion.C
primitives/triad/triad.C
primitives/omega/omega.C
# Run-time selectable functions
primitives/functions/Function1/makeFunction1s.C
primitives/functions/Function1/reverseRamp/reverseRamp.C
@ -102,7 +104,7 @@ primitives/functions/Function1/squarePulse/squarePulse.C
primitives/functions/Function1/Table/tableBase.C
primitives/functions/Function1/Table/TableReader/makeTableReaders.C
primitives/functions/Function1/unknownTypeFunction1/unknownTypeFunction1.C
primitives/functions/Function1/omega/omega.C
primitives/functions/Function1/omega1/omega1.C
primitives/functions/Function2/makeFunction2s.C

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2021-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "engineTime.H"
#include "unitConversion.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -43,9 +44,8 @@ namespace userTimes
Foam::userTimes::engine::engine(const dictionary& controlDict)
:
userTime(controlDict),
rpm_("rpm", dimless/dimTime, 0)
omega_(dict(controlDict))
{
read(controlDict);
addUnit(dimensionedScalar(unit(), dimTime, userTimeToTime(1)));
}
@ -58,24 +58,18 @@ Foam::userTimes::engine::~engine()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::dimensionedScalar& Foam::userTimes::engine::rpm() const
{
return rpm_;
}
Foam::scalar Foam::userTimes::engine::userTimeToTime
(
const scalar theta
) const
{
return theta/(6*rpm_.value());
return theta/radToDeg(omega_.value());
}
Foam::scalar Foam::userTimes::engine::timeToUserTime(const scalar t) const
{
return t*(6*rpm_.value());
return t*radToDeg(omega_.value());
}
@ -87,7 +81,7 @@ Foam::word Foam::userTimes::engine::unit() const
bool Foam::userTimes::engine::read(const dictionary& controlDict)
{
rpm_.read(dict(controlDict));
omega_ = omega(dict(controlDict));
addUnit(dimensionedScalar(unit(), dimTime, userTimeToTime(1)));
return true;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2021 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2021-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -36,7 +36,7 @@ SourceFiles
#define engineTime_H
#include "userTime.H"
#include "dimensionedTypes.H"
#include "omega.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,8 +55,8 @@ class engine
{
// Private Data
//- The engine RPM
dimensionedScalar rpm_;
//- The engine angular speed [rad/s]
omega omega_;
public:
@ -77,9 +77,6 @@ public:
// Member Functions
//- Return the RPM
const dimensionedScalar& rpm() const;
//- Return the theta crank-angle is s
virtual scalar userTimeToTime(const scalar theta) const;

View File

@ -23,29 +23,50 @@ License
\*---------------------------------------------------------------------------*/
#include "omega.H"
#include "omega1.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::autoPtr<Foam::Function1<Foam::scalar>> Foam::Function1s::omega::init
(
const dictionary& dict
)
{
const bool foundOmega = dict.found("omega");
const bool foundRpm = dict.found("rpm");
if (foundOmega && foundRpm)
{
FatalIOErrorInFunction(dict)
<< "Rotational speeds rpm and omega both defined in dictionary "
<< dict.name() << exit(FatalIOError);
}
if (!foundOmega && !foundRpm)
{
FatalIOErrorInFunction(dict)
<< "Neither rotational speed rpm or omega defined in dictionary "
<< dict.name() << exit(FatalIOError);
}
return Function1<scalar>::New(foundOmega ? "omega" : "rpm", dict);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::Function1s::omega::omega(const dictionary& dict)
:
rpm_(dict.found("rpm")),
omegaFactor_(rpm_ ? constant::mathematical::pi/30.0 : 1),
omega_
(
rpm_
? Function1<scalar>::New("rpm", dict)
: Function1<scalar>::New("omega", dict)
)
omega_(init(dict)),
factor_(omega_->name() == "omega" ? 1 : constant::mathematical::pi/30)
{}
Foam::Function1s::omega::omega(const omega& o)
:
rpm_(o.rpm_),
omegaFactor_(o.omegaFactor_),
omega_(o.omega_, false)
omega_(o.omega_, false),
factor_(o.factor_)
{}

View File

@ -85,12 +85,13 @@ See also
Foam::Function1s
SourceFiles
omega.C
omega1.C
omega1I.H
\*---------------------------------------------------------------------------*/
#ifndef omega_H
#define omega_H
#ifndef omega1_H
#define omega1_H
#include "Function1.H"
@ -109,15 +110,18 @@ class omega
{
// Private Data
//- True if the input specification is rpm rather than omega
const bool rpm_;
//- 1 for omega, pi/30 for rpm
const scalar omegaFactor_;
//- The omega function
const autoPtr<Function1<scalar>> omega_;
//- Conversion factor. 1 for omega. pi/30 for rpm.
const scalar factor_;
// Private Member Functions
//- Read and construct the omega function
autoPtr<Function1<scalar>> init(const dictionary& dict);
public:
@ -169,7 +173,7 @@ void writeEntry(Ostream& os, const omega& a);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "omegaI.H"
#include "omega1I.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2022-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -23,11 +23,13 @@ License
\*---------------------------------------------------------------------------*/
#include "omega1.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::scalar Foam::Function1s::omega::value(const scalar t) const
{
return omegaFactor_*omega_->value(t);
return factor_*omega_->value(t);
}
@ -37,7 +39,7 @@ inline Foam::scalar Foam::Function1s::omega::integral
const scalar t2
) const
{
return omegaFactor_*omega_->integral(t1, t2);
return factor_*omega_->integral(t1, t2);
}

View File

@ -0,0 +1,59 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2024 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 "omega.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::omega::omega(const dictionary& dict)
:
dimensionedScalar("omega", dimless/dimTime, NaN)
{
const bool foundOmega = dict.found("omega");
const bool foundRpm = dict.found("rpm");
if (foundOmega && foundRpm)
{
FatalIOErrorInFunction(dict)
<< "Rotational speeds rpm and omega both defined in dictionary "
<< dict.name() << exit(FatalIOError);
}
if (!foundOmega && !foundRpm)
{
FatalIOErrorInFunction(dict)
<< "Neither rotational speed rpm or omega defined in dictionary "
<< dict.name() << exit(FatalIOError);
}
value() =
foundOmega
? dict.lookup<scalar>("omega")
: constant::mathematical::pi/30*dict.lookup<scalar>("rpm");
}
// ************************************************************************* //

View File

@ -0,0 +1,71 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2024 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::omega
Description
User convenience class to handle the input of time-varying rotational speed
in rad/s if \c omega is specified or rpm if \c rpm is specified.
SourceFiles
omega.C
\*---------------------------------------------------------------------------*/
#ifndef omega_H
#define omega_H
#include "dimensionedScalar.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class omega Declaration
\*---------------------------------------------------------------------------*/
class omega
:
public dimensionedScalar
{
public:
// Constructors
//- Construct from dictionary
omega(const dictionary& dict);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,7 +42,7 @@ SourceFiles
#include "fvCellSet.H"
#include "volFieldsFwd.H"
#include "surfaceFields.H"
#include "omega.H"
#include "omega1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -77,7 +77,7 @@ SourceFiles
#include "fvPatchFields.H"
#include "pressureInletOutletVelocityFvPatchVectorField.H"
#include "omega.H"
#include "omega1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -75,7 +75,7 @@ SourceFiles
#define rotatingTotalPressureFvPatchScalarField_H
#include "totalPressureFvPatchScalarField.H"
#include "omega.H"
#include "omega1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -65,7 +65,7 @@ SourceFiles
#define rotatingWallVelocityFvPatchVectorField_H
#include "fixedValueFvPatchFields.H"
#include "omega.H"
#include "omega1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -95,7 +95,7 @@ SourceFiles
#include "fixedValueFvPatchFields.H"
#include "Function2.H"
#include "omega.H"
#include "omega1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -73,7 +73,7 @@ SourceFiles
#include "fixedValueFvPatchFields.H"
#include "Function2.H"
#include "omega.H"
#include "omega1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,6 +28,7 @@ License
#include "geometricOneField.H"
#include "syncTools.H"
#include "axesRotation.H"
#include "omega.H"
#include "addToRunTimeSelectionTable.H"
using namespace Foam::constant;
@ -76,9 +77,7 @@ void Foam::fv::rotorDisk::readCoeffs()
{
UName_ = coeffs().lookupOrDefault<word>("U", "U");
// Read co-ordinate system/geometry invariant properties
scalar rpm(coeffs().lookup<scalar>("rpm"));
omega_ = rpm/60.0*mathematical::twoPi;
omega_ = Foam::omega(coeffs()).value();
coeffs().lookup("nBlades") >> nBlades_;

View File

@ -40,7 +40,7 @@ SourceFiles
#include "solidBodyMotionFunction.H"
#include "primitiveFields.H"
#include "omega.H"
#include "omega1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //