IFEM  90A354
TopologySet.h
Go to the documentation of this file.
1 // $Id$
2 //==============================================================================
12 //==============================================================================
13 
14 #ifndef _TOPOLOGY_SET_H
15 #define _TOPOLOGY_SET_H
16 
17 #include <cstdlib>
18 #include <iostream>
19 #include <string>
20 #include <set>
21 #include <map>
22 
23 
28 struct TopItem
29 {
30  size_t patch;
31  short int item;
32  short int idim;
33 
38  TopItem(size_t p = 0, short int i = 0, short int d = 0)
39  : patch(p), item(i), idim(d) {}
40 
42  friend bool operator<(const TopItem& a, const TopItem& b)
43  {
44  if (abs(a.idim) < abs(b.idim))
45  return true;
46  else if (abs(a.idim) > abs(b.idim))
47  return false;
48  else if (a.patch < b.patch)
49  return true;
50  else if (a.patch > b.patch)
51  return false;
52 
53  return a.item < b.item;
54  }
55 
57  friend std::ostream& operator<<(std::ostream& os, const TopItem& top)
58  {
59  return os <<" ("<< top.patch <<","<< top.item <<","<< top.idim <<"D)";
60  }
61 };
62 
63 typedef std::set<TopItem> TopEntity;
64 
65 typedef std::map<std::string,TopEntity> TopologySet;
66 
67 #endif
std::map< std::string, TopEntity > TopologySet
Named topology sets.
Definition: TopologySet.h:65
std::set< TopItem > TopEntity
Items defining a topological entity.
Definition: TopologySet.h:63
Struct for representing a topological item.
Definition: TopologySet.h:29
TopItem(size_t p=0, short int i=0, short int d=0)
Default constructor.
Definition: TopologySet.h:38
size_t patch
Patch index (one-based)
Definition: TopologySet.h:30
friend bool operator<(const TopItem &a, const TopItem &b)
The less-than operator defining the ordering of topological items.
Definition: TopologySet.h:42
friend std::ostream & operator<<(std::ostream &os, const TopItem &top)
Output stream operator.
Definition: TopologySet.h:57
short int item
Local item index within the patch (one-based)
Definition: TopologySet.h:31
short int idim
Dimension on the local item [-3,3].
Definition: TopologySet.h:32