engineTime.C
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) 2021-2024 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 \*---------------------------------------------------------------------------*/
25 
26 #include "engineTime.H"
27 #include "unitConversion.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace userTimes
35 {
38 }
39 }
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
45 :
47  omega_(dict(controlDict))
48 {
50 }
51 
52 
53 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
54 
56 {}
57 
58 
59 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
60 
62 (
63  const scalar theta
64 ) const
65 {
66  return theta/radToDeg(omega_.value());
67 }
68 
69 
70 Foam::scalar Foam::userTimes::engine::timeToUserTime(const scalar t) const
71 {
72  return t*radToDeg(omega_.value());
73 }
74 
75 
77 {
78  return "CAD";
79 }
80 
81 
83 {
84  return Foam::units()[unitName()];
85 }
86 
87 
89 {
90  omega_ = omega(dict(controlDict));
91  addUnits(unitName(), unitConversion(dimTime, 0, 0, userTimeToTime(1)));
92  return true;
93 }
94 
95 
96 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
A userTime based on engine crank-angle degrees.
Definition: engineTime.H:54
virtual scalar timeToUserTime(const scalar t) const
Return the time t in crank-angle.
Definition: engineTime.C:70
virtual word unitName() const
Return engine-time unit name (CAD)
Definition: engineTime.C:76
virtual scalar userTimeToTime(const scalar theta) const
Return the theta crank-angle is s.
Definition: engineTime.C:62
virtual ~engine()
Destructor.
Definition: engineTime.C:55
virtual const unitConversion & units() const
Return the engine-time unit conversion.
Definition: engineTime.C:82
virtual bool read(const dictionary &controlDict)
Read the controlDict and set all the parameters.
Definition: engineTime.C:88
engine(const dictionary &controlDict)
Construct from controlDict.
Definition: engineTime.C:44
A class for handling words, derived from string.
Definition: word.H:62
const scalar omega
addToRunTimeSelectionTable(userTime, engine, dictionary)
defineTypeNameAndDebug(engine, 0)
Namespace for OpenFOAM.
scalar radToDeg(const scalar rad)
Convert radians to degrees.
const HashTable< unitConversion > & units()
Get the table of unit conversions.
const dimensionSet dimTime
void addUnits(const word &name, const unitConversion &units)
Add a unit conversion.
runTime controlDict().lookup("adjustTimeStep") >> adjustTimeStep
dictionary dict