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 
32  if(!read(dict))
33  {
35  " error in reading rotatingAxis from dictionary "<< dict.globalName()<<endl;
36  fatalExit;
37  }
38 }
39 
42 (
43  const realx3& p1,
44  const realx3& p2,
45  real omega
46 )
47  :
48  timeInterval(),
49  line(p1, p2),
50  omega_(omega),
51  rotating_(!equal(omega,0.0))
52 {
53 
54 }
55 
56 
59 {
60  auto tmp = omega_;
61  omega_ = omega;
62  rotating_ = !equal(omega, 0.0);
63  return tmp;
64 }
65 
68 (
69  const dictionary& dict
70 )
71 {
72 
73  if(!timeInterval::read(dict))return false;
74  if(!line::read(dict)) return false;
75 
76  real omega = dict.getValOrSet("omega", static_cast<real>(0.0));
77 
78  setOmega(omega);
79  return true;
80 }
81 
84 (
85  dictionary& dict
86 ) const
87 {
88  if( !timeInterval::write(dict) ) return false;
89  if( !line::write(dict) ) return false;
90 
91  if( !dict.add("omega", omega_) )
92  {
94  " error in writing omega to dictionary "<< dict.globalName()<<endl;
95  return false;
96  }
97  return true;
98 }
99 
102 (
103  iIstream& is
104 )
105 {
106  if( !rotatingAxis::timeInterval::read(is)) return false;
107  if( !rotatingAxis::line::read(is)) return false;
108 
109  word omegaw;
110  real omega;
111 
112  is >> omegaw >> omega;
113  if( !is.check(FUNCTION_NAME))
114  {
115  ioErrorInFile(is.name(), is.lineNumber());
116  return false;
117  }
118  if(omegaw != "omega")
119  {
120  ioErrorInFile(is.name(), is.lineNumber())<<
121  " expected omega but found "<< omegaw <<endl;
122  return false;
123  }
125 
126  setOmega(omega);
127 
128  return true;
129 }
130 
133 (
134  iOstream& os
135 )const
136 {
137  if( !rotatingAxis::timeInterval::write(os)) return false;
138  if( !rotatingAxis::line::write(os) ) return false;
139 
140  os.writeWordEntry("omega", omega());
141  return os.check(FUNCTION_NAME);
142 }
pFlow::rotatingAxis::setOmega
FUNCTION_HD real setOmega(real omega)
Set omega.
Definition: rotatingAxis.cpp:58
pFlow::dictionary::getValOrSet
T getValOrSet(const word &keyword, const T &setVal) const
Definition: dictionary.hpp:325
pFlow::real
float real
Definition: builtinTypes.hpp:46
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::line
Definition: line.hpp:36
pFlow::timeInterval::write
FUNCTION_H bool write(dictionary &dict) const
Definition: timeInterval.cpp:26
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::line::write
FUNCTION_H bool write(dictionary &ditc) const
Definition: line.cpp:61
pFlow::iIstream::readEndStatement
char readEndStatement(const char *funcName)
Definition: iIstream.cpp:332
FUNCTION_NAME
#define FUNCTION_NAME
Definition: pFlowMacros.hpp:29
pFlow::dictionary::globalName
virtual word globalName() const
Definition: dictionary.cpp:349
pFlow::dictionary::add
bool add(const word &keyword, const float &v)
Definition: dictionary.cpp:422
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:320
pFlow::rotatingAxis::write
FUNCTION_H bool write(dictionary &dict) const
Write to dictionary.
Definition: rotatingAxis.cpp:84
pFlow::rotatingAxis::rotating_
bool rotating_
is rotating
Definition: rotatingAxis.hpp:73
pFlow::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.cpp:42
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
pFlow::line::read
FUNCTION_H bool read(const dictionary &dict)
Definition: line.cpp:50
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::rotatingAxis::omega_
real omega_
rotation speed
Definition: rotatingAxis.hpp:70
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
dictionary.hpp
pFlow::rotatingAxis::omega
INLINE_FUNCTION_HD real omega() const
Return omega.
Definition: rotatingAxis.hpp:104
pFlow::timeInterval
Definition: timeInterval.hpp:16
FUNCTION_HD
#define FUNCTION_HD
Definition: pFlowMacros.hpp:57
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:68
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Definition: error.hpp:49
pFlow::IOstream::lineNumber
int32 lineNumber() const
Const access to the current stream line number.
Definition: IOstream.hpp:221
pFlow::triple< real >
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::equal
INLINE_FUNCTION_HD bool equal(const real &s1, const real &s2)
Definition: bTypesFunctions.hpp:188
pFlow::iOstream::writeWordEntry
iOstream & writeWordEntry(const word &key, const T &value)
Write a keyword/value entry.
Definition: iOstream.hpp:224
pFlow::rotatingAxis::rotatingAxis
FUNCTION_HD rotatingAxis()
Empty constructor.
Definition: rotatingAxis.hpp:81
pFlow::dictionary
Definition: dictionary.hpp:38