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