crankConRod.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2017 OpenFOAM Foundation
9 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::crankConRod
29
30Description
31 Manage time in terms of engine RPM and crank-angle.
32
33 When crankConRod is in effect, the userTime is reported in degrees
34 crank-angle instead of in seconds. The RPM to be used is specified in
35 \c constant/engineGeometry. If only a time conversion is required,
36 the geometric engine parameters can be dropped or set to zero.
37
38 For example,
39 \verbatim
40 rpm rpm [0 0 -1 0 0] 2000;
41
42 conRodLength conRodLength [0 1 0 0 0] 0.0;
43 bore bore [0 1 0 0 0] 0.0;
44 stroke stroke [0 1 0 0 0] 0.0;
45 clearance clearance [0 1 0 0 0] 0.0;
46 \endverbatim
47
48SourceFiles
49 crankConRod.C
50
51\*---------------------------------------------------------------------------*/
52
53#ifndef crankConRod_H
54#define crankConRod_H
55
56#include "engineTime.H"
57#include "dictionary.H"
58#include "dimensionedScalar.H"
59
60// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61
62namespace Foam
63{
64
65/*---------------------------------------------------------------------------*\
66 Class crankConRod Declaration
67\*---------------------------------------------------------------------------*/
69class crankConRod
70:
71 public engineTime
72{
73 // Private data
74
75 //- RPM is required
77
78 //- Optional engine geometry parameters
79 dimensionedScalar conRodLength_;
81 dimensionedScalar stroke_;
82 dimensionedScalar clearance_;
83
84
85 // Private Member Functions
86
87 //- No copy construct
88 crankConRod(const crankConRod&) = delete;
89
90 //- No copy assignment
91 void operator=(const crankConRod&) = delete;
92
93 //- Adjust read time values
94 void timeAdjustment();
95
96public:
97
98 //- Runtime type information
99 TypeName("crankConRod");
100
101
102 // Constructors
103
104 //- Construct from objectRegistry arguments
106 (
107 const word& name,
108 const fileName& rootPath,
109 const fileName& caseName,
110 const fileName& systemName = "system",
111 const fileName& constantName = "constant",
112 const fileName& dictName = "engineGeometry"
113 );
114
115 //- Destructor
116 virtual ~crankConRod() = default;
117
118
119 // Member Functions
120
121 // Conversion
122
123 //- Convert degrees to seconds (for given engine speed in RPM)
124 scalar degToTime(const scalar theta) const;
125
126 //- Convert seconds to degrees (for given engine speed in RPM)
127 scalar timeToDeg(const scalar t) const;
128
129 //- Calculate the piston position from the engine geometry
130 // and given crank angle.
131 scalar pistonPosition(const scalar theta) const;
132
133
134 // Access
135
136 //- Return the engines current operating RPM
137 const dimensionedScalar& rpm() const
138 {
139 return rpm_;
140 }
141
142 //- Return the engines connecting-rod length
143 const dimensionedScalar& conRodLength() const
144 {
145 return conRodLength_;
146 }
147
148 //- Return the engines bore
149 const dimensionedScalar& bore() const
150 {
151 return bore_;
152 }
153
154 //- Return the engines stroke
155 const dimensionedScalar& stroke() const
156 {
157 return stroke_;
158 }
159
160 //- Return the engines clearance-gap
161 const dimensionedScalar& clearance() const
162 {
163 return clearance_;
164 }
165
166
167 //- Return current crank-angle
168 virtual scalar theta() const;
169
170 //- Return time unit
171 virtual word unit() const;
172
173 //- Return current crank-angle translated to a single revolution
174 // (value between -180 and 180 with 0 = top dead centre)
175 scalar thetaRevolution() const;
176
177 //- Return crank-angle increment
178 virtual scalar deltaTheta() const;
179
180
181 // Member functions overriding the virtual functions in time
182
183 //- Convert the user-time (CA deg) to real-time (s).
184 virtual scalar userTimeToTime(const scalar theta) const;
185
186 //- Convert the real-time (s) into user-time (CA deg)
187 virtual scalar timeToUserTime(const scalar t) const;
188
189 //- Read the control dictionary and set the write controls etc.
190 virtual void readDict();
191
192
193 // Edit
194
195 //- Read the controlDict and set all the parameters
196 virtual bool read();
197};
198
199
200// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201
202} // End namespace Foam
203
204// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205
206#endif
207
208// ************************************************************************* //
const fileName & caseName() const
Return case name.
Definition: TimePathsI.H:62
const fileName & rootPath() const
Return root path.
Definition: TimePathsI.H:50
Manage time in terms of engine RPM and crank-angle.
Definition: crankConRod.H:71
virtual void readDict()
Read the control dictionary and set the write controls etc.
Definition: crankConRod.C:104
virtual scalar timeToUserTime(const scalar t) const
Convert the real-time (s) into user-time (CA deg)
Definition: crankConRod.C:199
const dimensionedScalar & bore() const
Return the engines bore.
Definition: crankConRod.H:148
const dimensionedScalar & stroke() const
Return the engines stroke.
Definition: crankConRod.H:154
virtual ~crankConRod()=default
Destructor.
virtual scalar theta() const
Return current crank-angle.
Definition: crankConRod.C:137
const dimensionedScalar & rpm() const
Return the engines current operating RPM.
Definition: crankConRod.H:136
virtual scalar userTimeToTime(const scalar theta) const
Convert the user-time (CA deg) to real-time (s).
Definition: crankConRod.C:193
scalar thetaRevolution() const
Return current crank-angle translated to a single revolution.
Definition: crankConRod.C:149
scalar degToTime(const scalar theta) const
Convert degrees to seconds (for given engine speed in RPM)
Definition: crankConRod.C:123
scalar timeToDeg(const scalar t) const
Convert seconds to degrees (for given engine speed in RPM)
Definition: crankConRod.C:130
const dimensionedScalar & conRodLength() const
Return the engines connecting-rod length.
Definition: crankConRod.H:142
virtual scalar deltaTheta() const
Return crank-angle increment.
Definition: crankConRod.C:167
TypeName("crankConRod")
Runtime type information.
const dimensionedScalar & clearance() const
Return the engines clearance-gap.
Definition: crankConRod.H:160
virtual word unit() const
Return time unit.
Definition: crankConRod.C:143
virtual bool read()
Read the controlDict and set all the parameters.
Definition: crankConRod.C:111
const word & name() const
Return const reference to name.
An abstract class for the time description of the piston motion.
Definition: engineTime.H:57
dimensionedScalar pistonPosition() const
Return current piston position.
Definition: engineTime.C:94
A class for handling file names.
Definition: fileName.H:76
A class for handling words, derived from Foam::string.
Definition: word.H:68
const word dictName("faMeshDefinition")
Namespace for OpenFOAM.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73