box.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 #include "box.hpp"
23 
24 
27 (
28  const dictionary & dict
29 )
30 :
31  min_
32  (
33  dict.getVal<realx3>("min")
34  ),
35  max_
36  (
37  dict.getVal<realx3>("max")
38  )
39 {}
40 
43 (
44  iIstream& is
45 )
46 {
47  if( !read(is))
48  {
49  ioErrorInFile(is.name(), is.lineNumber())<<
50  "error in reading box from file. \n";
51  fatalExit;
52  }
53 }
54 
55 
58 {
59  if(!is.nextData<realx3>("min", min_)) return false;
60  if(!is.nextData<realx3>("max", max_)) return false;
61  return true;
62 }
63 
66 {
67  os.writeWordEntry("min", min_);
68  os.writeWordEntry("max", max_);
69  return os.check(FUNCTION_NAME);
70 }
71 
74 (
75  const dictionary& dict
76 )
77 {
78  min_ = dict.getVal<realx3>("min");
79  max_ = dict.getVal<realx3>("max");
80  return true;
81 }
82 
85 (
86  dictionary& dict
87 )const
88 {
89  if(!dict.add("min", min_))
90  {
92  " error in writing min to dictionary "<<dict.globalName()<<endl;
93  return false;
94  }
95 
96  if(!dict.add("max", max_))
97  {
99  " error in writing max to dictionary "<<dict.globalName()<<endl;
100  return false;
101  }
102 
103  return true;
104 }
105 
108 {
109  if(! b.read(is))
110  {
111  ioErrorInFile(is.name(), is.lineNumber())<<
112  "error in reading box. \n";
113  fatalExit;
114  }
115  return is;
116 }
117 
120 {
121 
122  if(! b.write(os))
123  {
124  ioErrorInFile(os.name(), os.lineNumber())<<
125  "error in writing box. \n";
126  fatalExit;
127  }
128  return os;
129 }
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::box::box
INLINE_FUNCTION_HD box()
Definition: box.hpp:49
pFlow::box::max_
realx3 max_
Definition: box.hpp:40
box.hpp
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::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::box::write
FUNCTION_H bool write(iOstream &os) const
Definition: box.cpp:65
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
pFlow::box
Definition: box.hpp:32
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Definition: error.hpp:49
pFlow::IOstream::lineNumber
int32 lineNumber() const
Definition: IOstream.hpp:187
pFlow::triple< real >
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::iOstream::writeWordEntry
iOstream & writeWordEntry(const word &key, const T &value)
Definition: iOstream.hpp:217
pFlow::box::read
FUNCTION_H bool read(iIstream &is)
Definition: box.cpp:57
pFlow::box::min_
realx3 min_
Definition: box.hpp:37
pFlow::dictionary
Definition: dictionary.hpp:38