mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: engineTime: Generalized to provide run-time selection of piston-motion
Standard crank-connecting rod and the new free-piston kinematics motion options are provides, others can easily be added. Contributed by Francesco Contino and Nicolas Bourgeois, BURN Research Group.
This commit is contained in:
committed by
Andrew Heather
parent
d425421c0a
commit
01efb2c85b
@ -1,4 +1,8 @@
|
||||
engineTime/engineTime.C
|
||||
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
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,12 +23,22 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "engineTime.H"
|
||||
#include "crankConRod.H"
|
||||
#include "unitConversion.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(crankConRod, 0);
|
||||
addToRunTimeSelectionTable(engineTime, crankConRod, dictionary);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::engineTime::timeAdjustment()
|
||||
void Foam::crankConRod::timeAdjustment()
|
||||
{
|
||||
deltaT_ = degToTime(deltaT_);
|
||||
endTime_ = degToTime(endTime_);
|
||||
@ -46,7 +56,7 @@ void Foam::engineTime::timeAdjustment()
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::engineTime::engineTime
|
||||
Foam::crankConRod::crankConRod
|
||||
(
|
||||
const word& name,
|
||||
const fileName& rootPath,
|
||||
@ -56,7 +66,7 @@ Foam::engineTime::engineTime
|
||||
const fileName& dictName
|
||||
)
|
||||
:
|
||||
Time
|
||||
engineTime
|
||||
(
|
||||
name,
|
||||
rootPath,
|
||||
@ -64,18 +74,6 @@ Foam::engineTime::engineTime
|
||||
systemName,
|
||||
constantName
|
||||
),
|
||||
dict_
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"engineGeometry",
|
||||
constant(),
|
||||
*this,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
),
|
||||
rpm_(dict_.lookup("rpm")),
|
||||
conRodLength_(dimensionedScalar("conRodLength", dimLength, 0)),
|
||||
bore_(dimensionedScalar("bore", dimLength, 0)),
|
||||
@ -92,6 +90,7 @@ Foam::engineTime::engineTime
|
||||
|
||||
startTime_ = degToTime(startTime_);
|
||||
value() = degToTime(value());
|
||||
|
||||
deltaTSave_ = deltaT_;
|
||||
deltaT0_ = deltaT_;
|
||||
}
|
||||
@ -99,16 +98,14 @@ Foam::engineTime::engineTime
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Read the controlDict and set all the parameters
|
||||
void Foam::engineTime::readDict()
|
||||
void Foam::crankConRod::readDict()
|
||||
{
|
||||
Time::readDict();
|
||||
timeAdjustment();
|
||||
}
|
||||
|
||||
|
||||
// Read the controlDict and set all the parameters
|
||||
bool Foam::engineTime::read()
|
||||
bool Foam::crankConRod::read()
|
||||
{
|
||||
if (Time::read())
|
||||
{
|
||||
@ -122,29 +119,33 @@ bool Foam::engineTime::read()
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::engineTime::degToTime(const scalar theta) const
|
||||
Foam::scalar Foam::crankConRod::degToTime(const scalar theta) const
|
||||
{
|
||||
// 6 * rpm => deg/s
|
||||
return theta/(6.0*rpm_.value());
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::engineTime::timeToDeg(const scalar t) const
|
||||
Foam::scalar Foam::crankConRod::timeToDeg(const scalar t) const
|
||||
{
|
||||
// 6 * rpm => deg/s
|
||||
return t*(6.0*rpm_.value());
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::engineTime::theta() const
|
||||
Foam::scalar Foam::crankConRod::theta() const
|
||||
{
|
||||
return timeToDeg(value());
|
||||
}
|
||||
|
||||
|
||||
// Return current crank-angle translated to a single revolution
|
||||
// (value between -180 and 180 with 0 = top dead centre)
|
||||
Foam::scalar Foam::engineTime::thetaRevolution() const
|
||||
Foam::word Foam::crankConRod::unit() const
|
||||
{
|
||||
return " CAD";
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::crankConRod::thetaRevolution() const
|
||||
{
|
||||
scalar t = theta();
|
||||
|
||||
@ -162,13 +163,13 @@ Foam::scalar Foam::engineTime::thetaRevolution() const
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::engineTime::deltaTheta() const
|
||||
Foam::scalar Foam::crankConRod::deltaTheta() const
|
||||
{
|
||||
return timeToDeg(deltaTValue());
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::engineTime::pistonPosition(const scalar theta) const
|
||||
Foam::scalar Foam::crankConRod::pistonPosition(const scalar theta) const
|
||||
{
|
||||
return
|
||||
(
|
||||
@ -187,46 +188,14 @@ Foam::scalar Foam::engineTime::pistonPosition(const scalar theta) const
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::engineTime::userTimeToTime(const scalar theta) const
|
||||
Foam::scalar Foam::crankConRod::userTimeToTime(const scalar theta) const
|
||||
{
|
||||
return degToTime(theta);
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::engineTime::timeToUserTime(const scalar t) const
|
||||
Foam::scalar Foam::crankConRod::timeToUserTime(const scalar t) const
|
||||
{
|
||||
return timeToDeg(t);
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -22,12 +22,12 @@ License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::engineTime
|
||||
Foam::crankConRod
|
||||
|
||||
Description
|
||||
Manage time in terms of engine RPM and crank-angle.
|
||||
|
||||
When engineTime is in effect, the userTime is reported in degrees
|
||||
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.
|
||||
@ -42,19 +42,16 @@ Description
|
||||
clearance clearance [0 1 0 0 0] 0.0;
|
||||
\endverbatim
|
||||
|
||||
Note
|
||||
The engineTime can currently only be selected at compile-time.
|
||||
|
||||
SourceFiles
|
||||
engineTime.C
|
||||
crankConRod.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef engineTime_H
|
||||
#define engineTime_H
|
||||
#ifndef crankConRod_H
|
||||
#define crankConRod_H
|
||||
|
||||
#include "Time.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "engineTime.H"
|
||||
#include "dictionary.H"
|
||||
#include "dimensionedScalar.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -63,17 +60,15 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class engineTime Declaration
|
||||
Class crankConRod Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class engineTime
|
||||
class crankConRod
|
||||
:
|
||||
public Time
|
||||
public engineTime
|
||||
{
|
||||
// Private data
|
||||
|
||||
IOdictionary dict_;
|
||||
|
||||
//- RPM is required
|
||||
dimensionedScalar rpm_;
|
||||
|
||||
@ -87,20 +82,24 @@ class engineTime
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
engineTime(const engineTime&);
|
||||
crankConRod(const crankConRod&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const engineTime&);
|
||||
void operator=(const crankConRod&);
|
||||
|
||||
//- Adjust read time values
|
||||
void timeAdjustment();
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("crankConRod");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from objectRegistry arguments
|
||||
engineTime
|
||||
crankConRod
|
||||
(
|
||||
const word& name,
|
||||
const fileName& rootPath,
|
||||
@ -111,7 +110,7 @@ public:
|
||||
);
|
||||
|
||||
//- Destructor
|
||||
virtual ~engineTime()
|
||||
virtual ~crankConRod()
|
||||
{}
|
||||
|
||||
|
||||
@ -132,12 +131,6 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the engine geometry dictionary
|
||||
const IOdictionary& engineDict() const
|
||||
{
|
||||
return dict_;
|
||||
}
|
||||
|
||||
//- Return the engines current operating RPM
|
||||
const dimensionedScalar& rpm() const
|
||||
{
|
||||
@ -170,23 +163,17 @@ public:
|
||||
|
||||
|
||||
//- Return current crank-angle
|
||||
scalar theta() const;
|
||||
virtual scalar theta() const;
|
||||
|
||||
//- Return time unit
|
||||
virtual word unit() const;
|
||||
|
||||
//- Return current crank-angle translated to a single revolution
|
||||
// (value between -180 and 180 with 0 = top dead centre)
|
||||
scalar thetaRevolution() const;
|
||||
|
||||
//- Return crank-angle increment
|
||||
scalar deltaTheta() 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 scalar deltaTheta() const;
|
||||
|
||||
|
||||
// Member functions overriding the virtual functions in time
|
||||
126
src/engine/engineTime/engineTime/engineTime.C
Normal file
126
src/engine/engineTime/engineTime/engineTime.C
Normal file
@ -0,0 +1,126 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 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 "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)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
176
src/engine/engineTime/engineTime/engineTime.H
Normal file
176
src/engine/engineTime/engineTime/engineTime.H
Normal file
@ -0,0 +1,176 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 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::engineTime
|
||||
|
||||
Description
|
||||
An abstract class for the time description of the piston motion
|
||||
|
||||
SourceFiles
|
||||
engineTime.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef engineTime_H
|
||||
#define engineTime_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<engineTime> New
|
||||
(
|
||||
const word& name,
|
||||
const fileName& rootPath,
|
||||
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 timr (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
|
||||
|
||||
// ************************************************************************* //
|
||||
80
src/engine/engineTime/engineTime/engineTimeNew.C
Normal file
80
src/engine/engineTime/engineTime/engineTimeNew.C
Normal file
@ -0,0 +1,80 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2017 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 "engineTime.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::autoPtr<Foam::engineTime> Foam::engineTime::New
|
||||
(
|
||||
const word& name,
|
||||
const fileName& rootPath,
|
||||
const fileName& caseName,
|
||||
const fileName& systemName,
|
||||
const fileName& constantName,
|
||||
const fileName& dictName
|
||||
)
|
||||
{
|
||||
IFstream engineDictFile("."/constantName/dictName);
|
||||
|
||||
dictionary engineDict(engineDictFile);
|
||||
|
||||
const word engineType
|
||||
(
|
||||
engineDict.lookupOrDefault<word>("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<engineTime>
|
||||
(
|
||||
cstrIter()
|
||||
(
|
||||
name,
|
||||
rootPath,
|
||||
caseName,
|
||||
systemName,
|
||||
constantName,
|
||||
dictName
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
91
src/engine/engineTime/freePiston/freePiston.C
Normal file
91
src/engine/engineTime/freePiston/freePiston.C
Normal file
@ -0,0 +1,91 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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 "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<scalar>::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);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
145
src/engine/engineTime/freePiston/freePiston.H
Normal file
145
src/engine/engineTime/freePiston/freePiston.H
Normal file
@ -0,0 +1,145 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017 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::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 with a tableFile
|
||||
\verbatim
|
||||
pistonPositionTime tableFile;
|
||||
pistonPositionTimeCoeffs
|
||||
{
|
||||
fileName "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<Function1<scalar>> pistonPositionTime_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
freePiston(const freePiston&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const freePiston&);
|
||||
|
||||
|
||||
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"
|
||||
);
|
||||
|
||||
//- 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;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -80,14 +80,14 @@ Foam::ignitionSite::ignitionSite
|
||||
(
|
||||
db_.userTimeToTime
|
||||
(
|
||||
edb.degToTime(readScalar(ignitionSiteDict_.lookup("start")))
|
||||
edb.userTimeToTime(readScalar(ignitionSiteDict_.lookup("start")))
|
||||
)
|
||||
),
|
||||
duration_
|
||||
(
|
||||
db_.userTimeToTime
|
||||
(
|
||||
edb.degToTime(readScalar(ignitionSiteDict_.lookup("duration")))
|
||||
edb.userTimeToTime(readScalar(ignitionSiteDict_.lookup("duration")))
|
||||
)
|
||||
),
|
||||
strength_(readScalar(ignitionSiteDict_.lookup("strength"))),
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
Info<< "Create engine time\n" << endl;
|
||||
Info<< "Create engine time\n" << endl;
|
||||
|
||||
engineTime runTime
|
||||
autoPtr<engineTime> runTimePtr
|
||||
(
|
||||
engineTime::New
|
||||
(
|
||||
Time::controlDictName,
|
||||
args.rootPath(),
|
||||
args.caseName()
|
||||
);
|
||||
)
|
||||
);
|
||||
|
||||
engineTime& runTime = runTimePtr();
|
||||
|
||||
Reference in New Issue
Block a user