# PhasicFlow: src/phasicFlow/structuredData/line/line.cpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

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
Fatal exit.
Definition: error.hpp:98
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::line::write
FUNCTION_H bool write(dictionary &ditc) const
Definition: line.cpp:61
pFlow::iIstream::readEndStatement
char readEndStatement(const char *funcName)
End statement character ;.
Definition: iIstream.cpp:359
FUNCTION_NAME
#define FUNCTION_NAME
Definition: pFlowMacros.hpp:29
pFlow::dictionary::globalName
virtual word globalName() const
global name of entry, separated with dots
Definition: dictionary.cpp:356
pFlow::dictionary::add
bool add(const word &keyword, const float &v)
add a float dataEntry
Definition: dictionary.cpp:435
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::line::line
FUNCTION_HD line()
Definition: line.hpp:52
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:62
pFlow::line::read
FUNCTION_H bool read(const dictionary &dict)
Definition: line.cpp:50
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::line::point2
INLINE_FUNCTION_HD realx3 point2() const
Definition: line.hpp:98
dictionary.hpp
FUNCTION_HD
#define FUNCTION_HD
Definition: pFlowMacros.hpp:61
pFlow::IOstream::name
virtual const word & name() const
Return the name of the stream.
Definition: IOstream.cpp:31
pFlow::dictionary::getVal
T getVal(const word &keyword) const
get the value of data entry
Definition: dictionary.hpp:379
pFlow::line::point1
INLINE_FUNCTION_HD realx3 point1() const
Definition: line.hpp:94
ioErrorInFile
#define ioErrorInFile(fileName, lineNumber)
Report an error in file operation with supplied fileName and lineNumber.
Definition: error.hpp:87
pFlow::IOstream::lineNumber
int32 lineNumber() const
Const access to the current stream line number.
Definition: IOstream.hpp:223
pFlow::triple< real >
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::iOstream::writeWordEntry
iOstream & writeWordEntry(const word &key, const T &value)
Write a keyword/value entry.
Definition: iOstream.hpp:239
line.hpp
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67