www.cemf.ir
shape.cpp
Go to the documentation of this file.
1 #include "shape.hpp"
2 
3 
5 {
7 
9  {
10  if(uint32 propId; property_.nameToIndex(materialNames_[i], propId) )
11  {
12  shapePropertyIds_[i] = propId;
13  }
14  else
15  {
16  fatalErrorInFunction<<"Material name "<< materialNames_[i]<<
17  " is not valid in dictionary "<<globalName()<<endl;
18  return false;
19  }
20  }
21  return true;
22 }
23 
25 {
26 
27  materialNames_ = getVal<wordVector>("materials");
28 
29  if(materialNames_.size() != numShapes() )
30  {
32  " number of elements in materials and names are not the same in "<< globalName()<<endl;
33  return false;
34  }
35 
36  return true;
37 }
38 
39 
41 (
42  const word &fileName,
43  repository *owner,
44  const property &prop
45 )
46 :
47  baseShapeNames(fileName,owner),
48  property_(prop)
49 {
50 
51  if( !readFromDictionary2() )
52  {
54  fatalExit;
55  }
56 
57  if(!findPropertyIds())
58  {
60  fatalExit;
61  }
62 
63 }
64 
66 {
67  if(!baseShapeNames::writeToDict(dict))return false;
68 
69  if( !dict.add("materials", materialNames_) )
70  {
72  " Error in writing materials to dictionary "<< dict.globalName()<<endl;
73  return false;
74  }
75 
76  return true;
77 }
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