diff --git a/applications/solvers/combustion/XiFoam/XiEngineFoam/XiEngineFoam.C b/applications/solvers/combustion/XiFoam/XiEngineFoam/XiEngineFoam.C index 1e5eb4b72e..09c54802c4 100644 --- a/applications/solvers/combustion/XiFoam/XiEngineFoam/XiEngineFoam.C +++ b/applications/solvers/combustion/XiFoam/XiEngineFoam/XiEngineFoam.C @@ -49,7 +49,6 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" -#include "engineTime.H" #include "engineMesh.H" #include "psiuReactionThermo.H" #include "compressibleMomentumTransportModels.H" @@ -67,12 +66,11 @@ Description int main(int argc, char *argv[]) { - #define CREATE_TIME createEngineTime.H #define CREATE_MESH createEngineMesh.H #include "postProcess.H" #include "setRootCaseLists.H" - #include "createEngineTime.H" + #include "createTime.H" #include "createEngineMesh.H" #include "createControl.H" #include "readCombustionProperties.H" @@ -99,7 +97,7 @@ int main(int argc, char *argv[]) runTime++; - Info<< "Crank angle = " << runTime.theta() << " CA-deg" << endl; + Info<< "Crank angle = " << runTime.timeName() << endl; mesh.move(); diff --git a/applications/solvers/combustion/XiFoam/XiEngineFoam/logSummary.H b/applications/solvers/combustion/XiFoam/XiEngineFoam/logSummary.H index 181fd0b4b9..d441699951 100644 --- a/applications/solvers/combustion/XiFoam/XiEngineFoam/logSummary.H +++ b/applications/solvers/combustion/XiFoam/XiEngineFoam/logSummary.H @@ -12,7 +12,7 @@ Info<< "Mean u':" << meanup << endl; logSummaryFile() - << runTime.theta() << tab + << runTime.userTimeValue() << tab << meanp << tab << meanT << tab << meanup << tab diff --git a/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C b/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C index 1a674c7c6f..51a82d1f93 100644 --- a/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C +++ b/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C @@ -30,7 +30,6 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" -#include "engineTime.H" #include "engineMesh.H" #include "psiThermo.H" #include "compressibleMomentumTransportModels.H" @@ -44,12 +43,11 @@ Description int main(int argc, char *argv[]) { - #define CREATE_TIME createEngineTime.H #define CREATE_MESH createEngineMesh.H #include "postProcess.H" #include "setRootCaseLists.H" - #include "createEngineTime.H" + #include "createTime.H" #include "createEngineMesh.H" #include "createControl.H" #include "createFields.H" diff --git a/applications/solvers/combustion/coldEngineFoam/logSummary.H b/applications/solvers/combustion/coldEngineFoam/logSummary.H index 19c98d878a..62664f774f 100644 --- a/applications/solvers/combustion/coldEngineFoam/logSummary.H +++ b/applications/solvers/combustion/coldEngineFoam/logSummary.H @@ -11,7 +11,7 @@ Info<< "Mean u':" << meanup << endl; logSummaryFile() - << runTime.theta() << tab + << runTime.userTimeValue() << tab << meanp << tab << meanT << tab << meanup diff --git a/applications/solvers/combustion/reactingFoam/engineFoam/engineFoam.C b/applications/solvers/combustion/reactingFoam/engineFoam/engineFoam.C index 120041d2e1..fe44729fbb 100644 --- a/applications/solvers/combustion/reactingFoam/engineFoam/engineFoam.C +++ b/applications/solvers/combustion/reactingFoam/engineFoam/engineFoam.C @@ -47,12 +47,11 @@ Description int main(int argc, char *argv[]) { - #define CREATE_TIME createEngineTime.H #define CREATE_MESH createEngineMesh.H #include "postProcess.H" #include "setRootCaseLists.H" - #include "createEngineTime.H" + #include "createTime.H" #include "createEngineMesh.H" #include "createEngineControls.H" #include "initContinuityErrs.H" diff --git a/applications/solvers/combustion/reactingFoam/engineFoam/logSummary.H b/applications/solvers/combustion/reactingFoam/engineFoam/logSummary.H index 5a33f48764..ce7d69b424 100644 --- a/applications/solvers/combustion/reactingFoam/engineFoam/logSummary.H +++ b/applications/solvers/combustion/reactingFoam/engineFoam/logSummary.H @@ -5,7 +5,7 @@ Info<< "Mean u':" << endl; logSummaryFile - << runTime.theta() << tab + << runTime.userTimeValue() << tab << p.weightedAverage(mesh.V()).value() << tab << T.weightedAverage(mesh.V()).value() << tab << (sqrt((2.0/3.0)*turbulence->k()))().weightedAverage(mesh.V()).value() diff --git a/applications/utilities/mesh/manipulation/moveEngineMesh/moveEngineMesh.C b/applications/utilities/mesh/manipulation/moveEngineMesh/moveEngineMesh.C index f93ba78bc3..4dea47ca29 100644 --- a/applications/utilities/mesh/manipulation/moveEngineMesh/moveEngineMesh.C +++ b/applications/utilities/mesh/manipulation/moveEngineMesh/moveEngineMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,7 +30,6 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" -#include "engineTime.H" #include "engineMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -39,7 +38,7 @@ int main(int argc, char *argv[]) { #include "setRootCase.H" - #include "createEngineTime.H" + #include "createTime.H" #include "createEngineMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -48,7 +47,7 @@ int main(int argc, char *argv[]) while (runTime.loop()) { - Info<< "Time = " << runTime.theta() << " CA-deg\n" << endl; + Info<< "Time = " << runTime.timeName() << endl; mesh.move(); diff --git a/applications/utilities/postProcessing/miscellaneous/engineCompRatio/engineCompRatio.C b/applications/utilities/postProcessing/miscellaneous/engineCompRatio/engineCompRatio.C index 0a8555c568..4558587f9e 100644 --- a/applications/utilities/postProcessing/miscellaneous/engineCompRatio/engineCompRatio.C +++ b/applications/utilities/postProcessing/miscellaneous/engineCompRatio/engineCompRatio.C @@ -32,7 +32,6 @@ Description \*---------------------------------------------------------------------------*/ #include "fvCFD.H" -#include "engineTime.H" #include "engineMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -40,7 +39,7 @@ Description int main(int argc, char *argv[]) { #include "setRootCase.H" - #include "createEngineTime.H" + #include "createTime.H" #include "createEngineMesh.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,29 +50,29 @@ int main(int argc, char *argv[]) scalar ca0 = -180.0; scalar ca1 = 0.0; - while (runTime.theta() > ca0) + while (runTime.userTimeValue() > ca0) { ca0 += fullCycle; ca1 += fullCycle; } - while (mag(runTime.theta() - ca0) > eps) + while (mag(runTime.userTimeValue() - ca0) > eps) { - scalar t0 = runTime.userTimeToTime(ca0 - runTime.theta()); + scalar t0 = runTime.userTimeToTime(ca0 - runTime.userTimeValue()); runTime.setDeltaT(t0); runTime++; - Info<< "CA = " << runTime.theta() << endl; + Info<< "CA = " << runTime.userTimeValue() << endl; mesh.move(); } scalar Vmax = sum(mesh.V().field()); - while (mag(runTime.theta()-ca1) > eps) + while (mag(runTime.userTimeValue()-ca1) > eps) { - scalar t1 = runTime.userTimeToTime(ca1 - runTime.theta()); + scalar t1 = runTime.userTimeToTime(ca1 - runTime.userTimeValue()); runTime.setDeltaT(t1); runTime++; - Info<< "CA = " << runTime.theta() << endl; + Info<< "CA = " << runTime.userTimeValue() << endl; mesh.move(); } diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index 8d06179748..40c8c9c9f7 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -116,6 +116,7 @@ void Foam::Time::setControls() if (startFrom == "startTime") { controlDict_.lookup("startTime") >> startTime_; + startTime_ = userTimeToTime(startTime_); } else { @@ -128,11 +129,11 @@ void Foam::Time::setControls() { if (timeDirs[0].name() == constant() && timeDirs.size() >= 2) { - startTime_ = timeDirs[1].value(); + startTime_ = userTimeToTime(timeDirs[1].value()); } else { - startTime_ = timeDirs[0].value(); + startTime_ = userTimeToTime(timeDirs[0].value()); } } } @@ -140,7 +141,7 @@ void Foam::Time::setControls() { if (timeDirs.size()) { - startTime_ = timeDirs.last().value(); + startTime_ = userTimeToTime(timeDirs.last().value()); } } else @@ -153,7 +154,6 @@ void Foam::Time::setControls() } setTime(startTime_, 0); - readDict(); deltaTSave_ = deltaT_; deltaT0_ = deltaT_; @@ -177,6 +177,7 @@ void Foam::Time::setControls() setTime(startTime_, 0); word newTime(timeName()); + if (newTime == oldTime) { break; diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C index 263d54f31e..092ebd67c7 100644 --- a/src/OpenFOAM/db/Time/TimeIO.C +++ b/src/OpenFOAM/db/Time/TimeIO.C @@ -40,7 +40,7 @@ void Foam::Time::readDict() if (!deltaTchanged_) { - deltaT_ = controlDict_.lookup("deltaT"); + deltaT_ = userTimeToTime(controlDict_.lookup("deltaT")); } if (controlDict_.found("writeControl")) @@ -55,6 +55,15 @@ void Foam::Time::readDict() if (controlDict_.readIfPresent("writeInterval", newWriteInterval)) { + if + ( + writeControl_ == writeControl::runTime + || writeControl_ == writeControl::adjustableRunTime + ) + { + newWriteInterval = userTimeToTime(newWriteInterval); + } + if ( writeControl_ == writeControl::timeStep @@ -120,7 +129,7 @@ void Foam::Time::readDict() if (stopAt_ == stopAtControl::endTime) { - controlDict_.lookup("endTime") >> endTime_; + endTime_ = userTimeToTime(controlDict_.lookup("endTime")); } else { @@ -132,7 +141,7 @@ void Foam::Time::readDict() endTime_ = 0; } - dimensionedScalar::name() = timeName(value()); + dimensionedScalar::name() = timeName(timeToUserTime(value())); if (controlDict_.found("writeVersion")) { diff --git a/src/engine/Make/files b/src/engine/Make/files index a53bfe3ec6..471be555d2 100644 --- a/src/engine/Make/files +++ b/src/engine/Make/files @@ -1,8 +1,3 @@ -engineTime/engineTime/engineTime.C -engineTime/engineTime/engineTimeNew.C -engineTime/freePiston/freePiston.C -engineTime/crankConRod/crankConRod.C - ignition/ignition.C ignition/ignitionIO.C ignition/ignitionSite.C diff --git a/src/engine/engineMesh/engineMesh/engineMesh.C b/src/engine/engineMesh/engineMesh/engineMesh.C index e5cb9ba961..6529ac3bf9 100644 --- a/src/engine/engineMesh/engineMesh/engineMesh.C +++ b/src/engine/engineMesh/engineMesh/engineMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,14 +24,15 @@ License \*---------------------------------------------------------------------------*/ #include "engineMesh.H" -#include "dimensionedScalar.H" +#include "../OpenFOAM/lnInclude/engineTime.H" +#include "unitConversion.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { -defineTypeNameAndDebug(engineMesh, 0); -defineRunTimeSelectionTable(engineMesh, IOobject); + defineTypeNameAndDebug(engineMesh, 0); + defineRunTimeSelectionTable(engineMesh, IOobject); } @@ -40,7 +41,26 @@ defineRunTimeSelectionTable(engineMesh, IOobject); Foam::engineMesh::engineMesh(const IOobject& io) : fvMesh(io), - engineDB_(refCast(time())), + dict_ + ( + IOobject + ( + "engineGeometry", + time().constant(), + time(), + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE, + false + ) + ), + rpm_ + ( + refCast(time().userTime()).rpm() + ), + conRodLength_("conRodLength", dimLength, dict_), + bore_("bore", dimLength, dict_), + stroke_("stroke", dimLength, dict_), + clearance_("clearance", dimLength, dict_), pistonIndex_(-1), linerIndex_(-1), cylinderHeadIndex_(-1), @@ -131,4 +151,71 @@ Foam::engineMesh::engineMesh(const IOobject& io) Foam::engineMesh::~engineMesh() {} + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::scalar Foam::engineMesh::theta() const +{ + return time().userTimeValue(); +} + + +Foam::scalar Foam::engineMesh::deltaTheta() const +{ + return time().timeToUserTime(time().deltaTValue()); +} + + +Foam::scalar Foam::engineMesh::pistonPosition(const scalar theta) const +{ + return + ( + conRodLength_.value() + + stroke_.value()/2.0 + + clearance_.value() + ) + - ( + stroke_.value()*::cos(degToRad(theta))/2.0 + + ::sqrt + ( + sqr(conRodLength_.value()) + - sqr(stroke_.value()*::sin(degToRad(theta))/2.0) + ) + ); +} + + +Foam::dimensionedScalar Foam::engineMesh::pistonPosition() const +{ + return dimensionedScalar + ( + "pistonPosition", + dimLength, + pistonPosition(theta()) + ); +} + + +Foam::dimensionedScalar Foam::engineMesh::pistonDisplacement() const +{ + return dimensionedScalar + ( + "pistonDisplacement", + dimLength, + pistonPosition(theta() - deltaTheta()) - pistonPosition().value() + ); +} + + +Foam::dimensionedScalar Foam::engineMesh::pistonSpeed() const +{ + return dimensionedScalar + ( + "pistonSpeed", + dimVelocity, + pistonDisplacement().value()/(time().deltaTValue() + vSmall) + ); +} + + // ************************************************************************* // diff --git a/src/engine/engineMesh/engineMesh/engineMesh.H b/src/engine/engineMesh/engineMesh/engineMesh.H index 321828ca68..21e285ce7d 100644 --- a/src/engine/engineMesh/engineMesh/engineMesh.H +++ b/src/engine/engineMesh/engineMesh/engineMesh.H @@ -35,7 +35,6 @@ SourceFiles #ifndef engineMesh_H #define engineMesh_H -#include "engineTime.H" #include "fvMesh.H" #include "autoPtr.H" #include "runTimeSelectionTables.H" @@ -57,7 +56,16 @@ protected: // Protected data - const engineTime& engineDB_; + const IOdictionary dict_; + + //- RPM + dimensionedScalar rpm_; + + //- Optional engine geometry parameters + dimensionedScalar conRodLength_; + dimensionedScalar bore_; + dimensionedScalar stroke_; + dimensionedScalar clearance_; label pistonIndex_; label linerIndex_; @@ -112,6 +120,56 @@ public: return true; } + //- Return the engines current operating RPM + const dimensionedScalar& rpm() const + { + return rpm_; + } + + //- Return the engines connecting-rod length + const dimensionedScalar& conRodLength() const + { + return conRodLength_; + } + + //- Return the engines bore + const dimensionedScalar& bore() const + { + return bore_; + } + + //- Return the engines stroke + const dimensionedScalar& stroke() const + { + return stroke_; + } + + //- Return the engines clearance-gap + const dimensionedScalar& clearance() const + { + return clearance_; + } + + //- Return current crank-angle + virtual scalar theta() const; + + //- Return crank-angle increment + virtual scalar deltaTheta() const; + + //- Calculate the piston position from the engine geometry + // and given crank angle. + scalar pistonPosition(const scalar theta) const; + + //- Return current piston position + dimensionedScalar pistonPosition() const; + + //- Return piston displacement for current time step + dimensionedScalar pistonDisplacement() const; + + //- Return piston speed for current time step + dimensionedScalar pistonSpeed() const; + + virtual void move() = 0; diff --git a/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C b/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C index b035b5b787..5cd0755638 100644 --- a/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C +++ b/src/engine/engineMesh/fvMotionSolverEngineMesh/fvMotionSolverEngineMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,10 +46,10 @@ Foam::fvMotionSolverEngineMesh::fvMotionSolverEngineMesh(const IOobject& io) motionSolver_ ( *this, - engineDB_.engineDict() + dict_ ) { - engineDB_.engineDict().readIfPresent("pistonLayers", pistonLayers_); + dict_.readIfPresent("pistonLayers", pistonLayers_); } @@ -63,13 +63,13 @@ Foam::fvMotionSolverEngineMesh::~fvMotionSolverEngineMesh() void Foam::fvMotionSolverEngineMesh::move() { - scalar deltaZ = engineDB_.pistonDisplacement().value(); + scalar deltaZ = pistonDisplacement().value(); Info<< "deltaZ = " << deltaZ << endl; // Position of the top of the static mesh layers above the piston scalar pistonPlusLayers = pistonPosition_.value() + pistonLayers_.value(); - scalar pistonSpeed = deltaZ/engineDB_.deltaTValue(); + scalar pistonSpeed = deltaZ/time().deltaTValue(); motionSolver_.pointMotionU().boundaryFieldRef()[pistonIndex_] == pistonSpeed; @@ -87,37 +87,7 @@ void Foam::fvMotionSolverEngineMesh::move() } motionSolver_.solve(); - - if (engineDB_.foundObject("phi")) - { - surfaceScalarField& phi = - engineDB_.lookupObjectRef("phi"); - - const volScalarField& rho = - engineDB_.lookupObject("rho"); - - const volVectorField& U = - engineDB_.lookupObject("U"); - - bool absolutePhi = false; - if (moving()) - { - phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U); - absolutePhi = true; - } - - movePoints(motionSolver_.curPoints()); - - if (absolutePhi) - { - phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U); - } - } - else - { - movePoints(motionSolver_.curPoints()); - } - + movePoints(motionSolver_.curPoints()); pistonPosition_.value() += deltaZ; diff --git a/src/engine/engineMesh/layeredEngineMesh/layeredEngineMesh.C b/src/engine/engineMesh/layeredEngineMesh/layeredEngineMesh.C index 7a809088ad..595db5db93 100644 --- a/src/engine/engineMesh/layeredEngineMesh/layeredEngineMesh.C +++ b/src/engine/engineMesh/layeredEngineMesh/layeredEngineMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -44,7 +44,7 @@ Foam::layeredEngineMesh::layeredEngineMesh(const IOobject& io) engineMesh(io), pistonLayers_("pistonLayers", dimLength, 0.0) { - engineDB_.engineDict().readIfPresent("pistonLayers", pistonLayers_); + dict_.readIfPresent("pistonLayers", pistonLayers_); } @@ -58,7 +58,7 @@ Foam::layeredEngineMesh::~layeredEngineMesh() void Foam::layeredEngineMesh::move() { - scalar deltaZ = engineDB_.pistonDisplacement().value(); + scalar deltaZ = pistonDisplacement().value(); Info<< "deltaZ = " << deltaZ << endl; // Position of the top of the static mesh layers above the piston @@ -83,38 +83,10 @@ void Foam::layeredEngineMesh::move() } } - if (engineDB_.foundObject("phi")) - { - surfaceScalarField& phi = - engineDB_.lookupObjectRef("phi"); - - const volScalarField& rho = - engineDB_.lookupObject("rho"); - - const volVectorField& U = - engineDB_.lookupObject("U"); - - bool absolutePhi = false; - if (moving()) - { - phi += fvc::interpolate(rho)*fvc::meshPhi(rho, U); - absolutePhi = true; - } - - movePoints(newPoints); - - if (absolutePhi) - { - phi -= fvc::interpolate(rho)*fvc::meshPhi(rho, U); - } - } - else - { - movePoints(newPoints); - } + movePoints(newPoints); pistonPosition_.value() += deltaZ; - scalar pistonSpeed = deltaZ/engineDB_.deltaTValue(); + scalar pistonSpeed = deltaZ/time().deltaTValue(); Info<< "clearance: " << deckHeight_.value() - pistonPosition_.value() << nl << "Piston speed = " << pistonSpeed << " m/s" << endl; diff --git a/src/engine/enginePiston/enginePiston.C b/src/engine/enginePiston/enginePiston.C index 12abe133cb..b32bb7fc0d 100644 --- a/src/engine/enginePiston/enginePiston.C +++ b/src/engine/enginePiston/enginePiston.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,8 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "enginePiston.H" -#include "engineTime.H" -#include "polyMesh.H" +#include "engineMesh.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -38,8 +37,7 @@ Foam::enginePiston::enginePiston const scalar maxLayer ) : - mesh_(mesh), - engineDB_(refCast(mesh.time())), + mesh_(refCast(mesh)), patchID_(pistonPatchName, mesh.boundaryMesh()), csPtr_(pistonCS), minLayer_(minLayer), @@ -53,8 +51,7 @@ Foam::enginePiston::enginePiston const dictionary& dict ) : - mesh_(mesh), - engineDB_(refCast(mesh_.time())), + mesh_(refCast(mesh)), patchID_(dict.lookup("patch"), mesh.boundaryMesh()), csPtr_ ( diff --git a/src/engine/enginePiston/enginePiston.H b/src/engine/enginePiston/enginePiston.H index 90a9b4679f..8e0fed19cf 100644 --- a/src/engine/enginePiston/enginePiston.H +++ b/src/engine/enginePiston/enginePiston.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -44,8 +44,7 @@ namespace Foam { // Forward declaration of classes -class polyMesh; -class engineTime; +class engineMesh; /*---------------------------------------------------------------------------*\ Class enginePiston Declaration @@ -56,10 +55,7 @@ class enginePiston // Private Data //- Reference to engine mesh - const polyMesh& mesh_; - - //- Reference to engine database - const engineTime& engineDB_; + const engineMesh& mesh_; //- Piston patch polyPatchID patchID_; diff --git a/src/engine/engineTime/crankConRod/crankConRod.C b/src/engine/engineTime/crankConRod/crankConRod.C deleted file mode 100644 index 7c2a01bf26..0000000000 --- a/src/engine/engineTime/crankConRod/crankConRod.C +++ /dev/null @@ -1,177 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2017-2021 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 "crankConRod.H" -#include "../OpenFOAM/lnInclude/engineTime.H" -#include "unitConversion.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(crankConRod, 0); - addToRunTimeSelectionTable(engineTime, crankConRod, dictionary); -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::crankConRod::timeAdjustment() -{ - deltaT_ = degToTime(deltaT_); - endTime_ = degToTime(endTime_); - - if - ( - writeControl_ == writeControl::runTime - || writeControl_ == writeControl::adjustableRunTime - ) - { - writeInterval_ = degToTime(writeInterval_); - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::crankConRod::crankConRod -( - const word& name, - const fileName& rootPath, - const fileName& caseName, - const fileName& systemName, - const fileName& constantName, - const fileName& dictName -) -: - engineTime - ( - name, - rootPath, - caseName, - systemName, - constantName - ), - rpm_ - ( - refCast(userTime()).rpm() - ), - conRodLength_(dimensionedScalar("conRodLength", dimLength, 0)), - bore_(dimensionedScalar("bore", dimLength, 0)), - stroke_(dimensionedScalar("stroke", dimLength, 0)), - clearance_(dimensionedScalar("clearance", dimLength, 0)) -{ - // geometric parameters are not strictly required for Time - dict_.readIfPresent("conRodLength", conRodLength_); - dict_.readIfPresent("bore", bore_); - dict_.readIfPresent("stroke", stroke_); - dict_.readIfPresent("clearance", clearance_); - - timeAdjustment(); - - startTime_ = degToTime(startTime_); - value() = degToTime(value()); - - deltaTSave_ = deltaT_; - deltaT0_ = deltaT_; -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::crankConRod::readDict() -{ - Time::readDict(); - timeAdjustment(); -} - - -bool Foam::crankConRod::read() -{ - if (Time::read()) - { - timeAdjustment(); - return true; - } - else - { - return false; - } -} - - -Foam::scalar Foam::crankConRod::degToTime(const scalar theta) const -{ - // 6 * rpm => deg/s - return theta/(6.0*rpm_.value()); -} - - -Foam::scalar Foam::crankConRod::timeToDeg(const scalar t) const -{ - // 6 * rpm => deg/s - return t*(6.0*rpm_.value()); -} - - -Foam::scalar Foam::crankConRod::theta() const -{ - return timeToDeg(value()); -} - - -Foam::word Foam::crankConRod::unit() const -{ - return " CAD"; -} - - -Foam::scalar Foam::crankConRod::deltaTheta() const -{ - return timeToDeg(deltaTValue()); -} - - -Foam::scalar Foam::crankConRod::pistonPosition(const scalar theta) const -{ - return - ( - conRodLength_.value() - + stroke_.value()/2.0 - + clearance_.value() - ) - - ( - stroke_.value()*::cos(degToRad(theta))/2.0 - + ::sqrt - ( - sqr(conRodLength_.value()) - - sqr(stroke_.value()*::sin(degToRad(theta))/2.0) - ) - ); -} - - -// ************************************************************************* // diff --git a/src/engine/engineTime/crankConRod/crankConRod.H b/src/engine/engineTime/crankConRod/crankConRod.H deleted file mode 100644 index 0f0597df1d..0000000000 --- a/src/engine/engineTime/crankConRod/crankConRod.H +++ /dev/null @@ -1,201 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2017-2021 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::crankConRod - -Description - Manage time in terms of engine RPM and crank-angle. - - When crankConRod is in effect, the userTime is reported in degrees - crank-angle instead of in seconds. The RPM to be used is specified in - \c constant/engineGeometry. If only a time conversion is required, - the geometric engine parameters can be dropped or set to zero. - - For example, - \verbatim - rpm rpm [0 0 -1 0 0] 2000; - - conRodLength conRodLength [0 1 0 0 0] 0.0; - bore bore [0 1 0 0 0] 0.0; - stroke stroke [0 1 0 0 0] 0.0; - clearance clearance [0 1 0 0 0] 0.0; - \endverbatim - -SourceFiles - crankConRod.C - -\*---------------------------------------------------------------------------*/ - -#ifndef crankConRod_H -#define crankConRod_H - -#include "engineTime.H" -#include "dictionary.H" -#include "dimensionedScalar.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class crankConRod Declaration -\*---------------------------------------------------------------------------*/ - -class crankConRod -: - public engineTime -{ - // Private Data - - //- RPM is required - dimensionedScalar rpm_; - - //- Optional engine geometry parameters - dimensionedScalar conRodLength_; - dimensionedScalar bore_; - dimensionedScalar stroke_; - dimensionedScalar clearance_; - - - // Private Member Functions - - //- Adjust read time values - void timeAdjustment(); - - -public: - - //- Runtime type information - TypeName("crankConRod"); - - - // Constructors - - //- Construct from objectRegistry arguments - crankConRod - ( - const word& name, - const fileName& rootPath, - const fileName& caseName, - const fileName& systemName = "system", - const fileName& constantName = "constant", - const fileName& dictName = "engineGeometry" - ); - - //- Disallow default bitwise copy construction - crankConRod(const crankConRod&) = delete; - - - //- Destructor - virtual ~crankConRod() - {} - - - // Member Functions - - // Conversion - - //- Convert degrees to seconds (for given engine speed in RPM) - scalar degToTime(const scalar theta) const; - - //- Convert seconds to degrees (for given engine speed in RPM) - scalar timeToDeg(const scalar t) const; - - //- Calculate the piston position from the engine geometry - // and given crank angle. - scalar pistonPosition(const scalar theta) const; - - - // Access - - //- Return the engines current operating RPM - const dimensionedScalar& rpm() const - { - return rpm_; - } - - //- Return the engines connecting-rod length - const dimensionedScalar& conRodLength() const - { - return conRodLength_; - } - - //- Return the engines bore - const dimensionedScalar& bore() const - { - return bore_; - } - - //- Return the engines stroke - const dimensionedScalar& stroke() const - { - return stroke_; - } - - //- Return the engines clearance-gap - const dimensionedScalar& clearance() const - { - return clearance_; - } - - - //- Return current crank-angle - virtual scalar theta() const; - - //- Return time unit - virtual word unit() const; - - //- Return crank-angle increment - virtual scalar deltaTheta() const; - - - // Member Functions overriding the virtual functions in time - - //- Read the control dictionary and set the write controls etc. - virtual void readDict(); - - - // Edit - - //- Read the controlDict and set all the parameters - virtual bool read(); - - - // Member Operators - - //- Disallow default bitwise assignment - void operator=(const crankConRod&) = delete; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/engine/engineTime/engineTime/engineTime.C b/src/engine/engineTime/engineTime/engineTime.C deleted file mode 100644 index 51e3dd1009..0000000000 --- a/src/engine/engineTime/engineTime/engineTime.C +++ /dev/null @@ -1,126 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 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 "engineTime.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(engineTime, 0); - defineRunTimeSelectionTable(engineTime, dictionary); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::engineTime::engineTime -( - const word& name, - const fileName& rootPath, - const fileName& caseName, - const fileName& systemName, - const fileName& constantName, - const fileName& dictName -) -: - Time - ( - name, - rootPath, - caseName, - systemName, - constantName - ), - dict_ - ( - IOobject - ( - "engineGeometry", - constant(), - *this, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE, - false - ) - ) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::engineTime::readDict() -{ - Time::readDict(); -} - - -bool Foam::engineTime::read() -{ - if (Time::read()) - { - return true; - } - else - { - return false; - } -} - - -Foam::dimensionedScalar Foam::engineTime::pistonPosition() const -{ - return dimensionedScalar - ( - "pistonPosition", - dimLength, - pistonPosition(theta()) - ); -} - - -Foam::dimensionedScalar Foam::engineTime::pistonDisplacement() const -{ - return dimensionedScalar - ( - "pistonDisplacement", - dimLength, - pistonPosition(theta() - deltaTheta()) - pistonPosition().value() - ); -} - - -Foam::dimensionedScalar Foam::engineTime::pistonSpeed() const -{ - return dimensionedScalar - ( - "pistonSpeed", - dimVelocity, - pistonDisplacement().value()/(deltaTValue() + vSmall) - ); -} - - -// ************************************************************************* // diff --git a/src/engine/engineTime/engineTime/engineTime.H b/src/engine/engineTime/engineTime/engineTime.H deleted file mode 100644 index dcc51e1d27..0000000000 --- a/src/engine/engineTime/engineTime/engineTime.H +++ /dev/null @@ -1,177 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 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::engineTime - -Description - An abstract class for the time description of the piston motion - -SourceFiles - engineTime.C - -\*---------------------------------------------------------------------------*/ - -#ifndef engineTime0_H -#define engineTime0_H - -#include "Time.H" -#include "IOdictionary.H" -#include "dimensionedScalar.H" -#include "runTimeSelectionTables.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class engineTime Declaration -\*---------------------------------------------------------------------------*/ - -class engineTime -: - public Time -{ - -protected: - - const IOdictionary dict_; - - -public: - - //- Runtime type information - TypeName("engineTime"); - - - //- Declare runtime constructor selection table - declareRunTimeSelectionTable - ( - autoPtr, - engineTime, - dictionary, - ( - const word& name, - const fileName& rootPath, - const fileName& caseName, - const fileName& systemName, - const fileName& constantName, - const fileName& dictName - ), - (name, rootPath, caseName, systemName, constantName, dictName) - ); - - - // Constructors - - //- Construct from objectRegistry arguments - engineTime - ( - const word& name, - const fileName& rootPath, - const fileName& caseName, - const fileName& systemName = "system", - const fileName& constantName = "constant", - const fileName& dictName = "engineGeometry" - ); - - - // Selector - - static autoPtr New - ( - const word& name, - const fileName& rootPath, - const fileName& globalCaseName, - const fileName& caseName, - const fileName& systemName = "system", - const fileName& constantName = "constant", - const fileName& dictName = "engineGeometry" - ); - - - //- Destructor - virtual ~engineTime() - {} - - - // Member Functions - // Conversion - - //- Calculate the piston position from the engine geometry - // and given time (CA or s) - virtual scalar pistonPosition(const scalar theta) const = 0; - - - // Access - - //- Return the engine geometry dictionary - inline const IOdictionary& engineDict() const - { - return dict_; - } - - //- Return current engine time - // (value might be expressed in CA or s depending on the model) - virtual scalar theta() const = 0; - - //- Return time unit - virtual word unit() const = 0; - - //- Return engine time increment - // (value might be expressed in CA or s depending on the model) - virtual scalar deltaTheta() const = 0; - - //- Return current piston position - dimensionedScalar pistonPosition() const; - - //- Return piston displacement for current time step - dimensionedScalar pistonDisplacement() const; - - //- Return piston speed for current time step - dimensionedScalar pistonSpeed() const; - - - // Member Functions overriding the virtual functions in time - - //- Read the control dictionary and set the write controls etc. - virtual void readDict(); - - - // Edit - - //- Read the controlDict and set all the parameters - virtual bool read(); -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/engine/engineTime/engineTime/engineTimeNew.C b/src/engine/engineTime/engineTime/engineTimeNew.C deleted file mode 100644 index 4ffd01e7f0..0000000000 --- a/src/engine/engineTime/engineTime/engineTimeNew.C +++ /dev/null @@ -1,81 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 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 "engineTime.H" -#include "IFstream.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::autoPtr Foam::engineTime::New -( - const word& name, - const fileName& rootPath, - const fileName& globalCaseName, - const fileName& caseName, - const fileName& systemName, - const fileName& constantName, - const fileName& dictName -) -{ - IFstream engineDictFile(rootPath/globalCaseName/constantName/dictName); - - dictionary engineDict(engineDictFile); - - const word engineType - ( - engineDict.lookupOrDefault("engineType", "crankConRod") - ); - - Info<< "Selecting engine type " << engineType << endl; - - dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(engineType); - - if (cstrIter == dictionaryConstructorTablePtr_->end()) - { - FatalErrorInFunction - << "Unknown engine type " - << engineType << nl << nl - << "Valid engine types are :" << nl - << dictionaryConstructorTablePtr_->sortedToc() - << exit(FatalError); - } - - return autoPtr - ( - cstrIter() - ( - name, - rootPath, - caseName, - systemName, - constantName, - dictName - ) - ); -} - - -// ************************************************************************* // diff --git a/src/engine/engineTime/freePiston/freePiston.C b/src/engine/engineTime/freePiston/freePiston.C deleted file mode 100644 index da48c22e72..0000000000 --- a/src/engine/engineTime/freePiston/freePiston.C +++ /dev/null @@ -1,91 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2017-2018 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 "freePiston.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(freePiston, 0); - addToRunTimeSelectionTable(engineTime, freePiston, dictionary); -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::freePiston::freePiston -( - const word& name, - const fileName& rootPath, - const fileName& caseName, - const fileName& systemName, - const fileName& constantName, - const fileName& dictName -) -: - engineTime - ( - name, - rootPath, - caseName, - systemName, - constantName - ), - pistonPositionTime_ - ( - Function1::New("pistonPositionTime", dict_) - ) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::scalar Foam::freePiston::theta() const -{ - return value(); -} - - -Foam::word Foam::freePiston::unit() const -{ - return " s"; -} - - -Foam::scalar Foam::freePiston::deltaTheta() const -{ - return deltaTValue(); -} - - -Foam::scalar Foam::freePiston::pistonPosition(const scalar theta) const -{ - return pistonPositionTime_->value(theta); -} - - -// ************************************************************************* // diff --git a/src/engine/engineTime/freePiston/freePiston.H b/src/engine/engineTime/freePiston/freePiston.H deleted file mode 100644 index d32d5ad454..0000000000 --- a/src/engine/engineTime/freePiston/freePiston.H +++ /dev/null @@ -1,146 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2017-2020 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::freePiston - -Description - In case of free pistons, the piston position is determined by a user-defined - position according to time. - - The piston trajectory is specified in \c constant/engineGeometry using a - table or a separated file. The position is relative to the cylinder head, - i.e. decreasing when compressing. - - For example, - \verbatim - pistonPositionTime table ( (0 0.13) (0.020 0.03) ); - \endverbatim - - or from a file - \verbatim - pistonPositionTime table; - pistonPositionTimeCoeffs - { - file "data"; - outOfBounds clamp; - interpolationScheme linear; - } - \endverbatim - -SourceFiles - freePiston.C - -\*---------------------------------------------------------------------------*/ - -#ifndef freePiston_H -#define freePiston_H - -#include "engineTime.H" -#include "dictionary.H" -#include "dimensionedScalar.H" -#include "Function1.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class freePiston Declaration -\*---------------------------------------------------------------------------*/ - -class freePiston -: - public engineTime -{ - // Private Data - - autoPtr> pistonPositionTime_; - - -public: - - //- Runtime type information - TypeName("freePiston"); - - - // Constructors - - //- Construct from objectRegistry arguments - freePiston - ( - const word& name, - const fileName& rootPath, - const fileName& caseName, - const fileName& systemName = "system", - const fileName& constantName = "constant", - const fileName& dictName = "engineGeometry" - ); - - //- Disallow default bitwise copy construction - freePiston(const freePiston&) = delete; - - - //- Destructor - virtual ~freePiston() - {} - - - // Member Functions - - // Conversion - - //- Calculate the piston position from the engine geometry - // and given crank angle. - scalar pistonPosition(const scalar theta) const; - - - // Access - - //- Return current engine time - virtual scalar theta() const; - - //- Return time unit - virtual word unit() const; - - //- Return engine time increment - virtual scalar deltaTheta() const; - - - // Member Operators - - //- Disallow default bitwise assignment - void operator=(const freePiston&) = delete; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/engine/engineValve/engineValve.C b/src/engine/engineValve/engineValve.C index 2024c56262..ee5086f24c 100644 --- a/src/engine/engineValve/engineValve.C +++ b/src/engine/engineValve/engineValve.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "engineValve.H" -#include "engineTime.H" +#include "engineMesh.H" #include "polyMesh.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -85,8 +85,7 @@ Foam::engineValve::engineValve ) : name_(name), - mesh_(mesh), - engineDB_(refCast(mesh.time())), + mesh_(refCast(mesh)), csPtr_(valveCS), bottomPatch_(bottomPatchName, mesh.boundaryMesh()), poppetPatch_(poppetPatchName, mesh.boundaryMesh()), @@ -116,8 +115,7 @@ Foam::engineValve::engineValve ) : name_(name), - mesh_(mesh), - engineDB_(refCast(mesh_.time())), + mesh_(refCast(mesh)), csPtr_ ( coordinateSystem::New @@ -172,7 +170,7 @@ Foam::scalar Foam::engineValve::lift(const scalar theta) const bool Foam::engineValve::isOpen() const { - return lift(engineDB_.theta()) >= minLift_; + return lift(mesh_.theta()) >= minLift_; } @@ -180,7 +178,7 @@ Foam::scalar Foam::engineValve::curLift() const { return max ( - lift(engineDB_.theta()), + lift(mesh_.theta()), minLift_ ); } @@ -193,10 +191,10 @@ Foam::scalar Foam::engineValve::curVelocity() const curLift() - max ( - lift(engineDB_.theta() - engineDB_.deltaTheta()), + lift(mesh_.theta() - mesh_.deltaTheta()), minLift_ ) - )/(engineDB_.deltaTValue() + vSmall); + )/(mesh_.time().deltaTValue() + vSmall); } diff --git a/src/engine/engineValve/engineValve.H b/src/engine/engineValve/engineValve.H index 6c1cf07d62..17acb83888 100644 --- a/src/engine/engineValve/engineValve.H +++ b/src/engine/engineValve/engineValve.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,8 +46,7 @@ namespace Foam { // Forward declaration of classes -class polyMesh; -class engineTime; +class engineMesh; /*---------------------------------------------------------------------------*\ Class engineValve Declaration @@ -61,10 +60,7 @@ class engineValve word name_; //- Reference to engine mesh - const polyMesh& mesh_; - - //- Reference to engine database - const engineTime& engineDB_; + const engineMesh& mesh_; //- Coordinate system autoPtr csPtr_; diff --git a/src/engine/ignition/ignition.H b/src/engine/ignition/ignition.H index fd7718bc36..8491dc324c 100644 --- a/src/engine/ignition/ignition.H +++ b/src/engine/ignition/ignition.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -68,9 +68,6 @@ public: //- Construct from Istream and database ignition(const dictionary&, const Time&, const fvMesh&); - //- Construct from Istream and engineTime - ignition(const dictionary&, const engineTime&, const fvMesh&); - //- Disallow default bitwise copy construction ignition(const ignition&) = delete; diff --git a/src/engine/ignition/ignitionIO.C b/src/engine/ignition/ignitionIO.C index 827bda4a6c..7aa88374fd 100644 --- a/src/engine/ignition/ignitionIO.C +++ b/src/engine/ignition/ignitionIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,7 +23,7 @@ License \*---------------------------------------------------------------------------*/ -#include "engineTime.H" +#include "Time.H" #include "ignition.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -54,30 +54,4 @@ Foam::ignition::ignition } -Foam::ignition::ignition -( - const dictionary& combustionProperties, - const engineTime& edb, - const fvMesh& mesh -) -: - mesh_(mesh), - ignite_(combustionProperties.lookup("ignite")), - ignSites_ - ( - combustionProperties.lookup("ignitionSites"), - ignitionSite::iNew(edb, mesh) - ) -{ - if (ignite_) - { - Info<< "\nIgnition on" << endl; - } - else - { - Info<< "\nIgnition switched off" << endl; - } -} - - // ************************************************************************* // diff --git a/src/engine/ignition/ignitionSite.H b/src/engine/ignition/ignitionSite.H index 4c6ac26dd7..94eefec4b6 100644 --- a/src/engine/ignition/ignitionSite.H +++ b/src/engine/ignition/ignitionSite.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -49,7 +49,6 @@ namespace Foam { class Time; -class engineTime; class fvMesh; /*---------------------------------------------------------------------------*\ @@ -115,9 +114,6 @@ public: //- Construct from Istream and database ignitionSite(Istream&, const Time&, const fvMesh&); - //- Construct from Istream and engineTime - ignitionSite(Istream&, const engineTime&, const fvMesh&); - //- Copy constructor ignitionSite(const ignitionSite&) = default; diff --git a/src/engine/ignition/ignitionSiteIO.C b/src/engine/ignition/ignitionSiteIO.C index 2e80f0b0df..5d6212af85 100644 --- a/src/engine/ignition/ignitionSiteIO.C +++ b/src/engine/ignition/ignitionSiteIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "ignitionSite.H" -#include "engineTime.H" +#include "Time.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -64,40 +64,4 @@ Foam::ignitionSite::ignitionSite } -Foam::ignitionSite::ignitionSite -( - Istream& is, - const engineTime& edb, - const fvMesh& mesh -) -: - db_(edb), - mesh_(mesh), - ignitionSiteDict_(is), - location_(ignitionSiteDict_.lookup("location")), - diameter_(ignitionSiteDict_.lookup("diameter")), - time_ - ( - db_.userTimeToTime - ( - edb.userTimeToTime(ignitionSiteDict_.lookup("start")) - ) - ), - duration_ - ( - db_.userTimeToTime - ( - edb.userTimeToTime(ignitionSiteDict_.lookup("duration")) - ) - ), - strength_(ignitionSiteDict_.lookup("strength")), - timeIndex_(db_.timeIndex()) -{ - // Check state of Istream - is.check("ignitionSite::ignitionSite(Istream&)"); - - findIgnitionCells(mesh_); -} - - // ************************************************************************* // diff --git a/src/engine/include/createEngineTime.H b/src/engine/include/createEngineTime.H deleted file mode 100644 index 256dd36c02..0000000000 --- a/src/engine/include/createEngineTime.H +++ /dev/null @@ -1,14 +0,0 @@ -Info<< "Create engine time\n" << endl; - -autoPtr runTimePtr -( - engineTime::New - ( - Time::controlDictName, - args.rootPath(), - args.globalCaseName(), - args.caseName() - ) -); - -engineTime& runTime = runTimePtr();