28 DEBUG(
"GeometryIOToml::makeProperty found integer property :", MAIA_DEBUG_USER1);
29 p->propertyType =
MINT;
30 p->elements = prop.
size();
32 copy(prop.
asInt().begin(), prop.
asInt().end(), p->intField);
37 DEBUG(
"GeometryIOToml::makeProperty found float property :", MAIA_DEBUG_USER1);
39 p->elements = prop.
size();
46 DEBUG(
"GeometryIOToml::makeProperty found char property :", MAIA_DEBUG_USER1);
48 p->elements = prop.
size();
54 stringstream errorMessage;
55 errorMessage <<
"GeometryIOToml::makeProperty Error: Unsupported variable input type encountered!" << endl;
56 TERMM(1, errorMessage.str());
61 const pair<const MString, GeometryProperty*> mp(p->name, p);
64 DEBUG(
"GeometryIOToml::makeProperty created default property ", MAIA_DEBUG_USER1);
65 DEBUG(
"GeometryIOToml::makeProperty elements = " << p->elements, MAIA_DEBUG_USER1);
66 DEBUG(
"GeometryIOToml::makeProperty m_noProperties = " <<
m_geometryPropertyMap->size(), MAIA_DEBUG_USER1);
72 m_log <<
" * reading body information" << endl;
74 Property bodySegments, bodySegmentsNames, bodySegmentsNum;
75 for(
auto&& prop : properties) {
76 if(prop.name() ==
"body_segments") {
78 }
else if(prop.name() ==
"body_segments_names") {
79 bodySegmentsNames = prop;
80 }
else if(prop.name() ==
"body_segments_num") {
81 bodySegmentsNum = prop;
85 if(bodySegments.
valid() && bodySegmentsNames.
valid() && bodySegmentsNum.
valid()) {
86 MInt len_bsnum = bodySegmentsNum.
size();
94 copy(bodySegments.
asInt().begin(), bodySegments.
asInt().end(), bs.
data());
95 bsallnames = bodySegmentsNames.
asString()[0];
96 copy(bodySegmentsNum.
asInt().begin(), bodySegmentsNum.
asInt().end(), bsnum.
data());
98 for(
MInt i = 0; i < len_bsnum; i++) {
99 MInt del_pos = bsallnames.find(
",");
100 bsname[i] = bsallnames.substr(0, del_pos);
101 MString tmp = bsallnames.substr(del_pos + 1, bsallnames.length() - del_pos);
105 for(
MInt i = 0, j = 0; i < len_bsnum; i++) {
109 body->
name = bsname[i];
127 m_log <<
" * reading body information" << endl;
130 for(
auto&& prop : properties) {
132 if(!strstr(prop.name().c_str(),
"body_segments.")) {
136 const auto pname = prop.name();
137 const char* du = strrchr(pname.c_str(),
'.');
142 body->
name.append(++du);
143 DEBUG(
"GeometryIOToml::readBodies Body found (name: " << body->
name <<
")", MAIA_DEBUG_USER2);
147 MInt length = prop.size();
148 DEBUG(
"GeometryIOToml::readBodies The Body has " << length <<
" solvers.", MAIA_DEBUG_USER2);
151 copy(prop.asInt().begin(), prop.asInt().end(), body->
segments);
171 body->
name.append(
"default");
174 list<MInt> segmentList;
176 for(
MInt i = 0; i < it->second->noSegments; i++) {
177 segmentList.push_back(it->second->segments[i]);
189 MInt simpleIterator = 0;
190 list<MInt>::const_iterator segmentIt = segmentList.begin();
192 if(!segmentList.empty()) {
194 if(*segmentIt == i) {
199 DEBUG(
"GeometryIOToml::buildDefaultBody Added segment " << i <<
" to the default body. ", MAIA_DEBUG_USER1);
208 DEBUG(
"GeometryIOToml::buildDefaultBody Default body has " << body->
noSegments <<
" segments.", MAIA_DEBUG_USER1);
238 m_log <<
" - rank 0 reads data from disk" << endl;
241 ifstream ifs(fileName);
243 TERMM(1,
"could not open geometry file '" + fileName +
"'");
248 TERMM(1,
"geometry file '" + fileName +
"' appears to be empty");
252 MInt length = ss.str().size() + 1;
255 vector<MChar> text(length);
256 strcpy(text.data(), ss.str().c_str());
270 vector<MChar> text(length);
280 vector<maia::io::toml::Property> properties;
286 for(
auto&& prop : properties) {
287 if(prop.name() ==
"newIOMethod") {
292 if(prop.name() ==
"noSegments") {
303 RECORD_TIMER_START(t_readBodies);
305 RECORD_TIMER_STOP(t_readBodies);
307 RECORD_TIMER_START(t_readRest);
309 RECORD_TIMER_STOP(t_readRest);
311 RECORD_TIMER_START(t_readBodies);
313 RECORD_TIMER_STOP(t_readBodies);
315 RECORD_TIMER_START(t_readRest);
317 RECORD_TIMER_STOP(t_readRest);
343 m_log <<
" * reading rest of the properties" << endl;
347 TERMM(1,
"Body consistency check failed");
350 for(
auto&& prop : properties) {
352 const MString varName = prop.name();
355 if(!strstr(varName.c_str(),
".")) {
360 DEBUG(
"GeometryIOToml::readPropertyFile default property : " << varName, MAIA_DEBUG_USER1);
363 p->name.append(varName);
368 if(strstr(varName.c_str(),
"_bodies.")) {
369 DEBUG(
"GeometryIOToml::readPropertyFile normal property: " << varName, MAIA_DEBUG_USER1);
370 MInt noBodies = prop.size();
372 copy(prop.asString().begin(), prop.asString().end(), bodies);
375 list<MInt> segmentList;
376 for(
MInt i = 0; i != noBodies; i++) {
377 DEBUG(
"GeometryIOToml::readPropertyFile definition for body " << bodies[i], MAIA_DEBUG_USER1);
382 for(
MInt j = 0; j < zI->second->noSegments; j++)
383 segmentList.push_back(zI->second->segments[j]);
387 du = strrchr(
const_cast<MChar*
>(varName.c_str()),
'.');
390 dummy.replace(dummy.find(
"_bodies."), dummy.size(), du);
391 DEBUG(
"GeometryIOToml::readPropertyFile found property : " << dummy, MAIA_DEBUG_USER1);
394 list<MInt>::const_iterator it = segmentList.begin();
395 dummy.erase(dummy.find(
"."));
397 for(; it != segmentList.end(); it++) {
400 p->name.append(dummy);
402 DEBUG(
"GeometryIOToml::readPropertyFile created property for solver " << *it, MAIA_DEBUG_USER1);
408 du = strrchr(
const_cast<MChar*
>(varName.c_str()),
'.') + 1;
409 MInt singleSegmentId = atoi(du);
413 if(singleSegmentId || *du ==
'0') {
414 DEBUG(
"Found single segment property definition for segment " << singleSegmentId, MAIA_DEBUG_IO);
416 p->segmentId = singleSegmentId;
420 dummyName.erase(dummyName.find(
"."));
421 p->name.append(dummyName);
429 DEBUG(
"GeometryIOToml::readPropertyFile ** Property check successful \n", MAIA_DEBUG_USER1);
448 m_log <<
" * reading rest of the properties" << endl;
452 TERMM(1,
"Body consistency check failed");
455 for(
auto&& prop : properties) {
457 const MString varName = prop.name();
459 if(!strstr(varName.c_str(),
".")) {
462 p->name.append(varName);
465 if(strstr(varName.c_str(),
"BC.")) {
470 p_def->
name.append(
"BC");
475 const pair<const MString, GeometryProperty*> mp_def(p_def->
name, p_def);
479 MInt len = prop.size();
481 copy(prop.asInt().begin(), prop.asInt().end(), bcs.
data());
484 for(
MInt i = 0; i < len; i++) {
486 p->propertyType =
MINT;
488 p->name.append(
"BC");
490 p->intField =
new MInt[1];
491 p->intField[0] = bcs[i];
493 const pair<const MString, GeometryProperty*> mp(p->name, p);
496 }
else if(strstr(varName.c_str(),
"filename.")) {
501 p_def->
name.append(
"filename");
506 const pair<const MString, GeometryProperty*> mp_def(p_def->
name, p_def);
509 MString allnames = prop.asString()[0];
511 MInt num = count(allnames.begin(), allnames.end(),
',') + 1;
513 for(
MInt i = 0; i < num; i++) {
514 MInt del_pos = allnames.find(
",");
515 name[i] = allnames.substr(0, del_pos);
516 MString tmp = allnames.substr(del_pos + 1, allnames.length() - del_pos);
521 for(
MInt i = 0; i < num; i++) {
525 p->name.append(
"filename");
527 p->stringField =
new MString[1];
528 p->stringField[0] = name[i];
530 const pair<const MString, GeometryProperty*> mp(p->name, p);
546 DEBUG(
"GeometryIOToml::checkPropertyConsistency default property exists for :" << i->second->name,
565 list<MInt> segmentList;
566 list<MInt> compareList;
569 for(
MInt i = 0; i < it->second->noSegments; i++) {
572 segmentList.push_back(it->second->segments[i]);
573 compareList.push_back(index++);
577 if(segmentList == compareList) {
void readPropertyFileOldIOMethod(const std::vector< maia::io::toml::Property > &properties)
reads in the geomertry property file the old way
void readBodiesOldIOMethod(const std::vector< maia::io::toml::Property > &properties)
void readBodiesNewIOMethod(const std::vector< maia::io::toml::Property > &properties)
geometryPropertyMap * m_geometryPropertyMap
void readPropertyFileNewIOMethod(const std::vector< maia::io::toml::Property > &properties)
reads in the geomertry property file the old way
geometryAssembly * readPropertyFile(MString fileName)
check if the geometry property file is of new or old type and calls the according function
MBool checkGeometryPropertyConsistency()
geometryAssembly * m_geometryAssembly
void makeProperty(GeometryProperty *, const maia::io::toml::Property &prop)
MBool checkBodyConsistency()
VariableType propertyType
This class is a ScratchSpace.
std::shared_ptr< table > parse()
Class that represents a single key-value pair for TOML properties.
const std::vector< MInt > & asInt() const
const std::vector< MFloat > & asFloat() const
const std::vector< MString > & asString() const
VariableType type() const
struct b geometryAssembly
std::multimap< MString, GeometryProperty * > geometryPropertyMap
geometryPropertyMap::const_iterator geometryPropertyIterator
std::map< MString, Body * > bodyMap
bodyMap::const_iterator bodyIterator
struct y Body
define array structures
std::basic_string< char > MString
int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm, const MString &name, const MString &varname)
same as MPI_Bcast
void collectProperties(const std::shared_ptr< cpptoml::table > &tab, std::vector< std::string > &names, std::vector< Property > &properties, std::map< std::string, int > &solverAliases)
Recursively traverse TOML table and collect all properties with name, type, and count.
geometryPropertyMap * geometryProperties