~ubuntu-branches/ubuntu/quantal/python-demgengeo/quantal

« back to all changes in this revision

Viewing changes to src/MNTable2D.h

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2011-11-18 21:47:18 UTC
  • Revision ID: package-import@ubuntu.com-20111118214718-4ysqm3dhpqwdd7gd
Tags: upstream-0.99~bzr106
ImportĀ upstreamĀ versionĀ 0.99~bzr106

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////
 
2
//                                                         //
 
3
// Copyright (c) 2007-2011 by The University of Queensland //
 
4
// Earth Systems Science Computational Centre (ESSCC)      //
 
5
// http://www.uq.edu.au/esscc                              //
 
6
//                                                         //
 
7
// Primary Business: Brisbane, Queensland, Australia       //
 
8
// Licensed under the Open Software License version 3.0    //
 
9
// http://www.opensource.org/licenses/osl-3.0.php          //
 
10
//                                                         //
 
11
/////////////////////////////////////////////////////////////
 
12
 
 
13
#ifndef __MNTABLE_H
 
14
#define __MNTABLE_H
 
15
 
 
16
// --- STL includes ---
 
17
#include <boost/python.hpp>
 
18
#include <vector>
 
19
#include <map>
 
20
#include <set>
 
21
 
 
22
using std::vector;
 
23
using std::map;
 
24
using std::multimap;
 
25
using std::set;
 
26
 
 
27
// --- IO includes ---
 
28
#include <iostream>
 
29
 
 
30
using std::ostream;
 
31
 
 
32
// --- Project includes ---
 
33
#include "MNTCell.h"
 
34
#include "Sphere.h"
 
35
#include "Line2D.h"
 
36
#include "LineSegment2D.h"
 
37
 
 
38
/*!
 
39
  \class MNTable2D
 
40
  \brief Multi-group Neighbour table
 
41
 
 
42
  Neighbour table supporting multiple tagged groups of particles
 
43
*/
 
44
class MNTable2D
 
45
{
 
46
 public: // types
 
47
  typedef pair<int,int> bond;
 
48
 
 
49
 protected:
 
50
  MNTCell* m_data;
 
51
  map<int,set<pair<int,int> > > m_bonds; 
 
52
  double m_x0,m_y0; //!< origin
 
53
  double m_celldim; //!< cell size
 
54
  int m_nx,m_ny; //!< number of cells in x- and y-direction
 
55
  unsigned int m_ngroups;
 
56
  static int s_output_style; 
 
57
  static double s_small_value;
 
58
  int m_x_periodic;
 
59
  int m_y_periodic;
 
60
  
 
61
  virtual int getIndex(const Vector3&) const;
 
62
  inline int idx(int i,int j) const {return i*m_ny+j;};
 
63
  void WriteAsVtkXml(ostream&) const;
 
64
 
 
65
 public:
 
66
  MNTable2D();
 
67
  MNTable2D(const Vector3&,const Vector3&,double,unsigned int);
 
68
  virtual ~MNTable2D();
 
69
 
 
70
  virtual bool insert(const Sphere&,unsigned int);
 
71
  virtual bool insertChecked(const Sphere&,unsigned int,double tol=s_small_value);
 
72
  virtual bool checkInsertable(const Sphere&,unsigned int);
 
73
  void GrowNGroups(unsigned int);
 
74
  const multimap<double,const Sphere*> getSpheresClosestTo(const Vector3&,unsigned int) const;
 
75
  const multimap<double,const Sphere*> getSpheresFromGroupNear(const Vector3&,double,int) const;
 
76
  const vector<const Sphere*> getAllSpheresFromGroup(int) const;
 
77
  const Sphere* getClosestSphereFromGroup(const Sphere&,int) const;
 
78
  Sphere* getClosestSphereFromGroup(const Vector3&,int) const;
 
79
  int getTagOfClosestSphereFromGroup(const Sphere&,int) const;
 
80
  void tagParticlesAlongLine(const Line2D&,double,int,unsigned int);
 
81
  void tagParticlesAlongLineWithMask(const Line2D&,double,int,int, unsigned int);
 
82
  void tagParticlesAlongLineSegment(const LineSegment2D&,double,int,int, unsigned int);
 
83
  void tagParticlesNear(const Vector3&,double,int,int);
 
84
  void tagClosestParticle(const Vector3&,int,int);
 
85
  void tagParticlesToClosest(int,int);
 
86
  void tagParticlesInVolume(const AVolume&,int,unsigned int);
 
87
 
 
88
  boost::python::list getSphereListFromGroup(int) const;
 
89
 
 
90
  virtual void generateBonds(int,double,int);
 
91
  virtual void generateBondsWithMask(int,double,int,int,int);
 
92
  virtual void generateRandomBonds(int,double,double,int,int,int);
 
93
  virtual void generateClusterBonds(int,double,int,int);
 
94
  void insertBond(int,int,int);
 
95
  void breakBondsAlongLineSegment(const LineSegment2D&,double,int, unsigned int);
 
96
 
 
97
  void removeTagged(int,int,int);
 
98
 
 
99
  // output 
 
100
  double getSumVolume(int);
 
101
  int getNrParticles(int);
 
102
  friend ostream& operator << (ostream&,const MNTable2D&);
 
103
  static void SetOutputStyle(int);
 
104
  void write(char *filename, int outputStyle);
 
105
};
 
106
#endif // __MNTABLE_H