MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
geometrycontext.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#include "geometrycontext.h"
8
9#include "geometryionetcdf.h"
10#include "geometryiotoml.h"
11#include "globals.h"
12
13using namespace std;
14
15//--------------------------------------------------------------------------
19
20
21//--------------------------------------------------------------------------
24void GeometryContext::readPropertyFile(FileType fileType, const MChar* fileName) {
25 TRACE();
26
27 MBool success = false; // successfully accessed the property file ?
28 m_name = fileName;
29 while(!success) {
30 switch(fileType) {
31 case NETCDF:
33 break;
34 case TOML:
36 break;
37 /* case HDF:
38 m_geometryIOBase = new GeometryIOHdf;
39 break;
40 case ASCII:
41 m_geometryIOBase = new GeometryIOAscii;
42 break; */
43 default:
44 break;
45 }
50 success = true;
51 }
52}
53
54//--------------------------------------------------------------------------
60 // TRACE();
61 GeometryProperty* property = nullptr;
62 if(m_geometryPropertyMap->find(name) == m_geometryPropertyMap->end()) {
64 message.append("GeometryContext::getProperty Property: \"");
65 message.append(name);
66 message.append("\" not found!");
67 // SX8 cannot compile with excepetion handling
68 // throw ( MPropertyNotFound ( message ) );
69 cerr << message;
70 // allocate and return empty property
71 property = new GeometryProperty();
72 return property;
73 }
74
75 m_pair = m_geometryPropertyMap->equal_range(name); // lookup all properties
76 // with the requested key
77 MBool propertyFound = false;
78 for(geometryPropertyIterator i = m_pair.first; i != m_pair.second; i++) { // search for the segmentId
79 DEBUG("GeometryContext::getProperty segmentId:" << i->second->segmentId, MAIA_DEBUG_USER1);
80 if(i->second->segmentId == segmentId) { // look for the requested segmentId
81 property = i->second; // and deliver the value
82 propertyFound = true;
83 }
84 }
85 /* if no property found use standard value (remember, a standard value allways has
86 the segmentId of the last segmentId +1, i.e. it is equal the no of segments
87 expressed in m_noSegments). Since the consistency check guarantees the existence
88 of a standard value, this should always work!*/
89 if(!propertyFound) {
90 for(geometryPropertyIterator i = m_pair.first; i != m_pair.second; i++) {
91 if(i->second->segmentId == m_noSegments) { // look for a default value
92 property = i->second; // and deliver the value
93 DEBUG("GeometryContext::getProperty :" << name << " using standard property", MAIA_DEBUG_USER1);
94 } else {
95 DEBUG("GeometryContext::getProperty :" << name << " no standard value found !", MAIA_DEBUG_USER1);
96 }
97 }
98 }
99 return property;
100}
101
102//--------------------------------------------------------------------------
109 TRACE();
110 for(geometryPropertyIterator i = m_geometryPropertyMap->begin(); i != m_geometryPropertyMap->end(); i++) {
111 DEBUG("GeometryProperty::clear() name : " << i->second->name, MAIA_DEBUG_IO);
112 DEBUG("GeometryProperty::clear() segmentId : " << i->second->segmentId, MAIA_DEBUG_IO);
113 i->second->clear(); // remove the pointers of property
114 }
115 m_geometryPropertyMap->clear();
116
117 for(bodyIterator i = m_bodyMap->begin(); i != m_bodyMap->end(); i++) {
118 DEBUG("GeometryProperty::clear() name : " << i->second->name, MAIA_DEBUG_IO);
119 DEBUG("GeometryProperty::clear() noSegments : " << i->second->noSegments, MAIA_DEBUG_IO);
120 delete[] i->second->segments;
121 }
122}
123
124
125//---------------------------------------------------------------------------
133 TRACE();
134
135 const pair<const MString, GeometryProperty*> mp(p->name, p);
136 m_geometryPropertyMap->insert(mp);
137}
138
139//---------------------------------------------------------------------------
147 // TRACE();
148
150}
151
152//---------------------------------------------------------------------------
160 TRACE();
161
164}
165
166//--------------------------------------------------------------------------
172 if(m_geometryPropertyMap->find(name) == m_geometryPropertyMap->end()) {
173 return false;
174 } else {
175 return true;
176 }
177}
std::pair< geometryPropertyMap::iterator, geometryPropertyMap::iterator > m_pair
geometryPropertyMap * m_geometryPropertyMap
geometryAssembly * m_geometryAssembly
void init()
This intializes the property Map.
MPI_Comm mpiComm() const
MBool propertyExists(MString name, MInt solver)
bodyMap * m_bodyMap
GeometryProperty * getProperty(const MString &name, MInt segment)
void readPropertyFile(FileType, const MChar *fileName)
GeometryIOBase * m_geometryIOBase
void writeProperties(MChar *fileName)
This function writes all properties in a property File.
void addProperty(GeometryProperty *)
This method adds properties.
virtual MInt segmentCount()=0
virtual void writeProperties(const MChar *, geometryPropertyMap *)
virtual geometryAssembly * readPropertyFile(MString fileName)=0
FileType
Definition: enums.h:18
@ NETCDF
Definition: enums.h:18
@ TOML
Definition: enums.h:18
const MString const MString & message
Definition: functions.h:37
std::multimap< MString, GeometryProperty * > geometryPropertyMap
geometryPropertyMap::const_iterator geometryPropertyIterator
std::map< MString, Body * > bodyMap
bodyMap::const_iterator bodyIterator
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
bool MBool
Definition: maiatypes.h:58
char MChar
Definition: maiatypes.h:56
bodyMap * bodies
geometryPropertyMap * geometryProperties