# PhasicFlow: src/Particles/particles/shape/shape.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.

shape.cpp
Go to the documentation of this file.
#include "shape.hpp"
bool pFlow::shape::findPropertyIds()
{
shapePropertyIds_.resize(numShapes());
ForAll( i, materialNames_)
{
if(uint32 propId; property_.nameToIndex(materialNames_[i], propId) )
{
shapePropertyIds_[i] = propId;
}
else
{
fatalErrorInFunction<<"Material name "<< materialNames_[i]<<
" is not valid in dictionary "<<globalName()<<endl;
return false;
}
}
return true;
}
bool pFlow::shape::readFromDictionary2()
{
materialNames_ = getVal<wordVector>("materials");
if(materialNames_.size() != numShapes() )
{
fatalErrorInFunction<<
" number of elements in materials and names are not the same in "<< globalName()<<endl;
return false;
}
return true;
}
pFlow::shape::shape
(
const word &fileName,
repository *owner,
const property &prop
)
:
baseShapeNames(fileName,owner),
property_(prop)
{
if( !readFromDictionary2() )
{
fatalErrorInFunction;
fatalExit;
}
if(!findPropertyIds())
{
fatalErrorInFunction;
fatalExit;
}
}
bool pFlow::shape::writeToDict(dictionary &dict)const
{
if(!baseShapeNames::writeToDict(dict))return false;
if( !dict.add("materials", materialNames_) )
{
fatalErrorInFunction<<
" Error in writing materials to dictionary "<< dict.globalName()<<endl;
return false;
}
return true;
}
pFlow::shape::shapePropertyIds_
uint32Vector shapePropertyIds_
list of property ids of shapes (index)
Definition: shape.hpp:40
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
shape.hpp
pFlow::baseShapeNames
Definition: baseShapeNames.hpp:33
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::dictionary::globalName
virtual word globalName() const
global name of entry, separated with dots
Definition: dictionary.cpp:356
pFlow::shape::shape
shape(const word &fileName, repository *owner, const property &prop)
Definition: shape.cpp:41
pFlow::dictionary::add
bool add(const word &keyword, const float &v)
add a float dataEntry
Definition: dictionary.cpp:435
pFlow::baseShapeNames::numShapes
size_t numShapes() const
Definition: baseShapeNames.hpp:93
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::shape::writeToDict
bool writeToDict(dictionary &dict) const override
Definition: shape.cpp:65
pFlow::shape::property_
const property & property_
property of materials
Definition: shape.hpp:37
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
ForAll
#define ForAll(i, container)
Definition: pFlowMacros.hpp:75
pFlow::property::nameToIndex
bool nameToIndex(const word &name, uint32 &idx) const
Get the name of material in index idx Return true, if the name found, otherwise false.
Definition: property.hpp:172
pFlow::shape::findPropertyIds
bool findPropertyIds()
Definition: shape.cpp:4
pFlow::property
property holds the pure properties of materials.
Definition: property.hpp:37
pFlow::shape::materialNames_
wordVector materialNames_
list of material names
Definition: shape.hpp:43
pFlow::repository
Definition: repository.hpp:34
pFlow::baseShapeNames::writeToDict
virtual bool writeToDict(dictionary &dict) const
Definition: baseShapeNames.cpp:92
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
pFlow::shape::readFromDictionary2
bool readFromDictionary2()
Definition: shape.cpp:24