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