GPUE  v1.0
GPU Gross-Pitaevskii Equation numerical solver for Bose-Einstein condensates
vort.h
Go to the documentation of this file.
1 //##############################################################################
15  //#############################################################################
16 
17 #ifndef GPUE_1_VORT_H
18 #define GPUE_1_VORT_H
19 
20 #include <memory>
21 #include <vector>
22 #include <cuda.h>
23 #include <cuda_runtime.h>
24 #include <limits>
25 #include <cmath>
26 
27 #include<iostream>
28 #include <algorithm>
29 #include <set>
30 #include <utility> // std::pair, std::make_pair
31 
32 //@todo Convert the GPUE codebase to use the newly implemented Vortex and VtxList classes. Simplify graph codebase
33 namespace Vtx {
34 
39  class Vortex {
40  friend class VtxList;
41  private:
42  int2 coords;
43  double2 coordsD;
44  int winding;
45  bool isOn;
46  std::size_t timeStep;
47 
48  protected:
49  int uid;
50 
51  public:
52  Vortex();
53  Vortex(int2 coords, double2 coordsD, int winding, bool isOn, std::size_t timeStep);
54 
55  ~Vortex();
56 
57  void updateUID(int uid);
58  void updateWinding(int winding);
59  void updateIsOn(bool isOn);
60  void updateCoords(int2 coords);
61  void updateCoordsD(double2 coordsD);
62  void updateTimeStep(std::size_t timeStep);
63 
64  int getUID() const;
65  int getWinding() const;
66  bool getIsOn() const;
67  int2 getCoords() const;
68  double2 getCoordsD() const;
69  std::size_t getTimeStep() const;
70  };
71 
72 
73 // Adding block comments in the least intuitive way because of doxygen comments
74 //##############################################################################
78  class VtxList {
79  private:
80  std::vector< std::shared_ptr<Vtx::Vortex> > vortices;
81  std::size_t suid; //value of max UID. Used to allow for independent UIDs upon creation.
82  public:
83  VtxList(); //Initialise suid when creating the list
84  VtxList(std::size_t reserveSize);//If size is known in advance, reserve the required num of elements
85  ~VtxList(); //Remove all shared_ptr values
86 
92  void addVtx(std::shared_ptr<Vtx::Vortex> vtx);
93  void addVtx(std::shared_ptr<Vtx::Vortex> vtx, std::size_t idx);
94 
100  std::shared_ptr<Vortex> removeVtx(std::size_t idx);
101 
107  std::vector< std::shared_ptr<Vortex> > &getVortices();
108 
114  std::shared_ptr<Vortex> getVtx_Uid(int uid);
115 
121  std::shared_ptr<Vortex> getVtx_Idx(std::size_t idx);
122 
128  std::size_t getVtxIdx_Uid(int uid);
129 
135  std::size_t& getMax_Uid();
136 
142  std::shared_ptr<Vortex> getVtxMinDist(std::shared_ptr<Vortex> vtx);
143 
150  void swapUid(std::shared_ptr<Vortex> v1, std::shared_ptr<Vortex> v2);
157  void swapUid_Idx(std::size_t idx0, std::size_t idx1);
158 
163  void vortOff();
164 
170  void sortVtxUID();
171 
177  void arrangeVtx(std::vector<std::shared_ptr<Vortex> > &vPrev);
178 
179 
180  void setUIDs(std::set<std::shared_ptr<Vtx::Vortex> > &v);
181 
182 
183  std::pair<double,std::shared_ptr<Vortex> > minDistPair(std::shared_ptr<Vortex> vtx, double minRange);
184 
185 
186  };
187 };
188 //##############################################################################
189 #endif //GPUE_1_VORT_H
void sortVtxUID()
Sorts the vortices based on UID, from low to high.
int getUID() const
std::size_t & getMax_Uid()
Returns the largest UID given.
int2 getCoords() const
std::pair< double, std::shared_ptr< Vortex > > minDistPair(std::shared_ptr< Vortex > vtx, double minRange)
vtxLost idx
Definition: loadVtx.m:15
double2 getCoordsD() const
std::shared_ptr< Vortex > getVtx_Idx(std::size_t idx)
Returns a shared_ptr to the vortex by an index in VtxList.
void updateTimeStep(std::size_t timeStep)
% set(gca, 'Color', [0 0 0])
std::shared_ptr< Vortex > getVtxMinDist(std::shared_ptr< Vortex > vtx)
Returns index of vortex with shortest coordinate distance from current vortex.
void arrangeVtx(std::vector< std::shared_ptr< Vortex > > &vPrev)
Arrange the vortices to have correct UID corresponding across timesteps.
void updateCoordsD(double2 coordsD)
void swapUid(std::shared_ptr< Vortex > v1, std::shared_ptr< Vortex > v2)
In-place swap of the UID for the two given vortices.
isOn
Definition: vort.py:43
void vortOff()
Turns vortex activation off. Useful if vortex no longer exists in condensate.
bool getIsOn() const
void swapUid_Idx(std::size_t idx0, std::size_t idx1)
In-place swap of the UID for the two given vortices.
vtx
Definition: VtxCorr.m:32
Definition: vort.h:33
std::size_t getVtxIdx_Uid(int uid)
Returns a vortex index based upon a given vortex UID.
void updateIsOn(bool isOn)
std::vector< std::shared_ptr< Vortex > > & getVortices()
Returns a reference to the vortex list.
std::shared_ptr< Vortex > getVtx_Uid(int uid)
Returns a shared_ptr to the vortex by a UID.
void setUIDs(std::set< std::shared_ptr< Vtx::Vortex > > &v)
uid
Definition: vort.py:39
void addVtx(std::shared_ptr< Vtx::Vortex > vtx)
Adds a vortex to the list.
std::size_t getTimeStep() const
void updateCoords(int2 coords)
void updateUID(int uid)
std::shared_ptr< Vortex > removeVtx(std::size_t idx)
Remove a vortex at position idx.
void updateWinding(int winding)
int uid
Definition: vort.h:49
int getWinding() const