2024-01-25 11:07:59 +00:00
|
|
|
#include "shape.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
bool pFlow::shape::findPropertyIds()
|
|
|
|
{
|
|
|
|
shapePropertyIds_.resize(numShapes());
|
|
|
|
|
|
|
|
ForAll( i, materialNames_)
|
|
|
|
{
|
|
|
|
if(uint32 propId; property_.nameToIndex(materialNames_[i], propId) )
|
|
|
|
{
|
2024-01-26 09:10:10 +00:00
|
|
|
shapePropertyIds_[i] = propId;
|
2024-01-25 11:07:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fatalErrorInFunction<<"Material name "<< materialNames_[i]<<
|
2024-01-26 09:10:10 +00:00
|
|
|
" is not valid in dictionary "<<globalName()<<endl;
|
2024-01-25 11:07:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2024-01-26 09:10:10 +00:00
|
|
|
return true;
|
2024-01-25 11:07:59 +00:00
|
|
|
}
|
|
|
|
|
2024-01-26 09:10:10 +00:00
|
|
|
bool pFlow::shape::readFromDictionary2()
|
2024-01-25 11:07:59 +00:00
|
|
|
{
|
2024-01-26 09:10:10 +00:00
|
|
|
|
2024-01-25 11:07:59 +00:00
|
|
|
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)
|
|
|
|
{
|
|
|
|
|
2024-01-26 09:10:10 +00:00
|
|
|
if( !readFromDictionary2() )
|
2024-01-25 11:07:59 +00:00
|
|
|
{
|
2024-01-26 09:10:10 +00:00
|
|
|
fatalErrorInFunction;
|
2024-01-25 11:07:59 +00:00
|
|
|
fatalExit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!findPropertyIds())
|
|
|
|
{
|
2024-01-26 09:10:10 +00:00
|
|
|
fatalErrorInFunction;
|
2024-01-25 11:07:59 +00:00
|
|
|
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;
|
|
|
|
}
|