MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
GeometryContext Class Reference

#include <geometrycontext.h>

Collaboration diagram for GeometryContext:
[legend]

Public Member Functions

void readPropertyFile (FileType, const MChar *fileName)
 
GeometryPropertygetProperty (const MString &name, MInt segment)
 
MInt noPropertySegments (const MString &name)
 
MBool propertyExists (MString name, MInt solver)
 
bodyMap getBodies ()
 
void clear ()
 
void init ()
 This intializes the property Map. More...
 
void addProperty (GeometryProperty *)
 This method adds properties. More...
 
void writeProperties (MChar *fileName)
 This function writes all properties in a property File. More...
 
MInt getNoSegments () const
 
 ~GeometryContext ()
 
 GeometryContext (const MPI_Comm comm)
 
MPI_Comm mpiComm () const
 

Private Attributes

GeometryIOBasem_geometryIOBase
 
MString m_name
 
MInt m_noSegments
 
MInt m_noBodies
 
geometryPropertyMapm_geometryPropertyMap
 
bodyMapm_bodyMap
 
geometryAssemblym_geometryAssembly
 
std::pair< geometryPropertyMap::iterator, geometryPropertyMap::iterator > m_pair
 
const MPI_Comm m_mpiComm = MPI_COMM_NULL
 

Detailed Description

Definition at line 16 of file geometrycontext.h.

Constructor & Destructor Documentation

◆ ~GeometryContext()

GeometryContext::~GeometryContext ( )

This method cares for the correct deletion of the property structs. therefore it runs through the propertyMap and deletes every occuring property struct. Afterwards the bodyMap is equally treated. And finally the bodyMap and the propertyMap are deleted.

Definition at line 108 of file geometrycontext.cpp.

108 {
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}
geometryPropertyMap * m_geometryPropertyMap
bodyMap * m_bodyMap
geometryPropertyMap::const_iterator geometryPropertyIterator
bodyMap::const_iterator bodyIterator

◆ GeometryContext()

GeometryContext::GeometryContext ( const MPI_Comm  comm)
inline

Definition at line 49 of file geometrycontext.h.

49: m_mpiComm(comm){};
const MPI_Comm m_mpiComm

Member Function Documentation

◆ addProperty()

void GeometryContext::addProperty ( GeometryProperty p)

Definition at line 132 of file geometrycontext.cpp.

132 {
133 TRACE();
134
135 const pair<const MString, GeometryProperty*> mp(p->name, p);
136 m_geometryPropertyMap->insert(mp);
137}
constexpr std::underlying_type< FcCell >::type p(const FcCell property)
Converts property name to underlying integer value.

◆ clear()

void GeometryContext::clear ( )

◆ getBodies()

bodyMap GeometryContext::getBodies ( )

Returns a copy of the bodyMap

Definition at line 18 of file geometrycontext.cpp.

18{ return *m_bodyMap; }

◆ getNoSegments()

MInt GeometryContext::getNoSegments ( ) const
inline

Definition at line 46 of file geometrycontext.h.

46{ return m_noSegments; };

◆ getProperty()

GeometryProperty * GeometryContext::getProperty ( const MString name,
MInt  segmentId 
)

Returns a pointer to the requested property.

Definition at line 59 of file geometrycontext.cpp.

59 {
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}
std::pair< geometryPropertyMap::iterator, geometryPropertyMap::iterator > m_pair
const MString const MString & message
Definition: functions.h:37
std::basic_string< char > MString
Definition: maiatypes.h:55
bool MBool
Definition: maiatypes.h:58

◆ init()

void GeometryContext::init ( )

Use ts function if you want to create a new property list. If you want to load properties from file use the function readPropertyFile.

Definition at line 146 of file geometrycontext.cpp.

146 {
147 // TRACE();
148
150}
std::multimap< MString, GeometryProperty * > geometryPropertyMap

◆ mpiComm()

MPI_Comm GeometryContext::mpiComm ( ) const
inline

Definition at line 50 of file geometrycontext.h.

50{ return m_mpiComm; }

◆ noPropertySegments()

MInt GeometryContext::noPropertySegments ( const MString name)
inline

Definition at line 21 of file geometrycontext.h.

21 {
22 if(m_geometryPropertyMap->find(name) == m_geometryPropertyMap->end()) {
23 std::cerr << "GeometryContext::noPropertySegments " << name << " not found " << std::endl;
24 return 0;
25 }
26 auto range = m_geometryPropertyMap->equal_range(name);
27
28 MInt no = 0;
29 for(auto& i = range.first; i != range.second; i++) {
30 no++;
31 }
32 return no;
33 }
@ no
Definition: enums.h:208
int32_t MInt
Definition: maiatypes.h:62

◆ propertyExists()

MBool GeometryContext::propertyExists ( MString  name,
MInt  solver 
)

Definition at line 171 of file geometrycontext.cpp.

171 {
172 if(m_geometryPropertyMap->find(name) == m_geometryPropertyMap->end()) {
173 return false;
174 } else {
175 return true;
176 }
177}

◆ readPropertyFile()

void GeometryContext::readPropertyFile ( FileType  fileType,
const MChar fileName 
)

Creates an object of the specified filetype to open the property file

Definition at line 24 of file geometrycontext.cpp.

24 {
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}
geometryAssembly * m_geometryAssembly
MPI_Comm mpiComm() const
GeometryIOBase * m_geometryIOBase
virtual MInt segmentCount()=0
virtual geometryAssembly * readPropertyFile(MString fileName)=0
@ NETCDF
Definition: enums.h:18
@ TOML
Definition: enums.h:18
bodyMap * bodies
geometryPropertyMap * geometryProperties

◆ writeProperties()

void GeometryContext::writeProperties ( MChar fileName)

Use ts function if you want to create a new property list. If you want to load properties from file use the function readPropertyFile.

Definition at line 159 of file geometrycontext.cpp.

159 {
160 TRACE();
161
164}
virtual void writeProperties(const MChar *, geometryPropertyMap *)

Member Data Documentation

◆ m_bodyMap

bodyMap* GeometryContext::m_bodyMap
private

Definition at line 58 of file geometrycontext.h.

◆ m_geometryAssembly

geometryAssembly* GeometryContext::m_geometryAssembly
private

Definition at line 59 of file geometrycontext.h.

◆ m_geometryIOBase

GeometryIOBase* GeometryContext::m_geometryIOBase
private

Definition at line 53 of file geometrycontext.h.

◆ m_geometryPropertyMap

geometryPropertyMap* GeometryContext::m_geometryPropertyMap
private

Definition at line 57 of file geometrycontext.h.

◆ m_mpiComm

const MPI_Comm GeometryContext::m_mpiComm = MPI_COMM_NULL
private

Definition at line 61 of file geometrycontext.h.

◆ m_name

MString GeometryContext::m_name
private

Definition at line 54 of file geometrycontext.h.

◆ m_noBodies

MInt GeometryContext::m_noBodies
private

Definition at line 56 of file geometrycontext.h.

◆ m_noSegments

MInt GeometryContext::m_noSegments
private

Definition at line 55 of file geometrycontext.h.

◆ m_pair

std::pair<geometryPropertyMap::iterator, geometryPropertyMap::iterator> GeometryContext::m_pair
private

Definition at line 60 of file geometrycontext.h.


The documentation for this class was generated from the following files: