41 DEBUG(
"GeometryIONetcdf::makeProperty found integer property :", MAIA_DEBUG_USER1);
42 p->propertyType =
MINT;
45 p->intField =
new MInt[1];
47 DEBUG(
"GeometryIONetcdf::makeProperty " << p->intField[0], MAIA_DEBUG_USER1);
53 p->intField =
new MInt[length];
65 DEBUG(
"GeometryIONetcdf::makeProperty found float property :", MAIA_DEBUG_USER1);
69 p->floatField =
new MFloat[1];
71 DEBUG(
"GeometryIONetcdf::makeProperty " << p->floatField[0], MAIA_DEBUG_USER1);
77 p->floatField =
new MFloat[length];
89 DEBUG(
"GeometryIONetcdf::makeProperty found char property :", MAIA_DEBUG_USER1);
93 p->stringField =
new MString[1];
96 p->stringField->append(buf);
100 p->stringField =
new MString[1];
106 p->stringField->append(buf);
107 DEBUG(
"GeometryIONetcdf::makeProperty " << p->stringField[0], MAIA_DEBUG_USER1);
113 p->elements = length;
114 p->stringField =
new MString[noStrings];
117 for(
MInt i = 0; i < p->elements; i++) {
122 (p->stringField[i]).append(buf);
123 DEBUG(
"GeometryIONetcdf::makeProperty " << p->stringField[i], MAIA_DEBUG_USER1);
133 const pair<const MString, GeometryProperty*> mp(p->name, p);
135 DEBUG(
"GeometryIONetcdf::makeProperty created default property ", MAIA_DEBUG_USER1);
136 DEBUG(
"GeometryIONetcdf::makeProperty elements = " << p->elements, MAIA_DEBUG_USER1);
137 DEBUG(
"GeometryIONetcdf::makeProperty m_noProperties = " <<
m_geometryPropertyMap->size(), MAIA_DEBUG_USER1);
143 m_log <<
" * reading body information" << endl;
146 && bdFile->
hasDataset(
"body_segments_num.")) {
160 bdFile->
readArray(&bsallnames,
"body_segments_names.");
164 for(
MInt i = 0; i < len_bsnum; i++) {
165 MInt del_pos = bsallnames.find(
",");
166 bsname[i] = bsallnames.substr(0, del_pos);
167 MString tmp = bsallnames.substr(del_pos + 1, bsallnames.length() - del_pos);
171 for(
MInt i = 0, j = 0; i < len_bsnum; i++) {
175 body->
name = bsname[i];
197 m_log <<
" * reading body information" << endl;
198 MInt noVariables = 0;
199 const char MPropertySeperator =
'.';
208 noVariables = varNames.size();
210 for(
MInt n = 0; n < noVariables; n++) {
211 varName = varNames[n];
212 if(strstr(varName.c_str(),
"body_segments.")) {
213 du = strrchr(varName.c_str(), MPropertySeperator);
218 body->
name.append(++du);
219 DEBUG(
"GeometryIONetcdf::readBodies Body found (name: " << body->
name <<
")", MAIA_DEBUG_USER2);
224 DEBUG(
"GeometryIONetcdf::readBodies The Body has " << length <<
" solvers.", MAIA_DEBUG_USER2);
255 body->
name.append(
"default");
258 list<MInt> segmentList;
260 for(
MInt i = 0; i < it->second->noSegments; i++) {
261 segmentList.push_back(it->second->segments[i]);
273 MInt simpleIterator = 0;
274 list<MInt>::const_iterator segmentIt = segmentList.begin();
276 if(!segmentList.empty()) {
278 if(*segmentIt == i) {
283 DEBUG(
"GeometryIONetcdf::buildDefaultBody Added segment " << i <<
" to the default body. ", MAIA_DEBUG_USER1);
292 DEBUG(
"GeometryIONetcdf::buildDefaultBody Default body has " << body->
noSegments <<
" segments.", MAIA_DEBUG_USER1);
334 m_log <<
" - rank 0 reads data from disk" << endl;
342 NEW_SUB_TIMER(t_distRest,
"distribute rest geometry property",
g_t_readGeomFile);
345 RECORD_TIMER_START(t_readBodies);
347 RECORD_TIMER_STOP(t_readBodies);
349 RECORD_TIMER_START(t_readRest);
351 RECORD_TIMER_STOP(t_readRest);
353 RECORD_TIMER_START(t_readBodies);
355 RECORD_TIMER_STOP(t_readBodies);
357 RECORD_TIMER_START(t_readRest);
359 RECORD_TIMER_STOP(t_readRest);
391 RECORD_TIMER_START(t_distBodies);
393 RECORD_TIMER_STOP(t_distBodies);
395 RECORD_TIMER_START(t_distRest);
397 RECORD_TIMER_STOP(t_distRest);
456 MInt noVariables = 0;
457 const char MPropertySeperator =
'.';
462 m_log <<
" * reading rest of the properties" << endl;
467 noVariables = varNames.size();
469 for(
MInt id = 0;
id < noVariables;
id++) {
470 varName = varNames[
id];
472 if(!strstr(varName.c_str(),
".")) {
477 DEBUG(
"GeometryIONetcdf::readNCPropertyFile default property : " << varName, MAIA_DEBUG_USER1);
480 p->name.append(varName);
485 if(strstr(varName.c_str(),
"_bodies.")) {
486 DEBUG(
"GeometryIONetcdf::readPropertyFile normal property: " << varName, MAIA_DEBUG_USER1);
491 DEBUG(
"GeometryIONetcdf::readPropertyFile no of dimensions = " << noDims, MAIA_DEBUG_USER1);
513 noBodies = (
MInt)dbodies;
514 bodies =
new MString[noBodies];
517 for(
MInt i = 0; i < noBodies; i++) {
522 (bodies[i]).append(buf);
523 DEBUG(
"GeometryIONetcdf::readPropertyFile " << bodies[i], MAIA_DEBUG_USER1);
532 list<MInt> segmentList;
533 for(
MInt i = 0; i != noBodies; i++) {
534 DEBUG(
"GeometryIONetcdf::readPropertyFile definition for body " << bodies[i], MAIA_DEBUG_USER1);
539 for(
MInt j = 0; j < zI->second->noSegments; j++)
540 segmentList.push_back(zI->second->segments[j]);
544 du = strrchr(
const_cast<MChar*
>(varName.c_str()), MPropertySeperator);
547 dummy.replace(dummy.find(
"_bodies."), dummy.size(), du);
548 DEBUG(
"GeometryIONetcdf::readPropertyFile found property : " << dummy, MAIA_DEBUG_USER1);
551 list<MInt>::const_iterator it = segmentList.begin();
552 dummy.erase(dummy.find(
"."));
554 for(; it != segmentList.end(); it++) {
557 p->name.append(dummy);
559 DEBUG(
"GeometryIONetcdf::readPropertyFile created property for solver " << *it, MAIA_DEBUG_USER1);
565 du = strrchr(
const_cast<MChar*
>(varName.c_str()), MPropertySeperator) + 1;
566 MInt singleSegmentId = atoi(du);
570 if(singleSegmentId || *du ==
'0') {
571 DEBUG(
"Found single segment property definition for segment " << singleSegmentId, MAIA_DEBUG_IO);
573 p->segmentId = singleSegmentId;
577 dummyName.erase(dummyName.find(
"."));
578 p->name.append(dummyName);
586 DEBUG(
"GeometryIONetcdf::readPropertyFile ** Property check successful \n", MAIA_DEBUG_USER1);
605 m_log <<
" * reading rest of the properties" << endl;
609 MInt noVariables = varNames.size();
611 for(
MInt id = 0;
id < noVariables;
id++) {
614 if(!strstr(varName.c_str(),
".")) {
617 p->name.append(varName);
620 if(strstr(varName.c_str(),
"BC.")) {
625 p_def->
name.append(
"BC");
630 const pair<const MString, GeometryProperty*> mp_def(p_def->
name, p_def);
640 for(
MInt i = 0; i < len; i++) {
642 p->propertyType =
MINT;
644 p->name.append(
"BC");
646 p->intField =
new MInt[1];
647 p->intField[0] = bcs[i];
649 const pair<const MString, GeometryProperty*> mp(p->name, p);
652 }
else if(strstr(varName.c_str(),
"filename.")) {
657 p_def->
name.append(
"filename");
662 const pair<const MString, GeometryProperty*> mp_def(p_def->
name, p_def);
668 parallelIo->
readArray(&allnames,
"filename.");
670 MInt num = count(allnames.begin(), allnames.end(),
',') + 1;
672 for(
MInt i = 0; i < num; i++) {
673 MInt del_pos = allnames.find(
",");
674 name[i] = allnames.substr(0, del_pos);
675 MString tmp = allnames.substr(del_pos + 1, allnames.length() - del_pos);
680 for(
MInt i = 0; i < num; i++) {
684 p->name.append(
"filename");
686 p->stringField =
new MString[1];
687 p->stringField[0] = name[i];
689 const pair<const MString, GeometryProperty*> mp(p->name, p);
715 m_log <<
" - rank 0 distributes the geometry property information" << endl;
725 MInt name_length = prop->
name.length();
727 strcpy(c_name.
begin(), prop->
name.c_str());
759 char* buf =
new char[fld_len];
799 for(
MInt p = 0; p < propsize; p++) {
803 MInt name_length = 0;
805 char* name =
new char[name_length + 1];
806 name[name_length] =
'\0';
837 char* buf =
new char[fld_len];
841 MInt charsize = off[i + 1] - off[i];
842 char* tmp =
new char[charsize + 1];
843 strncpy(tmp, &buf[off[i]], charsize);
844 tmp[charsize] =
'\0';
857 const pair<const MString, GeometryProperty*> mp(prop->
name, prop);
878 m_log <<
" - rank 0 distributes the body information" << endl;
886 Body* body = (*it).second;
889 MInt name_length = body->
name.length();
891 strcpy(c_name.
begin(), body->
name.c_str());
924 for(
MInt p = 0; p < bosize; p++) {
929 MInt name_length = 0;
931 char* name =
new char[name_length + 1];
932 name[name_length] =
'\0';
960 DEBUG(
"GeometryIONetcdf::checkPropertyConsistency default property exists for :" << i->second->name,
978 list<MInt> segmentList;
979 list<MInt> compareList;
982 for(
MInt i = 0; i < it->second->noSegments; i++) {
985 segmentList.push_back(it->second->segments[i]);
986 compareList.push_back(index++);
990 if(segmentList == compareList) {
1014 TERMM(1,
"untested I/O method, please see comment for how to proceed");
1022 for(geometryPropertyMap::iterator i = pMap->begin(); i != pMap->end(); i++) {
1024 dimName.append(
"Dim");
1025 switch(i->second->type()) {
1038 totalCount[0] = i->second->count();
1039 totalCount[1] = NC_MAX_NAME;
1045 mTerm(1, AT_,
"Uknown property type");
1055 for(geometryPropertyMap::iterator i = pMap->begin(); i != pMap->end(); i++) {
1056 switch(i->second->type()) {
1058 parallelIo.
setOffset(i->second->count(), 0);
1059 parallelIo.
writeArray(i->second->intField, i->first);
1064 parallelIo.
setOffset(i->second->count(), 0);
1065 parallelIo.
writeArray(i->second->floatField, i->first);
1070 parallelIo.
setOffset(i->second->count(), 0, 2);
1071 parallelIo.
writeArray(i->second->asString(), i->first);
1076 mTerm(1, AT_,
"Unknown property type");
void distributeBodyProperties()
distributes the body information under all processes
void receiveBodyProperties()
receives the body information from rank 0
void readBodiesNewIOMethod(ParallelIo *)
geometryAssembly * m_geometryAssembly
void readPropertyFileNewIOMethod(ParallelIo *parallelIo)
reads in the geomertry property file the old way
MBool checkGeometryPropertyConsistency()
void receiveGeometryProperties()
receives the geometry properties from rank 0
geometryPropertyMap * m_geometryPropertyMap
void writeProperties(const MChar *fileName, geometryPropertyMap *pMap)
Write the properties into a netcdf file.
MBool checkBodyConsistency()
void readBodiesOldIOMethod(ParallelIo *)
geometryAssembly * readPropertyFile(MString fileName)
check if the geometry property file is of new or old type and calls the according function
void readPropertyFileOldIOMethod(ParallelIo *parallelIo)
reads in the geomertry property file the old way
void distributeGeometryProperties()
distributes the read geometry properties under all processes
void makeProperty(GeometryProperty *, MString, ParallelIo *)
VariableType propertyType
MInt getDatasetType(const MString &name)
Returns the data type of an array.
void readScalar(T *scalar, const MString &name)
Read scalar data from file. [MPI]
void setOffset(const size_type localCount, const size_type offset, const size_type noDims, const size_type noChunks)
Set the local and global counts, as well the local offset for array operations.
void defineArray(maiabd_type type, const MString &name, size_type totalCount)
Create a new array in the file.
void writeArray(const T *array, const MString &name, size_type memoryStride=-1, size_type diskStride=-1)
Write array data to file. [MPI]
MBool hasDataset(const MString &name, MInt dimension)
Check if the file contains an dataset with the given name and dimension.
std::vector< MString > getDatasetNames(const size_type dimensions=-1)
Returns a vector with the names of all existing datasets with given dimensionality in the file.
MBool hasAttribute(const MString &name, const MString &path="")
Check if a given attribute exists in the file.
MLong size_type
Type used for all size- and offset-related values.
size_type getArraySize(const MString &name, const size_type dimensionId=0)
Get the length of an array in the file.
size_type getDatasetNoDims(const MString &name)
Get the number of dimensions of a dataset with given name.
void readArray(T *array, const MString &name, size_type memoryStride=-1, size_type diskStride=-1)
Read array data from file. [MPI]
This class is a ScratchSpace.
T * getPointer() const
Deprecated: use begin() instead!
void mTerm(const MInt errorCode, const MString &location, const MString &message)
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
geometryPropertyMap * geometryProperties