iBox.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 
22 template<typename intType>
25 :
26  min_(0),
27  max_(1)
28 {}
29 
30 
31 template<typename intType>
34  const triple<intType>& minP,
35  const triple<intType>& maxP)
36 :
37  min_(minP),
38  max_(maxP)
39 {}
40 
41 template<typename intType>
44 (
45  const dictionary & dict
46 )
47 :
48  min_
49  (
50  dict.getVal<triple<intType>>("min")
51  ),
52  max_
53  (
54  dict.getVal<triple<intType>>("max")
55  )
56 {}
57 
58 template<typename intType>
61 (
62  iIstream& is
63 )
64 {
65  if( !read(is))
66  {
67  ioErrorInFile(is.name(), is.lineNumber())<<
68  "error in reading iBox from file. \n";
69  fatalExit;
70  }
71 }
72 
73 template<typename intType>
76 (
77  const triple<intType>& point
78 )const
79 {
80  return point >= min_ && point <= max_;
81 }
82 
83 template<typename intType>
86 {
87  if(!is.nextData<triple<intType>>("min", min_)) return false;
88  if(!is.nextData<triple<intType>>("max", max_)) return false;
89  return true;
90 }
91 
92 template<typename intType>
95 {
96  os.writeWordEntry("min", min_);
97  os.writeWordEntry("max", max_);
98  return os.check(FUNCTION_NAME);
99 }
100 
101 template<typename intType>
104 (
105  const dictionary& dict
106 )
107 {
108  min_ = dict.getVal<triple<intType>>("min");
109  max_ = dict.getVal<triple<intType>>("max");
110  return true;
111 }
112 
113 template<typename intType>
116 (
117  dictionary& dict
118 )const
119 {
120  if(!dict.add("min", min_))
121  {
123  " error in writing min to dictionary "<<dict.globalName()<<endl;
124  return false;
125  }
126 
127  if(!dict.add("max", max_))
128  {
130  " error in writing max to dictionary "<<dict.globalName()<<endl;
131  return false;
132  }
133 
134  return true;
135 }
136 
137 template<typename intType>
140 {
141  if(! b.read(is))
142  {
143  ioErrorInFile(is.name(), is.lineNumber())<<
144  "error in reading iBox. \n";
145  fatalExit;
146  }
147  return is;
148 }
149 
150 template<typename intType>
152 pFlow::iOstream& pFlow::operator << (iOstream& os, const iBox<intType>& b)
153 {
154 
155  if(! b.write(os))
156  {
157  ioErrorInFile(os.name(), os.lineNumber())<<
158  "error in writing iBox. \n";
159  fatalExit;
160  }
161  return os;
162 }
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::iBox::isInside
INLINE_FUNCTION_HD bool isInside(const triple< intType > &point) const
Definition: iBox.cpp:76
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
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::iBox::iBox
INLINE_FUNCTION_HD iBox()
Definition: iBox.cpp:24
pFlow::IOstream::check
virtual bool check(const char *operation) const
Definition: IOstream.cpp:42
FUNCTION_H
#define FUNCTION_H
Definition: pFlowMacros.hpp:58
pFlow::iIstream
Definition: iIstream.hpp:33
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
pFlow::iIstream::nextData
bool nextData(const word &keyword, T &data)
Definition: iIstreamI.hpp:81
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::iBox::write
FUNCTION_H bool write(iOstream &os) const
Definition: iBox.cpp:94
pFlow::operator<<
INLINE_FUNCTION iOstream & operator<<(iOstream &str, const AB3History &ab3)
Definition: AdamsBashforth3.hpp:57
pFlow::IOstream::name
virtual const word & name() const
Definition: IOstream.cpp:31
pFlow::dictionary::getVal
T getVal(const word &keyword) const
Definition: dictionary.hpp:309
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Definition: error.hpp:49
pFlow::IOstream::lineNumber
int32 lineNumber() const
Definition: IOstream.hpp:187
pFlow::iBox
Definition: iBox.hpp:33
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::triple< intType >
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::iOstream::writeWordEntry
iOstream & writeWordEntry(const word &key, const T &value)
Definition: iOstream.hpp:217
pFlow::dictionary
Definition: dictionary.hpp:38
pFlow::iBox::read
FUNCTION_H bool read(iIstream &is)
Definition: iBox.cpp:85