diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 6b02489d6f..4651484408 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -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 diff --git a/src/OpenFOAM/db/Time/userTime/engineTime/engineTime.C b/src/OpenFOAM/db/Time/userTime/engineTime/engineTime.C index b09e5689cb..174f708b88 100644 --- a/src/OpenFOAM/db/Time/userTime/engineTime/engineTime.C +++ b/src/OpenFOAM/db/Time/userTime/engineTime/engineTime.C @@ -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; } diff --git a/src/OpenFOAM/db/Time/userTime/engineTime/engineTime.H b/src/OpenFOAM/db/Time/userTime/engineTime/engineTime.H index 043bba2400..abede8b63f 100644 --- a/src/OpenFOAM/db/Time/userTime/engineTime/engineTime.H +++ b/src/OpenFOAM/db/Time/userTime/engineTime/engineTime.H @@ -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; diff --git a/src/OpenFOAM/primitives/functions/Function1/omega/omega.C b/src/OpenFOAM/primitives/functions/Function1/omega1/omega1.C similarity index 65% rename from src/OpenFOAM/primitives/functions/Function1/omega/omega.C rename to src/OpenFOAM/primitives/functions/Function1/omega1/omega1.C index b44781e8f8..b0de317394 100644 --- a/src/OpenFOAM/primitives/functions/Function1/omega/omega.C +++ b/src/OpenFOAM/primitives/functions/Function1/omega1/omega1.C @@ -23,29 +23,50 @@ License \*---------------------------------------------------------------------------*/ -#include "omega.H" +#include "omega1.H" #include "mathematicalConstants.H" +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::autoPtr> 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::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::New("rpm", dict) - : Function1::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_) {} diff --git a/src/OpenFOAM/primitives/functions/Function1/omega/omega.H b/src/OpenFOAM/primitives/functions/Function1/omega1/omega1.H similarity index 93% rename from src/OpenFOAM/primitives/functions/Function1/omega/omega.H rename to src/OpenFOAM/primitives/functions/Function1/omega1/omega1.H index db665a50e6..4b06288cac 100644 --- a/src/OpenFOAM/primitives/functions/Function1/omega/omega.H +++ b/src/OpenFOAM/primitives/functions/Function1/omega1/omega1.H @@ -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> omega_; + //- Conversion factor. 1 for omega. pi/30 for rpm. + const scalar factor_; + + + // Private Member Functions + + //- Read and construct the omega function + autoPtr> init(const dictionary& dict); + public: @@ -169,7 +173,7 @@ void writeEntry(Ostream& os, const omega& a); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#include "omegaI.H" +#include "omega1I.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/primitives/functions/Function1/omega/omegaI.H b/src/OpenFOAM/primitives/functions/Function1/omega1/omega1I.H similarity index 89% rename from src/OpenFOAM/primitives/functions/Function1/omega/omegaI.H rename to src/OpenFOAM/primitives/functions/Function1/omega1/omega1I.H index b60f407d41..716a7f59af 100644 --- a/src/OpenFOAM/primitives/functions/Function1/omega/omegaI.H +++ b/src/OpenFOAM/primitives/functions/Function1/omega1/omega1I.H @@ -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); } diff --git a/src/OpenFOAM/primitives/omega/omega.C b/src/OpenFOAM/primitives/omega/omega.C new file mode 100644 index 0000000000..260b13b0f2 --- /dev/null +++ b/src/OpenFOAM/primitives/omega/omega.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#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("omega") + : constant::mathematical::pi/30*dict.lookup("rpm"); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/omega/omega.H b/src/OpenFOAM/primitives/omega/omega.H new file mode 100644 index 0000000000..fceae6f581 --- /dev/null +++ b/src/OpenFOAM/primitives/omega/omega.H @@ -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 . + +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 + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H index 3020dcfa24..126f096644 100644 --- a/src/finiteVolume/cfdTools/general/MRF/MRFZone.H +++ b/src/finiteVolume/cfdTools/general/MRF/MRFZone.H @@ -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" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.H index 47fa45372b..d028935782 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingPressureInletOutletVelocity/rotatingPressureInletOutletVelocityFvPatchVectorField.H @@ -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" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.H index e26ead67ac..21b8a2bccb 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingTotalPressure/rotatingTotalPressureFvPatchScalarField.H @@ -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" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H index eee2a7670e..62a1a88c11 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H @@ -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" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.H index fa2ede799e..8a0ec65c39 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.H @@ -95,7 +95,7 @@ SourceFiles #include "fixedValueFvPatchFields.H" #include "Function2.H" -#include "omega.H" +#include "omega1.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.H index 3e9e265301..7cafe2b766 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/swirlInletVelocity/swirlInletVelocityFvPatchVectorField.H @@ -73,7 +73,7 @@ SourceFiles #include "fixedValueFvPatchFields.H" #include "Function2.H" -#include "omega.H" +#include "omega1.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/fvModels/derived/rotorDisk/rotorDisk.C b/src/fvModels/derived/rotorDisk/rotorDisk.C index 16df84db17..09a0908fbf 100644 --- a/src/fvModels/derived/rotorDisk/rotorDisk.C +++ b/src/fvModels/derived/rotorDisk/rotorDisk.C @@ -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("U", "U"); - // Read co-ordinate system/geometry invariant properties - scalar rpm(coeffs().lookup("rpm")); - omega_ = rpm/60.0*mathematical::twoPi; + omega_ = Foam::omega(coeffs()).value(); coeffs().lookup("nBlades") >> nBlades_; diff --git a/src/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.H b/src/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.H index 7ab102250f..871d51692c 100644 --- a/src/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.H +++ b/src/motionSolvers/displacement/solidBody/solidBodyMotionFunctions/rotatingMotion/rotatingMotion.H @@ -40,7 +40,7 @@ SourceFiles #include "solidBodyMotionFunction.H" #include "primitiveFields.H" -#include "omega.H" +#include "omega1.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //