omega1.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) 2022-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 "omega1.H"
27 #include "Time.H"
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 Foam::autoPtr<Foam::Function1<Foam::scalar>> Foam::Function1s::omega::init
32 (
33  const Time& time,
34  const dictionary& dict
35 )
36 {
37  const bool foundOmega = dict.found("omega");
38  const bool foundRpm = dict.found("rpm");
39 
40  if (foundOmega && foundRpm)
41  {
43  << "Rotational speeds rpm and omega both defined in dictionary "
44  << dict.name() << exit(FatalIOError);
45  }
46 
47  if (!foundOmega && !foundRpm)
48  {
50  << "Neither rotational speed rpm or omega defined in dictionary "
51  << dict.name() << exit(FatalIOError);
52  }
53 
54  return
56  (
57  foundOmega ? "omega" : "rpm",
58  tUnits_,
59  foundOmega ? unitRadians/dimTime : units()["rpm"],
60  dict
61  );
62 }
63 
64 
65 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66 
68 :
69  tUnits_(time.userUnits()),
70  omega_(init(time, dict))
71 {}
72 
73 
75 :
76  tUnits_(o.tUnits_),
77  omega_(o.omega_, false)
78 {}
79 
80 
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 
84 {
86  (
87  os,
88  tUnits_,
89  omega_->name() == "omega" ? unitRadians/dimTime : units()["rpm"],
90  omega_()
91  );
92 }
93 
94 
95 // * * * * * * * * * * * * * * * IOstream Functions * * * * * * * * * * * * //
96 
98 {
99  o.write(os);
100 }
101 
102 
103 // ************************************************************************* //
static autoPtr< Function1< Type > > New(const word &name, const Function1s::unitConversions &units, const dictionary &dict)
Select from dictionary.
Definition: Function1New.C:32
Convenience class to handle the input of time-varying rotational speed. Reads an omega Function1 entr...
Definition: omega1.H:132
omega(const Time &time, const dictionary &dict)
Construct from dictionary.
Definition: omega1.C:67
void write(Ostream &os) const
Write data to dictionary stream.
Definition: omega1.C:83
virtual const fileName & name() const
Return the name of the stream.
Definition: IOstream.H:294
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
void writeEntry(Ostream &os, const omega &a)
Definition: omega1.C:97
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
const HashTable< unitConversion > & units()
Get the table of unit conversions.
const dimensionSet dimTime
IOerror FatalIOError
const unitConversion unitRadians
dictionary dict