MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
maia::coupling::Mapping Struct Reference

Multi-to-multi mapping class. More...

#include <surfacecoupling.h>

Collaboration diagram for maia::coupling::Mapping:
[legend]

Public Member Functions

range< std::vector< MInt >::const_iterator > get (const MUint i) const
 
void clear ()
 
std::size_t size () const
 
MIntinsert (const MInt i)
 
range< std::vector< MInt >::const_iterator > operator[] (const MInt i) const
 

Public Attributes

std::vector< MUintm_offsets
 
std::vector< MIntm_mapped
 

Detailed Description

This mapping class allows for multi-to-multi mappings returning a range of values for a given key

Author
Julian Vorspohl j.vor.nosp@m.spoh.nosp@m.l@aia.nosp@m..rwt.nosp@m.h-aac.nosp@m.hen..nosp@m.de

Definition at line 186 of file surfacecoupling.h.

Member Function Documentation

◆ clear()

void maia::coupling::Mapping::clear ( )
inline

Definition at line 205 of file surfacecoupling.h.

205 {
206 m_offsets.clear();
207 m_mapped.clear();
208 }
std::vector< MUint > m_offsets
std::vector< MInt > m_mapped

◆ get()

range< std::vector< MInt >::const_iterator > maia::coupling::Mapping::get ( const MUint  i) const
inline

Definition at line 190 of file surfacecoupling.h.

190 {
191 MUint b = 0;
192 MUint e = 0;
193
194 if(i < m_offsets.size()) {
195 b = m_offsets[i];
196 e = (i == m_offsets.size() - 1) ? m_mapped.size() : m_offsets[i + 1];
197 }
198
199 std::vector<MInt>::const_iterator bb = m_mapped.begin() + b;
200 std::vector<MInt>::const_iterator ee = m_mapped.begin() + e;
201
202 return {bb, ee};
203 }
uint32_t MUint
Definition: maiatypes.h:63

◆ insert()

MInt & maia::coupling::Mapping::insert ( const MInt  i)
inline

Definition at line 214 of file surfacecoupling.h.

214 {
215 if(i < MInt(m_offsets.size() - 1)) {
216 // key already exists, but is not the last one
217
218 // if value is -1, set now!
219 if(m_mapped[m_offsets[i]] == -1) {
220 return m_mapped[m_offsets[i]];
221 }
222
223 for(MInt j = i + 1; j < MInt(m_offsets.size()); j++) {
224 m_offsets[j]++;
225 }
226
227 m_mapped.insert(m_mapped.begin() + m_offsets[i + 1] - 1, -1);
228
229 return m_mapped[m_offsets[i + 1] - 1];
230
231 } else if(i == MInt(m_offsets.size() - 1)) {
232 // key already exists and is the last
233
234 m_mapped.push_back(-1);
235
236 return m_mapped[m_mapped.size() - 1];
237
238 } else if(i >= MInt(m_offsets.size())) {
239 // key does not exist yet
240
241 // number of keys to be added
242 // none is mapping onto a value but the last one
243 const MUint noNewKeys = i + 1 - m_offsets.size();
244
245 for(MUint j = 0; j < noNewKeys; j++) {
246 m_offsets.push_back(m_mapped.size());
247 }
248
249 m_mapped.push_back(-1);
250
251 return m_mapped[m_mapped.size() - 1];
252 }
253
254 std::cerr << "Map insert shouldnt reach this case" << std::endl;
255 return m_mapped[m_mapped.size() - 1];
256 }
int32_t MInt
Definition: maiatypes.h:62

◆ operator[]()

range< std::vector< MInt >::const_iterator > maia::coupling::Mapping::operator[] ( const MInt  i) const
inline

Definition at line 258 of file surfacecoupling.h.

258{ return get(i); }
range< std::vector< MInt >::const_iterator > get(const MUint i) const

◆ size()

std::size_t maia::coupling::Mapping::size ( ) const
inline

Definition at line 211 of file surfacecoupling.h.

211{ return m_mapped.size(); }

Member Data Documentation

◆ m_mapped

std::vector<MInt> maia::coupling::Mapping::m_mapped

Definition at line 188 of file surfacecoupling.h.

◆ m_offsets

std::vector<MUint> maia::coupling::Mapping::m_offsets

Definition at line 187 of file surfacecoupling.h.


The documentation for this struct was generated from the following file: