engineTime.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) 2011-2019 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::engineTime
26 
27 Description
28  An abstract class for the time description of the piston motion
29 
30 SourceFiles
31  engineTime.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef engineTime_H
36 #define engineTime_H
37 
38 #include "Time.H"
39 #include "IOdictionary.H"
40 #include "dimensionedScalar.H"
41 #include "runTimeSelectionTables.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class engineTime Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class engineTime
53 :
54  public Time
55 {
56 
57 protected:
58 
59  const IOdictionary dict_;
60 
61 
62 public:
63 
64  //- Runtime type information
65  TypeName("engineTime");
66 
67 
68  //- Declare runtime constructor selection table
70  (
71  autoPtr,
72  engineTime,
73  dictionary,
74  (
75  const word& name,
76  const fileName& rootPath,
77  const fileName& caseName,
78  const fileName& systemName,
79  const fileName& constantName,
80  const fileName& dictName
81  ),
82  (name, rootPath, caseName, systemName, constantName, dictName)
83  );
84 
85 
86  // Constructors
87 
88  //- Construct from objectRegistry arguments
90  (
91  const word& name,
92  const fileName& rootPath,
93  const fileName& caseName,
94  const fileName& systemName = "system",
95  const fileName& constantName = "constant",
96  const fileName& dictName = "engineGeometry"
97  );
98 
99 
100  // Selector
101 
102  static autoPtr<engineTime> New
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 
113  //- Destructor
114  virtual ~engineTime()
115  {}
116 
117 
118  // Member Functions
119  // Conversion
120 
121  //- Calculate the piston position from the engine geometry
122  // and given timr (CA or s)
123  virtual scalar pistonPosition(const scalar theta) const = 0;
124 
125 
126  // Access
127 
128  //- Return the engine geometry dictionary
129  inline const IOdictionary& engineDict() const
130  {
131  return dict_;
132  }
133 
134  //- Return current engine time
135  // (value might be expressed in CA or s depending on the model)
136  virtual scalar theta() const = 0;
137 
138  //- Return time unit
139  virtual word unit() const = 0;
140 
141  //- Return engine time increment
142  // (value might be expressed in CA or s depending on the model)
143  virtual scalar deltaTheta() const = 0;
144 
145  //- Return current piston position
147 
148  //- Return piston displacement for current time step
150 
151  //- Return piston speed for current time step
153 
154 
155  // Member Functions overriding the virtual functions in time
156 
157  //- Read the control dictionary and set the write controls etc.
158  virtual void readDict();
159 
160 
161  // Edit
162 
163  //- Read the controlDict and set all the parameters
164  virtual bool read();
165 };
166 
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 } // End namespace Foam
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:79
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual bool read()
Read the controlDict and set all the parameters.
Definition: engineTime.C:80
virtual void readDict()
Read the control dictionary and set the write controls etc.
Definition: engineTime.C:74
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
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
const IOdictionary & engineDict() const
Return the engine geometry dictionary.
Definition: engineTime.H:128
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")
Definition: engineTimeNew.C:32
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:52
virtual ~engineTime()
Destructor.
Definition: engineTime.H:113
A class for handling words, derived from string.
Definition: word.H:59
const fileName & caseName() const
Return case name.
Definition: Time.H:259
engineTime(const word &name, const fileName &rootPath, const fileName &caseName, const fileName &systemName="system", const fileName &constantName="constant", const fileName &dictName="engineGeometry")
Construct from objectRegistry arguments.
Definition: engineTime.C:40
const word dictName("particleTrackDict")
const word & name() const
Return const reference to name.
virtual scalar deltaTheta() const =0
Return engine time increment.
virtual scalar theta() const =0
Return current engine time.
const IOdictionary dict_
Definition: engineTime.H:58
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))
Declare runtime constructor selection table.
dimensionedScalar pistonSpeed() const
Return piston speed for current time step.
Definition: engineTime.C:115
TypeName("engineTime")
Runtime type information.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
virtual word unit() const =0
Return time unit.
Macros to ease declaration of run-time selection tables.
Namespace for OpenFOAM.
const fileName & rootPath() const
Return root path.
Definition: Time.H:253
dimensionedScalar pistonDisplacement() const
Return piston displacement for current time step.
Definition: engineTime.C:104