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

line.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.
-----------------------------------------------------------------------------*/
#include "line.hpp"
#include "dictionary.hpp"
FUNCTION_HD
pFlow::line::line
(
const realx3 &lp1,
const realx3 &lp2
)
{
set(lp1, lp2);
}
FUNCTION_H
pFlow::line::line
(
const dictionary& dict
)
{
if(!read(dict))
{
fatalExit;
}
}
FUNCTION_H
bool pFlow::line::read
(
const dictionary& dict
)
{
realx3 p1 = dict.getVal<realx3>("p1");
realx3 p2 = dict.getVal<realx3>("p2");
set(p1, p2);
return true;
}
FUNCTION_H
bool pFlow::line::write(dictionary& dict) const
{
if(!dict.add("p1", point1()))
{
fatalErrorInFunction <<
" error in writing p1 to dictionary " << dict.globalName()<<endl;
return false;
}
if(!dict.add("p2", point2()))
{
fatalErrorInFunction <<
" error in writing p2 to dictionary " << dict.globalName()<<endl;
return false;
}
return true;
}
FUNCTION_H
bool pFlow::line::read
(
iIstream& is
)
{
word p1w;
realx3 p1;
is >> p1w >> p1;
if( !is.check(FUNCTION_NAME))
{
ioErrorInFile(is.name(), is.lineNumber());
return false;
}
if(p1w != "p1")
{
ioErrorInFile(is.name(), is.lineNumber())<<
" expected p1 but found "<< p1w<<endl;
return false;
}
is.readEndStatement(FUNCTION_NAME);
word p2w;
realx3 p2;
is >> p2w >> p2;
if( !is.check(FUNCTION_NAME))
{
ioErrorInFile(is.name(), is.lineNumber());
return false;
}
if(p2w != "p2")
{
ioErrorInFile(is.name(), is.lineNumber())<<
" expected p2 but found "<< p2w<<endl;
return false;
}
is.readEndStatement(FUNCTION_NAME);
set(p1,p2);
return true;
}
FUNCTION_H
bool pFlow::line::write
(
iOstream& os
)const
{
os.writeWordEntry("p1", point1());
os.writeWordEntry("p2", point2());
return os.check(FUNCTION_NAME);
}
fatalExit
#define fatalExit
Definition: error.hpp:57
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:324
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::line::line
FUNCTION_HD line()
Definition: line.hpp:52
pFlow::IOstream::check
virtual bool check(const char *operation) const
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
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
pFlow::line::point2
INLINE_FUNCTION_HD realx3 point2() const
Definition: line.hpp:90
dictionary.hpp
FUNCTION_HD
#define FUNCTION_HD
Definition: pFlowMacros.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::line::point1
INLINE_FUNCTION_HD realx3 point1() const
Definition: line.hpp:86
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
line.hpp
pFlow::dictionary
Definition: dictionary.hpp:38