Permalink
Browse files

Initial port

  • Loading branch information...
dxli committed Jul 8, 2011
0 parents commit 8550067b87d75c317b875b3d594b76c3c7be65eb
Showing with 881 additions and 0 deletions.
  1. +25 −0 CMakeLists.txt
  2. +21 −0 FindGrace.cmake
  3. +4 −0 README
  4. +63 −0 atom.cpp
  5. +29 −0 atom.h
  6. +28 −0 fortune.cpp
  7. +28 −0 fortune.h
  8. +494 −0 layer.cpp
  9. +61 −0 layer.h
  10. +20 −0 mkRandom.cpp
  11. +12 −0 mkRandom.h
  12. +49 −0 mps0.cpp
  13. +25 −0 myGrace.cpp
  14. +18 −0 myGrace.h
  15. +4 −0 parameters.h
@@ -0,0 +1,25 @@
+cmake_minimum_required(VERSION 2.6)
+project(mps)
+
+#There are lots of scripts with cmake
+#for finding external libraries.
+#see /usr/local/share/cmake-2.6/Modules/Find*.cmake for more examples
+#find_package(GLUT)
+#find_package(OpenGL)
+set(CMAKE_MODULE_PATH ".")
+find_package(Grace)
+set(CORELIBS ${GRACE_LIBRARY})
+add_library(myGrace myGrace.cpp)
+add_library(mkRandom mkRandom.cpp)
+add_library(atom atom.cpp)
+add_library(layer layer.cpp)
+set(CORELIBS ${CORELIBS} myGrace mkRandom atom layer)
+
+
+set(CMAKE_CXX_FLAGS "-g -O0 -march=native -fomit-frame-pointer -Wall")
+set(PROGRAMS mps0)
+foreach(program ${PROGRAMS})
+ add_executable(${program} ${program}.cpp)
+ target_link_libraries(${program} ${CORELIBS} ${GRACE_LIBRARY} myGrace mkRandom atom layer)
+endforeach(program)
+
@@ -0,0 +1,21 @@
+FIND_PATH(GRACE_INCLUDE_DIR grace_np.h /usr/include/ /usr/local/include)
+
+FIND_LIBRARY(GRACE_LIBRARY NAMES grace_np PATH /usr/lib /usr/local/lib)
+
+IF (GRACE_INCLUDE_DIR AND GRACE_LIBRARY)
+ SET(GRACE_FOUND TRUE)
+INCLUDE_DIRECTORIES( ${GRACE_INCLUDE_DIR} )
+SET(optionalLibs ${optionalLibs} ${GRACE_LIBRARY})
+ENDIF (GRACE_INCLUDE_DIR AND GRACE_LIBRARY)
+
+
+IF (GRACE_FOUND)
+ IF (NOT Grace_FIND_QUIETLY)
+ MESSAGE(STATUS "Found Grace: ${GRACE_LIBRARY}")
+ ENDIF (NOT Grace_FIND_QUIETLY)
+ELSE (GRACE_FOUND)
+ IF (Grace_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find Grace")
+ ENDIF (Grace_FIND_REQUIRED)
+ENDIF (GRACE_FOUND)
+
4 README
@@ -0,0 +1,4 @@
+construct Voronoi Cells from points within a periodic two dimensional cell (flat torus)
+to build,
+ cmake .
+ make
@@ -0,0 +1,63 @@
+#include<iostream>
+#include"atom.h"
+
+atom::atom(double x0,double y0) {
+ xi=x0;
+ yi=y0;
+}
+atom::atom(void){
+}
+ostream& operator << (ostream& os, atom a0) {
+ // Output the atom position to the stream in the format n/d
+ os <<'('<<a0.xi<<','<<a0.yi<<')';
+ return os;
+}
+
+rxy::rxy(void){
+}
+rxy::rxy(double x0,double y0) {
+ x=x0;
+ y=y0;
+ }
+
+rxy::rxy(vector<atom>::iterator a0) {
+ x=a0->xi;
+ y=a0->yi;
+ }
+
+rxy::rxy(double a0) {
+ x=cos(a0);
+ y=sin(a0);
+ }
+
+double operator * (rxy a0, rxy a1) {
+ return( a0.x * a1.x + a0.y*a1.y);
+}
+
+rxy operator / (rxy a0, int n0) {
+ return( rxy(a0.x /n0 , a0.y / n0));
+}
+rxy operator /= (rxy &a0, int n0) {
+ a0.x /= n0;
+ a0.y /= n0;
+ return( a0);
+}
+rxy operator * (double q0, rxy a0) {
+ return( rxy(a0.x *q0 , a0.y * q0));
+}
+
+rxy operator += (rxy &a0, rxy a1) {
+ a0.x += a1.x;
+ a0.y += a1.y;
+ return(a0);
+}
+
+double rxy::abs2()
+{
+ return( this->x* this->x + this->y * this->y);
+}
+
+double det(rxy a0, rxy a1) {
+//determinant
+ return(a0.x*a1.y-a1.x*a0.y);
+}
29 atom.h
@@ -0,0 +1,29 @@
+#pragma once
+#include<iostream>
+#include<fstream>
+#include<cmath>
+#include<vector>
+#include<iterator>
+#include<algorithm>
+using namespace std;
+
+class atom {
+public:
+ double xi,yi;
+ atom(double,double);
+ atom(void);
+};
+
+class rxy
+// the 2D complex class
+{
+public:
+ double x,y;
+ rxy(double,double);
+ rxy(double );
+ rxy(vector<atom> ::iterator );
+ rxy(void);
+ double abs2();
+};
+
+double det(rxy ,rxy );
@@ -0,0 +1,28 @@
+#include "fortune.h"
+
+RayP::RayP(int i){
+ site=i;
+ nb_L=-1;
+ nb_R=-1;
+ pnb_L=NULL;
+ pnb_R=NULL;
+ p3nb_L=NULL;
+ p3nb_R=NULL;
+}
+
+short int RayP::compare(int){
+ double yl;
+ if ( pnb_L != NULL ) {
+
+}
+}
+
+BeachLine::BeachLine(void){
+ Broot=NULL;
+ size=0;
+}
+
+BeachLine::BeachLine(int i){
+ Broot= &(RayP(i));
+ size=1;
+}
@@ -0,0 +1,28 @@
+#pragma once
+#include"layer.h"
+using namespace std;
+
+class RayP{
+ public:
+ int site;
+ int nb_L,nb_R;
+ RayP *pnb_L,*pnb_R, *p3nb_L,*p3nb_R;
+ RayP(int, int, int);
+ double x3();
+ short int compare_y(int);
+};
+class BeachLine{
+ public:
+ RayP *Broot;
+ int size;
+ BeachLine(void);
+ BeachLine(int);
+ void add(int);
+ void remove(RayP);
+
+};
+class ThreeSiteTree {
+ public:
+ RayP *root;
+};
+
Oops, something went wrong.

0 comments on commit 8550067

Please sign in to comment.