GPUE  v1.0
GPU Gross-Pitaevskii Equation numerical solver for Bose-Einstein condensates
edge.cu
Go to the documentation of this file.
1 
2 //######################################################################################################################
3 
4 #include "../include/edge.h"
5 #include <memory>
6 #include <iostream>
7 
8 using namespace LatticeGraph;
9 
10 //######################################################################################################################
11 //#################################### Ceiling Cat & Basement Cat ###############################################
12 //######################################################################################################################
13 
14 Edge::~Edge(){
15 }
16 
17 Edge::Edge() : uid(++suid){
18 }
19 
20 Edge::Edge(std::weak_ptr<Node> n1, std::weak_ptr<Node> n2) : uid(++suid){
21  this->n1 = n1;
22  this->n2 = n2;
23  this->direction = 0;
24  this->weight = 0;
25 }
26 
27 Edge::Edge(std::weak_ptr<Node> n1, std::weak_ptr<Node> n2, int dir, double weight) : uid(++suid){
28  this->n1 = n1;
29  this->n2 = n2;
30  this->direction = dir;
31  this->weight = weight;
32 }
33 
34 //######################################################################################################################
35 //#################################### Get stuff ###############################################
36 //######################################################################################################################
37 
38 /***
39  * Returns UID of Edge.
40  */
41 unsigned int Edge::getUid(){
42  return uid;
43 }
44 
45 /***
46  * Returns direction of Edge.
47  */
48 int Edge::getDirection(){
49  return this->direction;
50 }
51 /***
52  * Get Node at index idx.
53  */
54 std::weak_ptr<Node> Edge::getVortex(int idx){
55  try{
56  return (idx==0) ? n1 : n2;
57  }
58  catch(std::exception e){
59  return std::weak_ptr<Node>();
60  }
61 }
62 
63 /***
64  * Get weight of edge.
65  */
66 double Edge::getWeight(){
67  return this->weight;
68 }
69 
70 //######################################################################################################################
71 //#################################### Set stuff ###############################################
72 //######################################################################################################################
73 
74 /***
75  * Sets Edge direction for a directed graph.
76  */
77 void Edge::setDirection(int direction){
78  this->direction = direction;
79 }
80 /***
81  * Sets Edge weight between nodes.
82  */
83 void Edge::setWeight(double weight){
84  this->weight = weight;
85 }
86 
87 //######################################################################################################################
88 //#################################### Update stuff ###############################################
89 //######################################################################################################################
90 
91 /***
92  * Replaces Node n1 or n2 with new Node n_new.
93  */
94 void Edge::updateVortex(int idx, std::weak_ptr<Node> n_new ){
95  if(idx>0){
96  this->n1 = n_new;
97  }
98  else{
99  this->n2 = n_new;
100  }
101 }
102 
103 //######################################################################################################################
104 //#################################### Check stuff ###############################################
105 //######################################################################################################################
106 
107 bool Edge::isMember(std::weak_ptr<Node> n){
108  return ( this->n1.lock()->getUid() == n.lock()->getUid() || this->n2.lock()->getUid() == n.lock()->getUid() ) ? true : false;
109 }
110 
111 //######################################################################################################################