www.cemf.ir
rotatingAxis.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #include "rotatingAxis.hpp"
22 #include "dictionary.hpp"
23 
24 
27 (
28  const dictionary& dict
29 )
30 {
31  if(!read(dict))
32  {
34  " error in reading rotatingAxis from dictionary "<< dict.globalName()<<endl;
35  fatalExit;
36  }
37 }
38 
41 (
42  const realx3& p1,
43  const realx3& p2,
44  real omega
45 )
46  :
47  timeInterval(),
48  line(p1, p2),
49  omega_(omega),
50  rotating_(!equal(omega,0.0))
51 {
52 
53 }
54 
55 
58 {
59  auto tmp = omega_;
60  omega_ = omega;
61  rotating_ = !equal(omega, 0.0);
62  return tmp;
63 }
64 
67 (
68  const dictionary& dict
69 )
70 {
71 
72  if(!timeInterval::read(dict))return false;
73  if(!line::read(dict)) return false;
74 
75  real omega = dict.getValOrSet("omega", 0.0);
76 
77  setOmega(omega);
78  return true;
79 }
80 
83 (
84  dictionary& dict
85 ) const
86 {
87  if( !timeInterval::write(dict) ) return false;
88  if( !line::write(dict) ) return false;
89 
90  if( !dict.add("omega", omega_) )
91  {
93  " error in writing omega to dictionary "<< dict.globalName()<<endl;
94  return false;
95  }
96  return true;
97 }
98 
101 (
102  iIstream& is
103 )
104 {
105  if( !rotatingAxis::timeInterval::read(is)) return false;
106  if( !rotatingAxis::line::read(is)) return false;
107 
108  word omegaw;
109  real omega;
110 
111  is >> omegaw >> omega;
112  if( !is.check(FUNCTION_NAME))
113  {
114  ioErrorInFile(is.name(), is.lineNumber());
115  return false;
116  }
117  if(omegaw != "omega")
118  {
119  ioErrorInFile(is.name(), is.lineNumber())<<
120  " expected omega but found "<< omegaw <<endl;
121  return false;
122  }
124 
125  setOmega(omega);
126 
127  return true;
128 }
129 
132 (
133  iOstream& os
134 )const
135 {
136  if( !rotatingAxis::timeInterval::write(os)) return false;
137  if( !rotatingAxis::line::write(os) ) return false;
138 
139  os.writeWordEntry("omega", omega());
140  return os.check(FUNCTION_NAME);
141 }
pFlow::rotatingAxis::setOmega
FUNCTION_HD real setOmega(real omega)
Set omega.
Definition: rotatingAxis.cpp:57
pFlow::dictionary::getValOrSet
T getValOrSet(const word &keyword, const T &setVal) const
get the value of data entry or if not found, set the value to setVal
Definition: dictionary.hpp:415
pFlow::real
float real
Definition: builtinTypes.hpp:45
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::line
Definition: line.hpp:36
pFlow::timeInterval::write
FUNCTION_H bool write(dictionary &dict) const
Definition: timeInterval.cpp:26
pFlow::equal
INLINE_FUNCTION_HD bool equal(const box &b1, const box &b2, real tol=smallValue)
Definition: box.hpp:135
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::line::write
FUNCTION_H bool write(dictionary &ditc) const
Definition: line.cpp:61
pFlow::iIstream::readEndStatement
char readEndStatement(const char *funcName)
End statement character ;.
Definition: iIstream.cpp:359
FUNCTION_NAME
#define FUNCTION_NAME
Definition: pFlowMacros.hpp:29
pFlow::dictionary::globalName
virtual word globalName() const
global name of entry, separated with dots
Definition: dictionary.cpp:356
pFlow::dictionary::add
bool add(const word &keyword, const float &v)
add a float dataEntry
Definition: dictionary.cpp:435
rotatingAxis.hpp
pFlow::timeInterval::read
FUNCTION_H bool read(const dictionary &dict)
Definition: timeInterval.cpp:17
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::rotatingAxis::write
FUNCTION_H bool write(dictionary &dict) const
Write to dictionary.
Definition: rotatingAxis.cpp:83
pFlow::rotatingAxis::rotating_
bool rotating_
is rotating
Definition: rotatingAxis.hpp:72
pFlow::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.cpp:42
pFlow::rotatingAxis::rotatingAxis
FUNCTION_HD rotatingAxis()=default
Empty constructor.
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:62
pFlow::line::read
FUNCTION_H bool read(const dictionary &dict)
Definition: line.cpp:50
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::rotatingAxis::omega_
real omega_
rotation speed
Definition: rotatingAxis.hpp:69
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
dictionary.hpp
pFlow::rotatingAxis::omega
INLINE_FUNCTION_HD real omega() const
Return omega.
Definition: rotatingAxis.hpp:115
pFlow::timeInterval
Definition: timeInterval.hpp:16
FUNCTION_HD
#define FUNCTION_HD
Definition: pFlowMacros.hpp:61
pFlow::IOstream::name
virtual const word & name() const
Return the name of the stream.
Definition: IOstream.cpp:31
pFlow::rotatingAxis::read
FUNCTION_H bool read(const dictionary &dict)
Read from dictionary.
Definition: rotatingAxis.cpp:67
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and lineNumber.
Definition: error.hpp:87
pFlow::IOstream::lineNumber
int32 lineNumber() const
Const access to the current stream line number.
Definition: IOstream.hpp:223
pFlow::triple< real >
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::iOstream::writeWordEntry
iOstream & writeWordEntry(const word &key, const T &value)
Write a keyword/value entry.
Definition: iOstream.hpp:239
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67