MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
context.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7/* Copyright (C) Insitute of Aerodynamics, RWTH Aachen - All Rights Reserved
8 * Unauthorized copying of this file, via any medium is strictly prohibited
9 * Contact: office@aia.rwth-aachen.de
10 */
11
12#include "context.h"
13
14#include "COMM/mpioverride.h"
15#include "UTIL/binarytree.h"
16#include "globals.h"
17#include "ionetcdf.h"
18#include "iotoml.h"
19#include "typetraits.h"
20
21using namespace std;
22
23#ifdef MAIA_WRITE_ACCESS_PROPERTIES_FILE
24// Anonymous namespace to prevent accidental access from outside of this translation unit
25namespace {
26ofstream maia_properties;
27}
28#endif
29#ifdef MAIA_PRINT_PROPERTIES
30namespace {
31ofstream propsFromFile;
32ofstream propsDefault;
33} // namespace
34#endif
35/* definition of static members */
42pair<propertyMap::iterator, propertyMap::iterator> Context::m_pair;
49
50//--------------------------------------------------------------------------
55void Context::readPropertyFile(FileType fileType, const MString& fileName) {
56 TRACE();
57 m_name = fileName;
59 if(fileType == NETCDF) {
61 m_IONetcdf = new IONetcdf;
67 } else if(fileType == TOML) {
69 m_IOToml = new IOToml;
76 }
77
78
86#ifdef MAIA_WRITE_ACCESS_PROPERTIES_FILE
87 MInt logId = 0;
88
89 // avoid overwriting previous log files when running a testcase with canary
90 m_propertyFileOutputName.assign("access_properties_domain" + to_string(0) + "_0");
91 std::ifstream infile(m_propertyFileOutputName);
92 MBool fileExists = infile.good();
93 while(fileExists) {
94 // check if file for rank 0 exists (testcases with varying number of domains)
95 m_propertyFileOutputName.assign("access_properties_domain" + to_string(0) + "_" + to_string(logId));
96 std::ifstream infile2(m_propertyFileOutputName);
97 fileExists = infile2.good();
98 if(fileExists) logId++;
99 }
100
101 // use separate file for each rank
102 m_propertyFileOutputName.assign("access_properties_domain" + to_string(globalDomainId()) + "_" + to_string(logId));
103 MPI_Barrier(MPI_COMM_WORLD, AT_);
104#endif
105#ifdef MAIA_PRINT_PROPERTIES
106 cout << "WARNING: MAIA_PRINT_PROPERTIES is enabled. This can slow down the simulation extremely. Furthermore, this "
107 "should only be done for small testcases to reduce the output (every process needs to write out its "
108 "properties). If you dont want to print out the properties, disable MAIA_PRINT_PROPERTIES in config.h!!!"
109 << endl;
110 propsFromFile.open("PropertiesFromFile.dat");
111 propsDefault.open("DefaultProperties.dat");
112#endif
113}
114
115//-----------------Get Properties, New approach (Begin)--------------------//
125template <typename T, typename F>
126T Context::getBasicPropertyImplicit(const MString& nameOfCallingFunction, const MString& name, MBool has_default,
127 const T* defaultValue, MInt position, F&& f) {
128 if(propertyExists(name)) {
129 // lookup all properties with the requested key
130 m_pair = m_propertyMap->equal_range(name);
131 for(propertyIterator i = m_pair.first; i != m_pair.second; i++) {
132 if(i->second->solverId == m_noSolvers) {
133#ifdef MAIA_WRITE_ACCESS_PROPERTIES_FILE
134 if(!m_checkingProperties) { // Count number of accesses (if not during property checking)
135 i->second->noAccesses++;
136 }
137#endif
138
139 const T pValue = f(i->second, position);
140
141#ifdef MAIA_WRITE_ACCESS_PROPERTIES_FILE
142 // Check for default property values specified in the property file
143 if(has_default && !m_checkingProperties) {
144 const T dValue = *defaultValue;
145 const MBool isDefault = isSameValue(dValue, pValue);
146 if(!isDefault) {
147 // TODO labels:IO could be used to count properties with/without default values
148 /* i->second->noOldAccesses++; */
149 } else {
150 std::cerr << "Property default value specified: " << name << " solverId=" << -1 << " pos=" << position
151 << " value=" << pValue << " default=" << *defaultValue << " " << nameOfCallingFunction
152 << std::endl;
153 }
154 }
155#endif
156
157 return pValue;
158 }
159 }
160 }
161 stringstream errormessage;
162 errormessage << " The solver property '" << name << "' is required for the simulation"
163 << ", but was not set in the toml file!!!!";
164
165 if(!has_default) {
166 mTerm(1, nameOfCallingFunction, errormessage.str());
167 } else {
168 return *defaultValue;
169 }
170}
171
183MString Context::getBasicPropertyOverloaded(const MString& nameOfCallingFunction, const MString& name,
184 MBool has_default, const MString* default_value, MInt pos) {
185 MString propertyValue;
186 propertyValue = getBasicPropertyImplicit(nameOfCallingFunction, name, has_default, default_value, pos,
187 [](MProperty* i, MInt p) { return (*(i)->asString(p)); });
188#ifdef MAIA_PRINT_PROPERTIES
189 if(propertyExists(name))
190 propsFromFile << name << " = " << propertyValue << ", basic Property (MString)" << endl;
191 else
192 propsDefault << name << " = " << propertyValue << ", basic Property (MString)" << endl;
193#endif
194 return propertyValue;
195}
196
197MInt Context::getBasicPropertyOverloaded(const MString& nameOfCallingFunction, const MString& name, MBool has_default,
198 const MInt* default_value, MInt pos) {
199 MInt propertyValue;
200 propertyValue = getBasicPropertyImplicit(nameOfCallingFunction, name, has_default, default_value, pos,
201 [](MProperty* i, MInt p) { return (*(i)->asInt(p)); });
202#ifdef MAIA_PRINT_PROPERTIES
203 if(propertyExists(name))
204 propsFromFile << name << " = " << propertyValue << ", basic Property (MInt)" << endl;
205 else
206 propsDefault << name << " = " << propertyValue << ", basic Property (MInt)" << endl;
207#endif
208
209 return propertyValue;
210}
211
212MFloat Context::getBasicPropertyOverloaded(const MString& nameOfCallingFunction, const MString& name, MBool has_default,
213 const MFloat* default_value, MInt pos) {
214 MFloat propertyValue;
215 propertyValue = getBasicPropertyImplicit(nameOfCallingFunction, name, has_default, default_value, pos,
216 [](MProperty* i, MInt p) { return (*(i)->asFloat(p)); });
217#ifdef MAIA_PRINT_PROPERTIES
218 if(propertyExists(name))
219 propsFromFile << name << " = " << propertyValue << ", basic Property (MFloat)" << endl;
220 else
221 propsDefault << name << " = " << propertyValue << ", basic Property (MFloat)" << endl;
222#endif
223
224 return propertyValue;
225}
226
227MBool Context::getBasicPropertyOverloaded(const MString& nameOfCallingFunction, const MString& name, MBool has_default,
228 const MBool* default_value, MInt pos) {
229 MBool propertyValue;
230 if(m_fileType == TOML) {
231 propertyValue = getBasicPropertyImplicit(nameOfCallingFunction, name, has_default, default_value, pos,
232 [](MProperty* i, MInt p) { return (*(i)->asBool(p)); });
233 } else {
234 // handle the case that we have a netcdf property file
235 MInt tmpDef = 0; // false
236 if(has_default) {
237 tmpDef = static_cast<MInt>(*default_value);
238 }
239 MInt tmp = getBasicPropertyImplicit(nameOfCallingFunction, name, has_default, &tmpDef, pos,
240 [](MProperty* i, MInt p) { return (*(i)->asInt(p)); });
241 propertyValue = (tmp == 1);
242 }
243#ifdef MAIA_PRINT_PROPERTIES
244 if(propertyExists(name))
245 propsFromFile << name << " = " << propertyValue << ", basic Property (MBool)" << endl;
246 else
247 propsDefault << name << " = " << propertyValue << ", basic Property (MBool)" << endl;
248#endif
249
250 return propertyValue;
251}
252
253
264template <typename T, typename F>
265T Context::getSolverPropertyImplicit(const MString& nameOfCallingFunction, const MString& name, MInt solverId,
266 MBool has_default, const T* defaultValue, MInt position, F&& f) {
267 if(solverPropertyExists(name, solverId)) {
268 // lookup all properties with the requested key
269 m_pair = m_propertyMap->equal_range(name);
270 for(propertyIterator i = m_pair.first; i != m_pair.second; i++) {
271 if(i->second->solverId == solverId) {
272#ifdef MAIA_WRITE_ACCESS_PROPERTIES_FILE
273 if(!m_checkingProperties) { // Count number of accesses (if not during property checking)
274 i->second->noAccesses++;
275 }
276#endif
277
278 const T pValue = f(i->second, position);
279
280#ifdef MAIA_WRITE_ACCESS_PROPERTIES_FILE
281 // Check for default property values specified in the property file
282 if(has_default && !m_checkingProperties) {
283 const T dValue = *defaultValue;
284 const MBool isDefault = isSameValue(dValue, pValue);
285 if(!isDefault) {
286 // TODO labels:IO could be used to count properties with/without default values
287 /* i->second->noOldAccesses++; */
288 } else {
289 std::cerr << "Property default value specified: " << name << " solverId=" << solverId << " pos=" << position
290 << " value=" << pValue << " default=" << *defaultValue << " " << nameOfCallingFunction
291 << std::endl;
292 }
293 }
294#endif
295
296 return pValue;
297 }
298 }
299 } else if(propertyExists(name)) {
300 return getBasicPropertyImplicit(nameOfCallingFunction, name, has_default, defaultValue, position, f);
301 }
302
303 stringstream errormessage;
304 errormessage << " The solver property '" << name << "' is required for the simulation"
305 << ", but was not set in the toml file!!!!";
306 if(!has_default) {
307 mTerm(1, nameOfCallingFunction, errormessage.str());
308 } else {
309 return *defaultValue;
310 }
311}
312
324MString Context::getSolverPropertyOverloaded(const MString& nameOfCallingFunction, const MString& name,
325 const MInt solverId, MBool has_default, const MString* default_value,
326 MInt pos) {
327 MString propertyValue;
328 propertyValue = getSolverPropertyImplicit(nameOfCallingFunction, name, solverId, has_default, default_value, pos,
329 [](MProperty* i, MInt p) { return (*(i)->asString(p)); });
330#ifdef MAIA_PRINT_PROPERTIES
331 if(solverId != m_noSolvers) {
332 if(propertyExists(name, solverId))
333 propsFromFile << name << " = " << propertyValue << ", solver Property (solverId = " << solverId
334 << ", type = MString)" << endl;
335 else
336 propsDefault << name << " = " << propertyValue << ", solver Property (solverId = " << solverId
337 << ", type = MString)" << endl;
338 }
339#endif
340 return propertyValue;
341}
342
343MInt Context::getSolverPropertyOverloaded(const MString& nameOfCallingFunction, const MString& name,
344 const MInt solverId, MBool has_default, const MInt* default_value, MInt pos) {
345 MInt propertyValue;
346 propertyValue = getSolverPropertyImplicit(nameOfCallingFunction, name, solverId, has_default, default_value, pos,
347 [](MProperty* i, MInt p) { return (*(i)->asInt(p)); });
348#ifdef MAIA_PRINT_PROPERTIES
349 if(solverId != m_noSolvers) {
350 if(propertyExists(name, solverId))
351 propsFromFile << name << " = " << propertyValue << ", solver Property (solverId = " << solverId
352 << ", type = MInt)" << endl;
353 else
354 propsDefault << name << " = " << propertyValue << ", solver Property (solverId = " << solverId << ", type = MInt)"
355 << endl;
356 }
357#endif
358 return propertyValue;
359}
360
361MFloat Context::getSolverPropertyOverloaded(const MString& nameOfCallingFunction, const MString& name,
362 const MInt solverId, MBool has_default, const MFloat* default_value,
363 MInt pos) {
364 MFloat propertyValue;
365 propertyValue = getSolverPropertyImplicit(nameOfCallingFunction, name, solverId, has_default, default_value, pos,
366 [](MProperty* i, MInt p) { return (*(i)->asFloat(p)); });
367#ifdef MAIA_PRINT_PROPERTIES
368 if(solverId != m_noSolvers) {
369 if(propertyExists(name, solverId))
370 propsFromFile << name << " = " << propertyValue << ", solver Property (solverId = " << solverId
371 << ", type = MFloat)" << endl;
372 else
373 propsDefault << name << " = " << propertyValue << ", solver Property (solverId = " << solverId
374 << ", type = MFloat)" << endl;
375 }
376#endif
377 return propertyValue;
378}
379
380MBool Context::getSolverPropertyOverloaded(const MString& nameOfCallingFunction, const MString& name,
381 const MInt solverId, MBool has_default, const MBool* default_value,
382 MInt pos) {
383 MBool propertyValue;
384 if(m_fileType == TOML) {
385 propertyValue = getSolverPropertyImplicit(nameOfCallingFunction, name, solverId, has_default, default_value, pos,
386 [](MProperty* i, MInt p) { return (*(i)->asBool(p)); });
387 } else {
388 // handle the case that we have a netcdf property file
389 MInt tmpDef = 0; // false
390 if(has_default) {
391 tmpDef = static_cast<MInt>(*default_value);
392 }
393 MInt tmp = getBasicPropertyImplicit(nameOfCallingFunction, name, has_default, &tmpDef, pos,
394 [](MProperty* i, MInt p) { return (*(i)->asInt(p)); });
395 propertyValue = (tmp == 1);
396 }
397
398#ifdef MAIA_PRINT_PROPERTIES
399 if(solverId != m_noSolvers) {
400 if(propertyExists(name, solverId))
401 propsFromFile << name << " = " << propertyValue << ", solver Property (solverId = " << solverId
402 << ", type = MBool)" << endl;
403 else
404 propsDefault << name << " = " << propertyValue << ", solver Property (solverId = " << solverId
405 << ", type = MBool)" << endl;
406 }
407#endif
408 return propertyValue;
409}
410//-----------------Get Properties, New approach (End)---------------------//
411//--------------------------------------------------------------------------
412
419 TRACE();
420 for(propertyIterator i = m_propertyMap->begin(); i != m_propertyMap->end(); i++) {
421 DEBUG("MProperty::clear: name " << i->second->name, MAIA_DEBUG_IO);
422 DEBUG("MProperty::clear: solverId " << i->second->solverId, MAIA_DEBUG_IO);
423 i->second->clear(); // remove the pointers of property
424 }
425 m_propertyMap->clear();
426
427 for(propertyIterator i = m_propertyMapLowercase->begin(); i != m_propertyMapLowercase->end(); i++) {
428 DEBUG("MProperty::clear: name " << i->second->name, MAIA_DEBUG_IO);
429 DEBUG("MProperty::clear: solverId " << i->second->solverId, MAIA_DEBUG_IO);
430 i->second->clear(); // remove the pointers of property
431 }
432 m_propertyMapLowercase->clear();
433
434 for(zoneIterator i = m_zoneMap->begin(); i != m_zoneMap->end(); i++) {
435 DEBUG("MProperty::clear() name : " << i->second->name, MAIA_DEBUG_IO);
436 DEBUG("MProperty::clear() noSolvers : " << i->second->noSolvers, MAIA_DEBUG_IO);
437 delete[] i->second->solvers;
438 }
439#ifdef MAIA_PRINT_PROPERTIES
440 propsFromFile.close();
441 propsDefault.close();
442#endif
443}
444
445
446//---------------------------------------------------------------------------
454 // TRACE();
455
456 const pair<const MString, MProperty*> mp(p->name, p);
457
458 // produce the lowercase variant of the name to warn if property exists with different case
459 MString nameL = p->name;
460 std::transform(nameL.begin(), nameL.end(), nameL.begin(), [](unsigned char c) { return std::tolower(c); });
461
462 const pair<const MString, MProperty*> mpL(nameL, p);
463
464 // check if the lowercase variant of this property already exists but no regular-case variant
465 if(!(m_propertyMapLowercase->find(nameL) == m_propertyMapLowercase->end())
466 && (m_propertyMap->find(p->name) == m_propertyMap->end())) {
467 mTerm(1, AT_,
468 "There are multiple occurrences of the property " + p->name
469 + " with different cases. This should not happen!");
470 }
471 m_propertyMap->insert(mp);
472 m_propertyMapLowercase->insert(mpL);
473}
474
475//---------------------------------------------------------------------------
483 // TRACE();
484
487}
488
489//--------------------------------------------------------------------------
494MBool Context::propertyExists(const MString& name, MInt NotUsed(solverId)) {
495 const MBool exists = !(m_propertyMap->find(name) == m_propertyMap->end());
496 if(!exists) {
497 // produce lowercase name to check for case-insensitive matches
498 MString nameL = name;
499 std::transform(nameL.begin(), nameL.end(), nameL.begin(), [](unsigned char c) { return std::tolower(c); });
500 if(nameL == "postprocessing") { // delete this, when the two different spellings of postprocessing are delted!
501 return exists;
502 }
503 const MBool existsCaseInsensitive = !(m_propertyMapLowercase->find(nameL) == m_propertyMapLowercase->end());
504 if(existsCaseInsensitive) {
505 mTerm(1, AT_,
506 "Property " + name
507 + " not found, but there was a case-insensitive match. Are you sure you spelled it correctly?");
508 }
509 }
510 return exists;
511}
512
520 if(propertyExists(name)) {
521 m_pair = m_propertyMap->equal_range(name); // lookup all properties with the requested key
522 for(propertyIterator i = m_pair.first; i != m_pair.second; i++) { // search for the solverId
523 if(i->second->solverId == solverId) { // look for the requested solverId
524 return true;
525 }
526 }
527 }
528 return false;
529}
530
538MInt Context::propertyLength(const MString& name, MInt solverId) {
539 if(solverPropertyExists(name, solverId)) {
540 m_pair = m_propertyMap->equal_range(name); // lookup all properties with the requested key
541 for(propertyIterator i = m_pair.first; i != m_pair.second; i++) { // search for the solverId
542 if(i->second->solverId == solverId) { // look for the requested solverId
543 return i->second->count();
544 }
545 }
546 } else if(propertyExists(name)) {
547 m_pair = m_propertyMap->equal_range(name); // lookup all properties with the requested key
548 for(propertyIterator i = m_pair.first; i != m_pair.second; i++) { // search for the solverId
549 if(i->second->solverId == m_noSolvers) { // look for the requested solverId
550 return i->second->count();
551 }
552 }
553 }
554 return 0;
555}
556
557
559void Context::assertPropertyLength(const MString& name, const MInt length, const MInt solverId) {
560 const MInt propLength = propertyLength(name, solverId);
561 if(propLength != length) {
562 const MString isSolver = (solverId != m_noSolvers) ? " for solver #" + std::to_string(solverId) : "";
563 TERMM(1, "Property '" + name + "'" + isSolver + " has the wrong length, it is of length "
564 + std::to_string(Context::propertyLength(name)) + " but there should be " + std::to_string(length)
565 + " values!");
566 }
567}
568
569
577 if(solverPropertyExists(name, solverId)) {
578 m_pair = m_propertyMap->equal_range(name); // lookup all properties with the requested key
579 for(propertyIterator i = m_pair.first; i != m_pair.second; i++) { // search for the solverId
580 if(i->second->solverId == solverId) { // look for the requested solverId
581 return i->second->solverId;
582 }
583 }
584 } else if(propertyExists(name)) {
585 m_pair = m_propertyMap->equal_range(name); // lookup all properties with the requested key
586 for(propertyIterator i = m_pair.first; i != m_pair.second; i++) { // search for the solverId
587 if(i->second->solverId == m_noSolvers) { // look for the requested solverId
588 return i->second->solverId;
589 }
590 }
591 }
592 return 0;
593}
594
595//---------------------------------------------------------------------------
601 TRACE();
602
603 // All domains write their own property access file
604 {
605 std::cerr << "rank " << globalDomainId() << " writing property access file. " << m_propertyFileOutputName
606 << std::endl;
607#ifdef MAIA_WRITE_ACCESS_PROPERTIES_FILE
608 maia_properties.close();
609#endif
610 FILE* datei;
611 datei = fopen(m_propertyFileOutputName.c_str(), "a+");
612 MString tester;
613 MChar buffer[100];
614 MInt maxNameLength, maxElementLength;
615 maxNameLength = maxElementLength = 0;
616 fprintf(datei, "\n\n--------------------------property table--------------------------\n");
617 for(auto& i : *m_propertyMap) {
618 if(maxNameLength < ((MInt)i.first.length())) {
619 maxNameLength = i.first.length();
620 }
621 for(MInt j = 0; j < i.second->count(); j++) {
622 switch(i.second->type()) {
623 case MBOOL: {
624 sprintf(buffer, "%i", *i.second->asBool(j));
625 tester.append(buffer);
626 break;
627 }
628 case MINT: {
629 sprintf(buffer, "%i", *i.second->asInt(j));
630 tester.append(buffer);
631 break;
632 }
633 case MFLOAT: {
634 sprintf(buffer, "%G", *i.second->asFloat(j));
635 tester.append(buffer);
636 break;
637 }
638 case MSTRING: {
639 tester.append(*i.second->asString(j));
640 tester.append(" ");
641 break;
642 }
643 default: {
644 mTerm(1, AT_, "writePropertiesHumanReadable(): switch variable 'i->second->type' not matching any case");
645 }
646 }
647 tester.append("; ");
648 }
649 if(maxElementLength < ((MInt)tester.length())) {
650 maxElementLength = tester.length();
651 }
652 tester.clear();
653 }
654 maxNameLength = maxNameLength + 1;
655
656 for(auto& i : *m_propertyMap) {
657 switch(i.second->type()) {
658 case MBOOL: {
659 fprintf(datei, "%s ", "bool");
660 fprintf(datei, "%s", i.first.c_str());
661 for(MInt j = 0; j < ((MInt)(maxNameLength - i.first.length())); j++)
662 fprintf(datei, " ");
663 fprintf(datei, "= ");
664 for(MInt j = 0; j < i.second->count(); j++) {
665 sprintf(buffer, "%i; ", *i.second->asBool(j));
666 tester.append(buffer);
667 fprintf(datei, "%i; ", i.second->boolField[j]);
668 }
669 for(MInt k = 0; k < ((MInt)(maxElementLength - tester.length())); k++)
670 fprintf(datei, " ");
671 break;
672 }
673 case MINT: {
674 fprintf(datei, "%s ", "int");
675 fprintf(datei, "%s", i.first.c_str());
676 for(MInt j = 0; j < ((MInt)(maxNameLength - i.first.length())); j++)
677 fprintf(datei, " ");
678 fprintf(datei, "= ");
679 for(MInt j = 0; j < i.second->count(); j++) {
680 sprintf(buffer, "%i; ", *i.second->asInt(j));
681 tester.append(buffer);
682 fprintf(datei, "%i; ", i.second->intField[j]);
683 }
684 for(MInt k = 0; k < ((MInt)(maxElementLength - tester.length())); k++)
685 fprintf(datei, " ");
686 break;
687 }
688 case MFLOAT: {
689 fprintf(datei, "%s ", "double");
690 fprintf(datei, "%s", i.first.c_str());
691 for(MInt j = 0; j < ((MInt)(maxNameLength - i.first.length())); j++)
692 fprintf(datei, " ");
693 fprintf(datei, "= ");
694 for(MInt j = 0; j < i.second->count(); j++) {
695 sprintf(buffer, "%G; ", *i.second->asFloat(j));
696 tester.append(buffer);
697 fprintf(datei, "%G; ", i.second->floatField[j]);
698 }
699 for(MInt k = 0; k < ((MInt)(maxElementLength - tester.length())); k++)
700 fprintf(datei, " ");
701 break;
702 }
703 case MSTRING: {
704 fprintf(datei, "%s ", "char");
705 fprintf(datei, "%s", i.first.c_str());
706 for(MInt j = 0; j < ((MInt)(maxNameLength - i.first.length())); j++)
707 fprintf(datei, " ");
708 fprintf(datei, "= ");
709 for(MInt j = 0; j < i.second->count(); j++) {
710 tester.append(*i.second->asString(j));
711 fprintf(datei, "\"%s\"; ", i.second->asString(j)->c_str());
712 }
713 for(MInt k = 0; k < ((MInt)(maxElementLength - tester.length() - 4)); k++)
714 fprintf(datei, " ");
715 break;
716 }
717
718 default: {
719 fprintf(datei, "--------------ERROR--------------");
720 fprintf(datei, "\n");
721 fprintf(datei, "Undefined type of Property: ");
722 fprintf(datei, "%s =", i.first.c_str());
723 fprintf(datei, "\n");
724 break;
725 }
726 }
727 const MInt solverId = (i.second->solverId < m_noSolvers) ? i.second->solverId : -1;
728 fprintf(datei, "SolverId %2i", solverId);
729 fprintf(datei, " Accesses %i", i.second->noAccesses);
730 fprintf(datei, " OldAccesses %i",
731 i.second->noOldAccesses); // TODO labels:IO,totest,toremove not useful (anymore)?
732 fprintf(datei, "\n");
733 tester.clear();
734 }
735 fclose(datei);
736 }
737}
738
739//---------------------------------------------------------------------------
746 // TRACE();
747
748#ifdef MAIA_WRITE_ACCESS_PROPERTIES_FILE
749 maia_properties << endl << "--------------------------initialization process finshed--------------------------";
750 maia_properties << endl
751 << "--------------------------property access not allowed anymore--------------------------" << endl
752 << endl;
753#endif
754 // chrs should be commented in, if properties regrouping is finished
755 // writePropertiesHumanReadable();
756}
757
758//---------------------------------------------------------------------------
774 TRACE();
775
776 NEW_TIMER_GROUP_STATIC(m_timerGroupId, "Context");
777 NEW_TIMER(timerpcheck, "Property Validity Check", m_timerGroupId);
778 RECORD_TIMER_START(timerpcheck);
779
780 m_log << "==============================================================" << endl;
781 m_log << " Checking property validity... ";
782#ifdef MAIA_WRITE_ACCESS_PROPERTIES_FILE
783 maia_properties << "==============================================================" << endl;
784 maia_properties << " Checking property validity... ";
785#endif
786
787 // TEST
788 /*
789 MInt rank = MPI_COMM_WORLD.Get_rank();
790 if(rank==1)
791 {
792 MInt* b = new MInt();
793 *b=1;
794 MProperty* a = new MProperty(1,"AAA",1,b);
795 addProperty(a);
796 }
797 else
798 {
799 MInt* b = new MInt();
800 *b=2;
801 MProperty* a = new MProperty(1,"AAA",1,b);
802 addProperty(a);
803 }
804 */
805
806 MInt noDomains = globalNoDomains();
807 BinaryPropertyMPITree tree(noDomains);
808 // if(rank==0)
809 // tree.printTree();
810
811 MInt comm_partner = 0;
812
813 list<MProperty*>* left = nullptr;
814 list<MProperty*>* right = nullptr;
815
816 // We need to receive something from below
817 if(tree.getMyLeftMPISender() != nullptr || tree.getMyRightMPISender() != nullptr) {
818 if(tree.getMyLeftMPISender() != nullptr) {
819 comm_partner = *(tree.getMyLeftMPISender()->getObject());
820 left = receiveProperties(comm_partner);
821 checkPropertyViolation(comm_partner, left);
822 }
823 if(tree.getMyRightMPISender() != nullptr) {
824 comm_partner = *(tree.getMyRightMPISender()->getObject());
825 right = receiveProperties(comm_partner);
826 checkPropertyViolation(comm_partner, right);
827 }
828 }
829
830 // Send if we are not the almighty father of the tree
831 if(tree.getMyMPIReceiver() != nullptr) {
832 comm_partner = *(tree.getMyMPIReceiver()->getObject());
833 sendProperties(comm_partner);
834 }
835
836 m_log << " ---> EVERYTHING IS FINE!!!!" << endl;
837 m_log << "==============================================================" << endl;
838#ifdef MAIA_WRITE_ACCESS_PROPERTIES_FILE
839 maia_properties << " ---> EVERYTHING IS FINE!!!!" << endl;
840 maia_properties << "==============================================================" << endl;
841#endif
842 RECORD_TIMER_STOP(timerpcheck);
843}
844
866list<MProperty*>* Context::receiveProperties(MInt rank) {
867 TRACE();
868 // cerr << "Processor " << MPI_COMM_WORLD.Get_rank() << " is receiving from: " << rank << endl;
869
870 MInt tag = 0;
871 MPI_Status status;
872
873 MInt listSizes[10];
874
875 // Receive list sizes
876 MPI_Recv(listSizes, 10, MPI_INT, rank, tag, MPI_COMM_WORLD, &status, AT_, "listSizes");
877
878 // Receive integer array
879 auto* int_ar = new MInt[listSizes[0]];
880 MPI_Recv(int_ar, listSizes[0], MPI_INT, rank, tag, MPI_COMM_WORLD, &status, AT_, "int_ar");
881
882 // Receive MBool array
883 auto* bool_ar = new MBool[listSizes[1]];
884 MPI_Recv(bool_ar, listSizes[1], MPI_C_BOOL, rank, tag, MPI_COMM_WORLD, &status, AT_, "bool_ar");
885
886 // Receive float array
887 auto* float_ar = new MFloat[listSizes[2]];
888 MPI_Recv(float_ar, listSizes[2], MPI_DOUBLE, rank, tag, MPI_COMM_WORLD, &status, AT_, "float_ar");
889
890 // Receive string array
891 MChar* char_ar = new MChar[listSizes[3]];
892 MPI_Recv(char_ar, listSizes[3], MPI_CHAR, rank, tag, MPI_COMM_WORLD, &status, AT_, "char_ar");
893
894 // Receive name array
895 MChar* char_ar2 = new MChar[listSizes[4]];
896 MPI_Recv(char_ar2, listSizes[4], MPI_CHAR, rank, tag, MPI_COMM_WORLD, &status, AT_, "char_ar2");
897
898 // Receive offset array
899 MInt offset_sizes = listSizes[5] + listSizes[6] + listSizes[7] + listSizes[8] + listSizes[9];
900 auto* offset = new MInt[offset_sizes];
901 MPI_Recv(offset, offset_sizes, MPI_INT, rank, tag, MPI_COMM_WORLD, &status, AT_, "offset");
902
903 // Receive offset array
904 auto* solverIds = new MInt[listSizes[9]];
905 MPI_Recv(solverIds, listSizes[9], MPI_INT, rank, tag, MPI_COMM_WORLD, &status, AT_, "solverIds");
906
907 // Build something we can give back and handle in the comparison
908 auto* proplist = new list<MProperty*>();
909
910 MInt boolOffset = listSizes[5];
911 MInt floatOffset = listSizes[5] + listSizes[6];
912 MInt stringOffset = listSizes[5] + listSizes[6] + listSizes[7];
913 MInt nameOffset = listSizes[5] + listSizes[6] + listSizes[7] + listSizes[8];
914
915 // Run over all elements
916 MInt i = 0;
917 for(; i < boolOffset; i++) {
918 MInt low_off = 0;
919 MInt low_off_name = 0;
920 if(i > 0) {
921 low_off = offset[i - 1];
922 low_off_name = offset[nameOffset + i - 1];
923 }
924
925 auto* a = new MInt[offset[i] - low_off];
926 for(MInt j = low_off, l = 0; j < offset[i]; j++, l++) {
927 a[l] = int_ar[j];
928 }
929
930 MString name;
931 for(MInt j = low_off_name; j < offset[nameOffset + i]; j++) {
932 name += char_ar2[j];
933 }
934
935 MProperty* prop = new MProperty(offset[i] - low_off, name, solverIds[i], a);
936 proplist->push_back(prop);
937
938 delete[] a;
939 }
940
941 for(; i < floatOffset; i++) {
942 MInt low_off = 0;
943 MInt low_off_name = offset[nameOffset + i - 1];
944 if(i > boolOffset) {
945 low_off = offset[i - 1];
946 }
947
948 // cerr << offset[i]<< " " << low_off << endl;
949 auto* a = new MBool[offset[i] - low_off];
950 for(MInt j = low_off, l = 0; j < offset[i]; j++, l++) {
951 a[l] = bool_ar[j];
952 }
953
954 MString name;
955 for(MInt j = low_off_name; j < offset[nameOffset + i]; j++) {
956 name += char_ar2[j];
957 }
958
959 MProperty* prop = new MProperty(offset[i] - low_off, name, solverIds[i], a);
960 proplist->push_back(prop);
961
962 delete[] a;
963 }
964
965 for(; i < stringOffset; i++) {
966 MInt low_off = 0;
967 MInt low_off_name = offset[nameOffset + i - 1];
968 if(i > floatOffset) low_off = offset[i - 1];
969
970 // cerr << offset[i]<< " " << low_off << endl;
971 auto* a = new MFloat[offset[i] - low_off];
972 for(MInt j = low_off, l = 0; j < offset[i]; j++, l++) {
973 a[l] = float_ar[j];
974 }
975
976 MString name;
977 for(MInt j = low_off_name; j < offset[nameOffset + i]; j++)
978 name += char_ar2[j];
979
980 MProperty* prop = new MProperty(offset[i] - low_off, name, solverIds[i], a);
981 proplist->push_back(prop);
982
983 delete[] a;
984 }
985
986 for(; i < nameOffset; i++) {
987 MInt low_off = 0;
988 MInt low_off_name = offset[nameOffset + i - 1];
989 if(i > stringOffset) low_off = offset[i - 1];
990
991 MString a;
992 for(MInt j = low_off, l = 0; j < offset[i]; j++, l++)
993 a += char_ar[j];
994
995 MString name;
996 for(MInt j = low_off_name; j < offset[nameOffset + i]; j++)
997 name += char_ar2[j];
998
999 MProperty* prop = new MProperty(1, name, solverIds[i], &a);
1000 proplist->push_back(prop);
1001 }
1002
1003 // Check all properties
1004 // FOR DEBUG
1005 /*
1006 MInt l=0;
1007 for (list<MProperty*>::iterator it = proplist->begin(); it!=proplist->end();it++,l++)
1008 {
1009 cerr << (*it)->name << " " << (*it)->solverId << ": " ;
1010 for (MInt j=0; j<(*it)->elements;j++)
1011 {
1012 if(l<floatOffset)
1013 cerr << *((*it)->asInt(j)) << " ";
1014 else if(l<stringOffset)
1015 cerr << *((*it)->asFloat(j)) << " ";
1016 else if(l<nameOffset)
1017 cerr << *((*it)->asString(j)) << " ";
1018 }
1019 cerr << endl;
1020 }
1021 */
1022 delete[] offset;
1023 delete[] solverIds;
1024 delete[] int_ar;
1025 delete[] float_ar;
1026 delete[] bool_ar;
1027 delete[] char_ar;
1028 delete[] char_ar2;
1029
1030
1031 return proplist;
1032}
1033
1053 TRACE();
1054
1055 MInt tag = 0;
1056
1057 // cerr << "Processor " << MPI_COMM_WORLD.Get_rank() << " is sending to: " << rank << endl;
1058 MInt listSizes[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
1059
1060 list<MProperty*> intProperties;
1061 list<MProperty*> floatProperties;
1062 list<MProperty*> stringProperties;
1063 list<MProperty*> boolProperties;
1064
1065 for(auto& i : *m_propertyMap) {
1066 switch(i.second->type()) {
1067 case MINT: {
1068 intProperties.push_back(i.second);
1069 listSizes[0] += (i.second->elements);
1070 listSizes[5]++;
1071 break;
1072 }
1073 case MBOOL: {
1074 boolProperties.push_back(i.second);
1075 listSizes[1] += (i.second->elements);
1076 listSizes[6]++;
1077 break;
1078 }
1079 case MFLOAT: {
1080 floatProperties.push_back(i.second);
1081 listSizes[2] += (i.second->elements);
1082 listSizes[7]++;
1083 break;
1084 }
1085 case MSTRING: {
1086 stringProperties.push_back(i.second);
1087 listSizes[3] += (i.second->stringField->size());
1088 listSizes[8]++;
1089 break;
1090 }
1091 default: {
1092 mTerm(1, AT_, "Context::sendProperties(): switch variable 'i->second->type' not matching any case");
1093 }
1094 }
1095 listSizes[4] += (i.second->name.size());
1096 listSizes[9]++;
1097 }
1098
1099 MInt offset_sizes = listSizes[5] + listSizes[6] + listSizes[7] + listSizes[8] + listSizes[9];
1100 // cerr << offset_sizes << endl;
1101 auto* offset = new MInt[offset_sizes];
1102 auto* solverIds = new MInt[listSizes[9]];
1103 /*
1104 cerr << "Number of INT properties: " << intProperties.size() << ", size = " << listSizes[0] << endl;
1105 cerr << "Number of FLOAT properties: " << floatProperties.size() << ", size = " << listSizes[1] << endl;
1106 cerr << "Number of STRING properties: " << stringProperties.size() << ", size = " << listSizes[2] << endl;
1107 cerr << "Number of NAMES: " << listSizes[7] << ", size = " << listSizes[3] << endl;
1108 */
1109
1110 // Build integer array and fill sizes for offsets
1111 auto* int_ar = new MInt[listSizes[0]];
1112 MInt k = 0, m = 0, n = 0;
1113 for(auto& intPropertie : intProperties) {
1114 for(MInt j = 0; j < intPropertie->elements; j++) {
1115 int_ar[k] = intPropertie->intField[j];
1116 k++;
1117 }
1118 offset[m] = k;
1119 solverIds[m] = intPropertie->solverId;
1120 m++;
1121 }
1122
1123 // Build float array
1124 auto* bool_ar = new MBool[listSizes[1]];
1125 k = 0;
1126 for(auto& boolPropertie : boolProperties) {
1127 for(MInt j = 0; j < boolPropertie->elements; j++) {
1128 bool_ar[k] = boolPropertie->boolField[j];
1129 k++;
1130 }
1131
1132
1133 offset[m] = k;
1134 solverIds[m] = boolPropertie->solverId;
1135 m++;
1136 }
1137
1138 // Build MBool array and fill sizes for offsets
1139 auto* float_ar = new MFloat[listSizes[2]];
1140 k = 0;
1141 for(auto& floatPropertie : floatProperties) {
1142 for(MInt j = 0; j < floatPropertie->elements; j++) {
1143 float_ar[k] = floatPropertie->floatField[j];
1144 k++;
1145 }
1146
1147 offset[m] = k;
1148 solverIds[m] = floatPropertie->solverId;
1149 m++;
1150 }
1151
1152 // Build string array
1153 MChar* char_ar = new MChar[listSizes[3]];
1154 k = 0;
1155 for(auto& stringPropertie : stringProperties) {
1156 MString a = *(stringPropertie->asString());
1157 for(MInt j = 0; j < (MInt)a.size(); j++) {
1158 char_ar[k] = a[j];
1159 k++;
1160 }
1161 offset[m] = k;
1162 solverIds[m] = stringPropertie->solverId;
1163 m++;
1164 }
1165
1166 // Build name array
1167 MChar* char_ar2 = new MChar[listSizes[4]];
1168 k = 0;
1169 for(auto& intPropertie : intProperties) {
1170 MString a = intPropertie->name;
1171 for(MChar j : a) {
1172 char_ar2[k] = j;
1173 k++;
1174 }
1175 offset[m] = k;
1176 m++;
1177 }
1178 for(auto& boolPropertie : boolProperties) {
1179 MString a = boolPropertie->name;
1180 for(MChar j : a) {
1181 char_ar2[k] = j;
1182 k++;
1183 }
1184 offset[m] = k;
1185 m++;
1186 }
1187 for(auto& floatPropertie : floatProperties) {
1188 MString a = floatPropertie->name;
1189 for(MChar j : a) {
1190 char_ar2[k] = j;
1191 k++;
1192 }
1193 offset[m] = k;
1194 m++;
1195 }
1196 for(auto& stringPropertie : stringProperties) {
1197 MString a = stringPropertie->name;
1198 for(MChar j : a) {
1199 char_ar2[k] = j;
1200 k++;
1201 }
1202 offset[m] = k;
1203 m++;
1204 n++;
1205 }
1206
1207 // Send information about arrays
1208 MPI_Send(listSizes, 10, MPI_INT, rank, tag, MPI_COMM_WORLD, AT_, "listSizes");
1209
1210 // Send integer array
1211 MPI_Send(int_ar, listSizes[0], MPI_INT, rank, tag, MPI_COMM_WORLD, AT_, "int_ar");
1212
1213 // Send float array
1214 MPI_Send(bool_ar, listSizes[1], MPI_C_BOOL, rank, tag, MPI_COMM_WORLD, AT_, "bool_ar");
1215
1216 // Send MBool array
1217 MPI_Send(float_ar, listSizes[2], MPI_DOUBLE, rank, tag, MPI_COMM_WORLD, AT_, "float_ar");
1218
1219 // Send string array
1220 MPI_Send(char_ar, listSizes[3], MPI_CHAR, rank, tag, MPI_COMM_WORLD, AT_, "char_ar");
1221
1222 // Send name array
1223 MPI_Send(char_ar2, listSizes[4], MPI_CHAR, rank, tag, MPI_COMM_WORLD, AT_, "char_ar2");
1224
1225 // Send offset information
1226 MPI_Send(offset, offset_sizes, MPI_INT, rank, tag, MPI_COMM_WORLD, AT_, "offset");
1227
1228 // Send solverIds
1229 MPI_Send(solverIds, listSizes[9], MPI_INT, rank, tag, MPI_COMM_WORLD, AT_, "solverIds");
1230
1231 // Clean up
1232 delete[] offset;
1233 delete[] solverIds;
1234 delete[] int_ar;
1235 delete[] float_ar;
1236 delete[] bool_ar;
1237 delete[] char_ar;
1238 delete[] char_ar2;
1239 intProperties.clear();
1240 floatProperties.clear();
1241 stringProperties.clear();
1242 boolProperties.clear();
1243}
1244
1245
1256void Context::checkPropertyViolation(MInt partnerrank, list<MProperty*>* prop) {
1257 TRACE();
1258
1259 MInt defaultInt = -1;
1260 MFloat defaultFloat = -1.0;
1261 MBool defaultBool = false;
1262 MString defaultString = " ";
1263
1264 MInt rank = globalDomainId();
1265
1266 // Set flag to indicate that property accesses should not be counted here
1267 m_checkingProperties = true;
1268
1269 // Check local with other
1270 for(auto& it : *prop) {
1271 if(propertyExists(it->name)) {
1272 switch(it->type()) {
1273 case MINT: {
1274 for(MInt j = 0; j < it->elements; j++) {
1275 if(*(it->asInt(j)) != getSolverProperty<MInt>(it->name, it->solverId, AT_, &defaultInt, j)
1276 || it->solverId != propertySolverId(it->name, it->solverId)) {
1277 stringstream errorMessage;
1278 // auto p = getProperty((*it)->name,(*it)->solverId, AT_, (MInt*) nullptr);
1279 errorMessage << "Poperty violation for '" << it->name << "' on CPUs: " << rank << "," << partnerrank;
1280 // << endl
1281 // << "received: name='" << (*it)->name << "', value='" << *((*it)->asInt(j))
1282 // << "', solverId='" << (*it)->solverId << "'" << endl
1283 // << "local: name = '" << p->name << "', value='" << *(p->asInt(j))
1284 // << "', solverId='" << p->solverId << "'";
1285 mTerm(1, AT_, errorMessage.str());
1286 }
1287 }
1288 break;
1289 }
1290 case MBOOL: {
1291 for(MInt j = 0; j < it->elements; j++) {
1292 if(*(it->asBool(j)) != getSolverProperty<MBool>(it->name, it->solverId, AT_, &defaultBool, j)
1293 || it->solverId != propertySolverId(it->name, it->solverId)) {
1294 stringstream errorMessage;
1295 errorMessage << "Poperty violation for '" << it->name << "' on CPUs: " << rank << "," << partnerrank;
1296 mTerm(1, AT_, errorMessage.str());
1297 }
1298 }
1299 break;
1300 }
1301 case MFLOAT: {
1302 for(MInt j = 0; j < it->elements; j++) {
1303 if(!approx(*(it->asFloat(j)), getSolverProperty<MFloat>(it->name, it->solverId, AT_, &defaultFloat, j),
1304 MFloatEps)
1305 || it->solverId != propertySolverId(it->name, it->solverId)) {
1306 stringstream errorMessage;
1307 errorMessage << "Poperty violation for '" << it->name << "' on CPUs: " << rank << "," << partnerrank;
1308 mTerm(1, AT_, errorMessage.str());
1309 }
1310 }
1311 break;
1312 }
1313 case MSTRING: {
1314 for(MInt j = 0; j < it->elements; j++) {
1315 if(*(it->asString(j)) != getSolverProperty<MString>(it->name, it->solverId, AT_, &defaultString, j)
1316 || it->solverId != propertySolverId(it->name, it->solverId)) {
1317 stringstream errorMessage;
1318 errorMessage << "Poperty violation for '" << it->name << "' on CPUs: " << rank << "," << partnerrank;
1319 mTerm(1, AT_, errorMessage.str());
1320 }
1321 }
1322 break;
1323 }
1324 default: {
1325 mTerm(1, AT_, "Context::CheckPropertyViolation(): switch variable '(*it)->type' not matching any case");
1326 }
1327 }
1328 } else {
1329 MProperty* a;
1330 switch(it->type()) {
1331 case MINT: {
1332 a = new MProperty(it->elements, it->name, it->solverId, it->intField);
1333 break;
1334 }
1335 case MBOOL: {
1336 a = new MProperty(it->elements, it->name, it->solverId, it->boolField);
1337 break;
1338 }
1339 case MFLOAT: {
1340 a = new MProperty(it->elements, it->name, it->solverId, it->floatField);
1341 break;
1342 }
1343 case MSTRING: {
1344 a = new MProperty(it->elements, it->name, it->solverId, it->stringField);
1345 break;
1346 }
1347 default:
1348 a = new MProperty();
1349 }
1350 addProperty(a);
1351 }
1352 }
1353
1354 // Reset flag after checking properties
1355 m_checkingProperties = false;
1356
1357 // Clean up
1358 prop->clear();
1359}
1360
1362void Context::dump(const MString& fileName) {
1363 ofstream os(fileName);
1364 for(auto&& pm : *m_propertyMap) {
1365 const auto name = pm.first;
1366 const auto prop = pm.second;
1367 os << name << " (";
1368 switch(prop->propertyType) {
1369 case MINT:
1370 os << "MINT";
1371 break;
1372 case MFLOAT:
1373 os << "MFLOAT";
1374 break;
1375 case MSTRING:
1376 os << "MSTRING";
1377 break;
1378 case MBOOL:
1379 os << "MBOOL";
1380 break;
1381 default:
1382 TERMM(1, "Bad type");
1383 }
1384 os << "): ";
1385 for(MInt i = 0; i < prop->count(); i++) {
1386 if(i != 0) {
1387 os << ", ";
1388 }
1389 switch(prop->propertyType) {
1390 case MINT:
1391 os << prop->intField[i];
1392 break;
1393 case MFLOAT:
1394 os << prop->floatField[i];
1395 break;
1396 case MSTRING:
1397 os << prop->stringField[i];
1398 break;
1399 case MBOOL:
1400 os << prop->boolField[i];
1401 break;
1402 default:
1403 TERMM(1, "Bad type");
1404 }
1405 }
1406 os << std::endl;
1407 }
1408}
BinaryTreeIntNode * getMyMPIReceiver()
Definition: binarytree.h:141
BinaryTreeIntNode * getMyLeftMPISender()
Definition: binarytree.h:148
BinaryTreeIntNode * getMyRightMPISender()
Definition: binarytree.h:154
T * getObject()
Definition: binarytree.h:40
static void communicateProperties()
Communicates properties to check if default falues match.
Definition: context.cpp:773
static MBool m_checkingProperties
Definition: context.h:142
static propertyMap * m_propertyMapLowercase
Definition: context.h:135
static void initializationProcessFinished()
Sets flag to forbide property access.
Definition: context.cpp:745
static MString m_propertyFileText
Definition: context.h:140
static void dump(const MString &fileName)
Dump all properties to text file.
Definition: context.cpp:1362
static void init()
This intializes the property Map.
Definition: context.cpp:482
static void sendProperties(MInt rank)
Sends the property list to another cpu.
Definition: context.cpp:1052
static void checkPropertyViolation(MInt partnerrank, std::list< MProperty * > *prop)
Checks if local properties differ from received properties.
Definition: context.cpp:1256
static MInt propertySolverId(const MString &name, MInt solverId=m_noSolvers)
Returns the number of elements of a property.
Definition: context.cpp:576
static MInt propertyLength(const MString &name, MInt solverId=m_noSolvers)
Returns the number of elements of a property.
Definition: context.cpp:538
static IOToml * m_IOToml
Definition: context.h:131
static std::pair< propertyMap::iterator, propertyMap::iterator > m_pair
Definition: context.h:138
static MInt getSolverPropertyOverloaded(const MString &nameOfCallingFunction, const MString &name, const MInt solverId, MBool has_default, const MInt *default_value, MInt pos)
Definition: context.cpp:343
static IONetcdf * m_IONetcdf
Definition: context.h:130
static MInt getBasicPropertyOverloaded(const MString &nameOfCallingFunction, const MString &name, MBool has_default, const MInt *default_value, MInt pos)
Definition: context.cpp:197
static void addProperty(MProperty *)
This method adds properties.
Definition: context.cpp:453
static void writePropertiesHumanReadable()
Write the properties into a text file.
Definition: context.cpp:600
static assembly * m_assembly
Definition: context.h:137
static void clear()
Definition: context.cpp:418
static T getBasicPropertyImplicit(const MString &nameOfCallingFunction, const MString &name, MBool has_default, const T *defaultValue, MInt position, F &&f)
Returns the value of the requested basic level property (implicit).
Definition: context.cpp:126
static void readPropertyFile(FileType, const MString &fileName)
static void assertPropertyLength(const MString &name, const MInt length, const MInt solverId=m_noSolvers)
Assert that the length of a property matches the given length.
Definition: context.cpp:559
static MBool solverPropertyExists(const MString &name, MInt solver)
Checks existence of a solver property details This function returns true, if the solver property with...
Definition: context.cpp:519
static T getSolverPropertyImplicit(const MString &nameOfCallingFunction, const MString &name, const MInt solverId, MBool has_default, const T *defaultValue, MInt position, F &&f)
Returns the value of the requested solver property (implicit).
Definition: context.cpp:265
static MInt m_noSolvers
Definition: context.h:133
static zoneMap * m_zoneMap
Definition: context.h:136
static MBool propertyExists(const MString &name, MInt solver=m_noSolvers)
This function checks if a property exists in general.
Definition: context.cpp:494
static propertyMap * m_propertyMap
Definition: context.h:134
static MInt m_fileType
Definition: context.h:141
static std::list< MProperty * > * receiveProperties(MInt rank)
Receives a property list from another cpu.
Definition: context.cpp:866
static MString m_propertyFileOutputName
Definition: context.h:139
static MString m_name
Definition: context.h:132
static MBool isSameValue(const MFloat v1, const MFloat v2)
Definition: context.h:221
assembly * readPropertyFile(const MString &fileName)
Definition: ionetcdf.cpp:330
MInt solverCount()
Definition: ionetcdf.cpp:29
Definition: iotoml.h:25
MString rawText() const
Definition: iotoml.h:29
assembly * readPropertyFile(const MString &fileName)
Definition: iotoml.cpp:143
MInt solverCount()
Definition: iotoml.cpp:20
std::map< MString, MZone * > zoneMap
Definition: contexttypes.h:17
zoneMap::const_iterator zoneIterator
Definition: contexttypes.h:18
std::multimap< MString, MProperty * > propertyMap
Definition: contexttypes.h:15
propertyMap::const_iterator propertyIterator
Definition: contexttypes.h:16
FileType
Definition: enums.h:18
@ NETCDF
Definition: enums.h:18
@ TOML
Definition: enums.h:18
@ MINT
Definition: enums.h:269
@ MFLOAT
Definition: enums.h:269
@ MBOOL
Definition: enums.h:269
@ MSTRING
Definition: enums.h:269
void mTerm(const MInt errorCode, const MString &location, const MString &message)
Definition: functions.cpp:29
MBool fileExists(const MString &fileName)
Returns true if the file fileName exists, false otherwise.
Definition: functions.cpp:73
MBool approx(const T &, const U &, const T)
Definition: functions.h:272
MInt globalNoDomains()
Return global number of domains.
MInt globalDomainId()
Return global domain id.
InfoOutFile m_log
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58
char MChar
Definition: maiatypes.h:56
int MPI_Recv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Status *status, const MString &name, const MString &varname)
same as MPI_Recv
int MPI_Barrier(MPI_Comm comm, const MString &name)
same as MPI_Barrier
int MPI_Send(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, const MString &name, const MString &varname)
same as MPI_Send
Definition: contexttypes.h:19
propertyMap * properties
Definition: contexttypes.h:20
zoneMap * zones
Definition: contexttypes.h:22
propertyMap * propertiesLowercase
Definition: contexttypes.h:21