# PhasicFlow: src/phasicFlow/structuredData/iBox/iBox.cpp Source File

iBox.cpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
template<typename intType>
INLINE_FUNCTION_HD
pFlow::iBox<intType>::iBox()
:
min_(0),
max_(1)
{}
template<typename intType>
INLINE_FUNCTION_HD
pFlow::iBox<intType>::iBox(
const triple<intType>& minP,
const triple<intType>& maxP)
:
min_(minP),
max_(maxP)
{}
template<typename intType>
FUNCTION_H
pFlow::iBox<intType>::iBox
(
const dictionary & dict
)
:
min_
(
dict.getVal<triple<intType>>("min")
),
max_
(
dict.getVal<triple<intType>>("max")
)
{}
template<typename intType>
FUNCTION_H
pFlow::iBox<intType>::iBox
(
iIstream& is
)
{
if( !read(is))
{
ioErrorInFile(is.name(), is.lineNumber())<<
"error in reading iBox from file. \n";
fatalExit;
}
}
template<typename intType>
INLINE_FUNCTION_HD
bool pFlow::iBox<intType>::isInside
(
const triple<intType>& point
)const
{
return point >= min_ && point <= max_;
}
template<typename intType>
FUNCTION_H
bool pFlow::iBox<intType>::read(iIstream & is)
{
if(!is.nextData<triple<intType>>("min", min_)) return false;
if(!is.nextData<triple<intType>>("max", max_)) return false;
return true;
}
template<typename intType>
FUNCTION_H
bool pFlow::iBox<intType>::write(iOstream& os)const
{
os.writeWordEntry("min", min_);
os.writeWordEntry("max", max_);
return os.check(FUNCTION_NAME);
}
template<typename intType>
FUNCTION_H
bool pFlow::iBox<intType>::read
(
const dictionary& dict
)
{
min_ = dict.getVal<triple<intType>>("min");
max_ = dict.getVal<triple<intType>>("max");
return true;
}
template<typename intType>
FUNCTION_H
bool pFlow::iBox<intType>::write
(
dictionary& dict
)const
{
if(!dict.add("min", min_))
{
fatalErrorInFunction<<
" error in writing min to dictionary "<<dict.globalName()<<endl;
return false;
}
if(!dict.add("max", max_))
{
fatalErrorInFunction<<
" error in writing max to dictionary "<<dict.globalName()<<endl;
return false;
}
return true;
}
template<typename intType>
FUNCTION_H
pFlow::iIstream& pFlow::operator >> (iIstream& is, iBox<intType>& b)
{
if(! b.read(is))
{
ioErrorInFile(is.name(), is.lineNumber())<<
"error in reading iBox. \n";
fatalExit;
}
return is;
}
template<typename intType>
FUNCTION_H
pFlow::iOstream& pFlow::operator << (iOstream& os, const iBox<intType>& b)
{
if(! b.write(os))
{
ioErrorInFile(os.name(), os.lineNumber())<<
"error in writing iBox. \n";
fatalExit;
}
return os;
}
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