Langmuir
Simulation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cubicgrid.h
Go to the documentation of this file.
1 #ifndef CUBICGRID_H
2 #define CUBICGRID_H
3 
4 #include "agent.h"
5 
6 #include <QTextStream>
7 #include <QVector>
8 #include <QString>
9 #include <QObject>
10 #include <QDebug>
11 
12 namespace LangmuirCore
13 {
14 
15 class World;
16 
35 class Grid : public QObject
36 {
37 private:
38  Q_OBJECT
39  Q_DISABLE_COPY(Grid)
40  Q_ENUMS(CubeFace)
41 
42 public:
46  enum CubeFace
47  {
49  Left = 0,
50 
52  Right = 1,
53 
55  Top = 2,
56 
58  Bottom = 3,
59 
61  Front = 4,
62 
64  Back = 5,
65 
67  NoFace = 6
68  };
69  static QString toQString(const Grid::CubeFace e);
70 
76  Grid(World &world, QObject *parent = 0);
77 
81  ~Grid();
82 
86  int xSize();
87 
91  int ySize();
92 
96  int zSize();
97 
101  int xyPlaneArea();
102 
106  int volume();
107 
113  double totalDistance(int site1, int site2);
114 
120  double xDistance(int site1, int site2);
121 
127  double yDistance(int site1, int site2);
128 
134  double zDistance(int site1, int site2);
135 
144  double xImageDistance(int site1, int site2);
145 
154  double yImageDistance(int site1, int site2);
155 
164  double zImageDistance(int site1, int site2);
165 
171  int xDistancei(int site1, int site2);
172 
178  int yDistancei(int site1, int site2);
179 
185  int zDistancei(int site1, int site2);
186 
195  int xImageDistancei(int site1, int site2);
196 
205  int yImageDistancei(int site1, int site2);
206 
215  int zImageDistancei(int site1, int site2);
216 
228  int getIndexS(int xIndex, int yIndex, int zIndex = 0);
229 
237  int getIndexY(int site);
238 
246  int getIndexX(int site);
247 
255  int getIndexZ(int site);
256 
265  double getPositionY(int site);
266 
275  double getPositionX(int site);
276 
285  double getPositionZ(int site);
286 
292  Agent * agentAddress(int site);
293 
299  Agent::Type agentType(int site);
300 
306  void addToPotential(int site, double potential);
307 
313  void setPotential(int site, double potential);
314 
319  double potential(int site);
320 
326  QVector<int> neighborsSite(int site, int hoppingRange = 1);
327 
332  QVector<int> neighborsFace(Grid::CubeFace cubeFace);
333 
343  QVector<int> sliceIndex(int xi, int xf, int yi, int yf, int zi, int zf);
344 
354  void registerAgent(Agent *agent);
355 
364  void registerSpecialAgent(Agent *agent, Grid::CubeFace cubeFace);
365 
370  void unregisterAgent(Agent *agent);
371 
377  void unregisterSpecialAgent(Agent *agent, Grid::CubeFace cubeFace);
378 
383  void unregisterDefect(int site);
384 
389  void registerDefect(int site);
390 
394  int specialAgentCount();
395 
400  QList<Agent *>& getSpecialAgentList(Grid::CubeFace cubeFace);
401 
402 protected:
407 
415  QVector<Agent *> m_agents;
416 
423  QVector<double> m_potentials;
424 
432  QVector<Agent::Type> m_agentType;
433 
437  QList< QList<Agent *> > m_specialAgents;
438 
443 
448 
452  int m_xSize;
453 
457  int m_ySize;
458 
462  int m_zSize;
463 
468 
473 
478 
482  int m_volume;
483 };
484 
488 QTextStream &operator<<(QTextStream &stream,const Grid::CubeFace e);
489 
493 QDebug operator<<(QDebug dbg,const Grid::CubeFace e);
494 
495 }
496 #endif
x = 0, yz plane
Definition: cubicgrid.h:49
QList< QList< Agent * > > m_specialAgents
A list of lists of special agents, where each sub-list is for a different Grid::CubeFace.
Definition: cubicgrid.h:437
int m_xzPlaneArea
The number of sites in the xz-plane.
Definition: cubicgrid.h:477
double xImageDistance(int site1, int site2)
Get the image distance along the x-direction between two sites.
QVector< int > neighborsSite(int site, int hoppingRange=1)
Calculate the neighboring sites of a given site.
int zSize()
Get the number of sites along the z-direction.
int ySize()
Get the number of sites along the y-direction.
int m_ySize
The number of sites along the y-direction.
Definition: cubicgrid.h:457
double getPositionY(int site)
Get the y-position from the "s-site ID".
int yImageDistancei(int site1, int site2)
Get the integer image distance along the y-direction between two sites.
double getPositionX(int site)
Get the x-position from the "s-site ID".
void unregisterAgent(Agent *agent)
Remove an Agent from the Grid.
void unregisterDefect(int site)
Remove a defect from the Grid.
Agent * agentAddress(int site)
Get a pointer to the Agent at a site.
A class that abstractly represents an object that can occupy grid sites.
Definition: agent.h:24
static QString toQString(const Grid::CubeFace e)
void registerAgent(Agent *agent)
Assign an Agent to a site in the Grid.
QVector< double > m_potentials
1D list of site potentials, the size of which is the volume of the Grid + the max number of special A...
Definition: cubicgrid.h:423
int m_specialAgentCount
The current number of special Agents registered with the Grid.
Definition: cubicgrid.h:447
x = lx, yz plane
Definition: cubicgrid.h:52
QTextStream & operator<<(QTextStream &stream, const Agent::Type e)
Output Agent type enum to stream.
Definition: agent.h:172
int getIndexX(int site)
Get the "x-site ID" from the "s-site ID".
A class to hold Agents, calculate their positions, and store the background potential.
Definition: cubicgrid.h:35
int m_specialAgentReserve
The max number of special Agents allowed.
Definition: cubicgrid.h:442
int yDistancei(int site1, int site2)
Get the integer distance along the y-direction between two sites.
Type
An identifier for the type of Agent.
Definition: agent.h:33
int getIndexY(int site)
Get the "y-site ID" from the "s-site ID".
QVector< Agent::Type > m_agentType
1D list of Agent types, the size of which is the volume of the Grid + the max number of special Agent...
Definition: cubicgrid.h:432
double yImageDistance(int site1, int site2)
Get the image distance along the y-direction between two sites.
QVector< int > neighborsFace(Grid::CubeFace cubeFace)
Calculate the neighboring sites of a given face of the Grid.
Agent::Type agentType(int site)
Get the type of Agent at a site.
int m_yzPlaneArea
The number of sites in the yz-plane.
Definition: cubicgrid.h:472
void registerSpecialAgent(Agent *agent, Grid::CubeFace cubeFace)
Assign an Agent to a special location.
A class to hold all objects in a simulation.
Definition: world.h:51
void setPotential(int site, double potential)
Set the background potential at a site to some value.
int xImageDistancei(int site1, int site2)
Get the integer image distance along the x-direction between two sites.
double zImageDistance(int site1, int site2)
Get the image distance along the z-direction between two sites.
int m_xSize
The number of sites along the x-direction.
Definition: cubicgrid.h:452
int zDistancei(int site1, int site2)
Get the integer distance along the z-direction between two sites.
z = lz, xy plane
Definition: cubicgrid.h:58
int m_volume
The total number of sites.
Definition: cubicgrid.h:482
Grid(World &world, QObject *parent=0)
Create a grid.
double totalDistance(int site1, int site2)
Get the distance between two sites.
int getIndexS(int xIndex, int yIndex, int zIndex=0)
Get the serial site ID.
int xSize()
Get the number of sites along the x-direction.
void unregisterSpecialAgent(Agent *agent, Grid::CubeFace cubeFace)
Remove an Agent from the special list of Agents in the Grid.
y = 0, xz plane
Definition: cubicgrid.h:61
double potential(int site)
Get the background potential at some site.
double yDistance(int site1, int site2)
Get the distance along the y-direction between two sites.
QVector< int > sliceIndex(int xi, int xf, int yi, int yf, int zi, int zf)
Calculate the list of sites occupying a given range.
double getPositionZ(int site)
Get the z-position from the "s-site ID".
~Grid()
Destroy the grid.
int volume()
Get the total number of sites.
y = ly, xz plane
Definition: cubicgrid.h:64
Definition: agent.h:12
int specialAgentCount()
The total number of special Agents.
World & m_world
Reference to the World object.
Definition: cubicgrid.h:406
int m_xyPlaneArea
The number of sites in the xy-plane.
Definition: cubicgrid.h:467
void registerDefect(int site)
Assign a site to be Agent::Defect.
QList< Agent * > & getSpecialAgentList(Grid::CubeFace cubeFace)
Get a list of special Agents assigned to a specific Grid::CubeFace.
undefined face
Definition: cubicgrid.h:67
QVector< Agent * > m_agents
1D list of Agent pointers, the size of which is the volume of the Grid + the max number of special Ag...
Definition: cubicgrid.h:415
int getIndexZ(int site)
Get the "z-site ID" from the "s-site ID".
CubeFace
A way to indicate the faces of a cube.
Definition: cubicgrid.h:46
int xyPlaneArea()
Get the number of sites in the xy-plane.
z = 0, xy plane
Definition: cubicgrid.h:55
double zDistance(int site1, int site2)
Get the distance along the z-direction between two sites.
double xDistance(int site1, int site2)
Get the distance along the x-direction between two sites.
int m_zSize
The number of sites along the z-direction.
Definition: cubicgrid.h:462
int zImageDistancei(int site1, int site2)
Get the integer image distance along the z-direction between two sites.
void addToPotential(int site, double potential)
Add some value to the background potential at a site.
int xDistancei(int site1, int site2)
Get the integer distance along the x-direction between two sites.