mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
revived old changes to engineTime to allow dictionary modifications to be
noticed and to make the engine geometry optional
This commit is contained in:
@ -27,21 +27,35 @@ License
|
||||
#include "engineTime.H"
|
||||
#include "mathematicalConstants.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
void Foam::engineTime::timeAdjustment()
|
||||
{
|
||||
deltaT_ = degToTime(deltaT_);
|
||||
endTime_ = degToTime(endTime_);
|
||||
|
||||
if
|
||||
(
|
||||
writeControl_ == wcRunTime
|
||||
|| writeControl_ == wcAdjustableRunTime
|
||||
)
|
||||
{
|
||||
writeInterval_ = degToTime(writeInterval_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
//- Construct from objectRegistry arguments
|
||||
engineTime::engineTime
|
||||
Foam::engineTime::engineTime
|
||||
(
|
||||
const word& name,
|
||||
const fileName& rootPath,
|
||||
const fileName& caseName,
|
||||
const fileName& systemName,
|
||||
const fileName& constantName
|
||||
const fileName& constantName,
|
||||
const fileName& dictName
|
||||
)
|
||||
:
|
||||
Time
|
||||
@ -52,7 +66,7 @@ engineTime::engineTime
|
||||
systemName,
|
||||
constantName
|
||||
),
|
||||
engineGeometry_
|
||||
dict_
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
@ -64,78 +78,84 @@ engineTime::engineTime
|
||||
false
|
||||
)
|
||||
),
|
||||
conRodLength_(engineGeometry_.lookup("conRodLength")),
|
||||
bore_(engineGeometry_.lookup("bore")),
|
||||
stroke_(engineGeometry_.lookup("stroke")),
|
||||
clearance_(engineGeometry_.lookup("clearance")),
|
||||
rpm_(engineGeometry_.lookup("rpm"))
|
||||
rpm_(dict_.lookup("rpm")),
|
||||
conRodLength_(dimensionedScalar("conRodLength", dimLength, 0)),
|
||||
bore_(dimensionedScalar("bore", dimLength, 0)),
|
||||
stroke_(dimensionedScalar("stroke", dimLength, 0)),
|
||||
clearance_(dimensionedScalar("clearance", dimLength, 0))
|
||||
{
|
||||
value() = degToTime(value());
|
||||
// the geometric parameters are not strictly required for Time
|
||||
if (dict_.found("conRodLength"))
|
||||
{
|
||||
dict_.lookup("conRodLength") >> conRodLength_;
|
||||
}
|
||||
if (dict_.found("bore"))
|
||||
{
|
||||
dict_.lookup("bore") >> bore_;
|
||||
}
|
||||
if (dict_.found("stroke"))
|
||||
{
|
||||
dict_.lookup("stroke") >> stroke_;
|
||||
}
|
||||
if (dict_.found("clearance"))
|
||||
{
|
||||
dict_.lookup("clearance") >> clearance_;
|
||||
}
|
||||
|
||||
timeAdjustment();
|
||||
|
||||
startTime_ = degToTime(startTime_);
|
||||
endTime_ = degToTime(endTime_);
|
||||
|
||||
deltaT_ = degToTime(deltaT_);
|
||||
deltaT0_ = deltaT_;
|
||||
|
||||
if
|
||||
(
|
||||
writeControl_ == wcRunTime
|
||||
|| writeControl_ == wcAdjustableRunTime
|
||||
)
|
||||
{
|
||||
writeInterval_ = degToTime(writeInterval_);
|
||||
}
|
||||
value() = degToTime(value());
|
||||
deltaT0_ = deltaT_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Read the controlDict and set all the parameters
|
||||
bool engineTime::read()
|
||||
void Foam::engineTime::readDict()
|
||||
{
|
||||
if (!Time::read())
|
||||
Time::readDict();
|
||||
timeAdjustment();
|
||||
}
|
||||
|
||||
|
||||
// Read the controlDict and set all the parameters
|
||||
bool Foam::engineTime::read()
|
||||
{
|
||||
if (Time::read())
|
||||
{
|
||||
return false;
|
||||
timeAdjustment();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
deltaT_ = degToTime(deltaT_);
|
||||
endTime_ = degToTime(endTime_);
|
||||
|
||||
if
|
||||
(
|
||||
writeControl_ == wcRunTime
|
||||
|| writeControl_ == wcAdjustableRunTime
|
||||
)
|
||||
{
|
||||
writeInterval_ = degToTime(writeInterval_);
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
scalar engineTime::degToRad(const scalar deg) const
|
||||
Foam::scalar Foam::engineTime::degToRad(const scalar deg) const
|
||||
{
|
||||
return mathematicalConstant::pi*deg/180.0;
|
||||
}
|
||||
|
||||
|
||||
scalar engineTime::degToTime(const scalar theta) const
|
||||
Foam::scalar Foam::engineTime::degToTime(const scalar theta) const
|
||||
{
|
||||
return theta/(360.0*rpm_.value()/60.0);
|
||||
// 6 * rpm => deg/s
|
||||
return theta/(6.0*rpm_.value());
|
||||
}
|
||||
|
||||
|
||||
scalar engineTime::timeToDeg(const scalar t) const
|
||||
Foam::scalar Foam::engineTime::timeToDeg(const scalar t) const
|
||||
{
|
||||
return t*(360.0*rpm_.value()/60.0);
|
||||
// 6 * rpm => deg/s
|
||||
return t*(6.0*rpm_.value());
|
||||
}
|
||||
|
||||
|
||||
scalar engineTime::theta() const
|
||||
Foam::scalar Foam::engineTime::theta() const
|
||||
{
|
||||
return timeToDeg(value());
|
||||
}
|
||||
@ -143,7 +163,7 @@ scalar engineTime::theta() const
|
||||
|
||||
// Return current crank-angle translated to a single revolution
|
||||
// (value between -180 and 180 with 0 = top dead centre)
|
||||
scalar engineTime::thetaRevolution() const
|
||||
Foam::scalar Foam::engineTime::thetaRevolution() const
|
||||
{
|
||||
scalar t = theta();
|
||||
|
||||
@ -161,13 +181,13 @@ scalar engineTime::thetaRevolution() const
|
||||
}
|
||||
|
||||
|
||||
scalar engineTime::deltaTheta() const
|
||||
Foam::scalar Foam::engineTime::deltaTheta() const
|
||||
{
|
||||
return timeToDeg(deltaT().value());
|
||||
}
|
||||
|
||||
|
||||
scalar engineTime::pistonPosition(const scalar theta) const
|
||||
Foam::scalar Foam::engineTime::pistonPosition(const scalar theta) const
|
||||
{
|
||||
return
|
||||
(
|
||||
@ -186,7 +206,7 @@ scalar engineTime::pistonPosition(const scalar theta) const
|
||||
}
|
||||
|
||||
|
||||
dimensionedScalar engineTime::pistonPosition() const
|
||||
Foam::dimensionedScalar Foam::engineTime::pistonPosition() const
|
||||
{
|
||||
return dimensionedScalar
|
||||
(
|
||||
@ -197,7 +217,7 @@ dimensionedScalar engineTime::pistonPosition() const
|
||||
}
|
||||
|
||||
|
||||
dimensionedScalar engineTime::pistonDisplacement() const
|
||||
Foam::dimensionedScalar Foam::engineTime::pistonDisplacement() const
|
||||
{
|
||||
return dimensionedScalar
|
||||
(
|
||||
@ -208,24 +228,24 @@ dimensionedScalar engineTime::pistonDisplacement() const
|
||||
}
|
||||
|
||||
|
||||
dimensionedScalar engineTime::pistonSpeed() const
|
||||
Foam::dimensionedScalar Foam::engineTime::pistonSpeed() const
|
||||
{
|
||||
return dimensionedScalar
|
||||
(
|
||||
"pistonSpeed",
|
||||
dimLength/dimTime,
|
||||
dimVelocity,
|
||||
pistonDisplacement().value()/(deltaT().value() + VSMALL)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
scalar engineTime::userTimeToTime(const scalar theta) const
|
||||
Foam::scalar Foam::engineTime::userTimeToTime(const scalar theta) const
|
||||
{
|
||||
return degToTime(theta);
|
||||
}
|
||||
|
||||
|
||||
scalar engineTime::timeToUserTime(const scalar t) const
|
||||
Foam::scalar Foam::engineTime::timeToUserTime(const scalar t) const
|
||||
{
|
||||
return timeToDeg(t);
|
||||
}
|
||||
@ -233,6 +253,4 @@ scalar engineTime::timeToUserTime(const scalar t) const
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user