File: graph.h

package info (click to toggle)
esys-particle 2.3.4%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 13,036 kB
  • ctags: 10,805
  • sloc: cpp: 80,009; python: 5,872; makefile: 1,243; sh: 313; perl: 225
file content (126 lines) | stat: -rw-r--r-- 3,563 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/////////////////////////////////////////////////////////////
//                                                         //
// Copyright (c) 2003-2014 by The University of Queensland //
// Centre for Geoscience Computing                         //
// http://earth.uq.edu.au/centre-geoscience-computing      //
//                                                         //
// Primary Business: Brisbane, Queensland, Australia       //
// Licensed under the Open Software License version 3.0    //
// http://www.apache.org/licenses/LICENSE-2.0          //
//                                                         //
/////////////////////////////////////////////////////////////

#ifndef __GRAPH_H
#define __GRAPH_H

// --- project includes ---
#include "Foundation/vec3.h"

// --- STL includes ---
#include <list>
#include <vector>
#include <utility>
#include <map>
#include <iostream>
#include <string>

using std::list;
using std::vector;
using std::pair;
using std::map;
using std::ostream;
using std::endl;
using std::string;

struct pdata{
  int tag;
  double mass;
  Vec3 pos;
  double rad;
  Vec3 vel;
  Vec3 angvel;
  
  pdata(int t=-1,
	double m=0.0,
	Vec3 p=Vec3(0.0,0.0,0.0),
	double r=0.0, 
	Vec3 v=Vec3(0.0,0.0,0.0),
	Vec3 av=Vec3(0.0,0.0,0.0))
    :tag(t),mass(m),pos(p),rad(r),vel(v),angvel(av){};
};

struct pdata2d{
  int gid; // grain id
  Vec3 pos2d; // projected position
  double rad; // radius
};

/*!
  \class Graph
  \brief Graph class, partially based on Sedgewick, "Alg. in C++", progs. 17.1, 17.9 and 17.10

*/
class Graph
{
 public: // types
  struct Edge{
    int i,j;
    Edge(int v=-1,int w=-1):i(v),j(w){}
  };
  
  struct Node{
    int id;
    Node(int i=-1):id(i){};
  };
  typedef list<int>::iterator adjIterator;

 private:
  map<int,list<int> > m_data;
  map<int,int> cid; // component id for conn. component
  map<int,pdata> m_vertex_data;
  map<int,double> m_grain_mass;
  map<int,Vec3> m_grain_rot;
  int ccnt;

  void ccR(int);
  void dfsIter(int);

 public: // methods
  Graph();
  ~Graph();
  int numV() const;
  int numE() const;
  int getGrainID(int) const;
  double getParticleMass(int) const;
  void insert(const Edge&);
  void insert(const pair<int,int>&);
  void setVertexData(int,const pdata&);
  pdata getVertexData(int i) const;
  void remove(const Edge&);
  bool isEdge(int,int);
  void removeDoubles();
  adjIterator IterBegin(int);
  adjIterator IterEnd(int);
  map<int,int>::const_iterator cid_begin() const {return cid.begin();};
  map<int,int>::const_iterator cid_end() const {return cid.end();};
  void makeConnComp();
  void printGrainPCount(ostream&);
  void printGrainMass(ostream&);
  void printIdList(const string&);
  void printRotList(const string&);
  void printGrainCountDist(const string&);
  void printGrainDiamDist(const string&,double,int);
  void printGrainMassDist(const string&,double,int);
  void printSieveDist(const string&,double);
  double getPercentile(double);
  void writeAvgGrainSizeProfile(const string&,double,double,int) ;
  void writeAvgGrainSizeGrid(const string&,double,double,double,double,double,double,double) ;
  void writeMatrixFractionProfile(const string&,double,double,int,double) ;
  void writeMatrixFractionGrid(const string&,double,double,double,double,double,double,double,double) ;
  void printGrainsAsVtk(const string&,double);
  void printAllAsVtk(const string&);
  void printCrossSection(const Vec3&,const Vec3&,const Vec3&,const string&,int,int,double,double,double,double,bool,bool);
  void printGrainCenterPosition(const string&);
};

#endif //__GRAPH_H