From 546ca80d015a6eb7e5a3aac522bdca4a532e536f Mon Sep 17 00:00:00 2001 From: chr Date: Sat, 25 Apr 2015 12:58:39 +0000 Subject: [PATCH] L-shape calculation added. git-svn-id: https://codeforge.lbl.gov/anonscm/voro@581 6221c96e-593b-4ce1-a500-64c4038a1943 --- trunk/examples/extra/Makefile | 5 ++- trunk/examples/extra/l_shape.cc | 69 ++++++++++++++++++++++++++++++++++++ trunk/examples/timing/timing_test.cc | 2 +- trunk/examples/timing/timing_test.pl | 4 +-- trunk/src/cell.cc | 27 +++++++------- 5 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 trunk/examples/extra/l_shape.cc diff --git a/trunk/examples/extra/Makefile b/trunk/examples/extra/Makefile index 89e6517..529a71c 100644 --- a/trunk/examples/extra/Makefile +++ b/trunk/examples/extra/Makefile @@ -8,7 +8,7 @@ include ../../config.mk # List of executables -EXECUTABLES=box_cut cut_region superellipsoid irregular +EXECUTABLES=box_cut cut_region superellipsoid irregular l_shape # Makefile rules all: $(EXECUTABLES) @@ -25,6 +25,9 @@ superellipsoid: superellipsoid.cc irregular: irregular.cc $(CXX) $(CFLAGS) $(E_INC) $(E_LIB) -o irregular irregular.cc -lvoro++ +l_shape: l_shape.cc + $(CXX) $(CFLAGS) $(E_INC) $(E_LIB) -o l_shape l_shape.cc -lvoro++ + finite_sys: finite_sys.cc $(CXX) $(CFLAGS) $(E_INC) $(E_LIB) -o finite_sys finite_sys.cc -lvoro++ diff --git a/trunk/examples/extra/l_shape.cc b/trunk/examples/extra/l_shape.cc new file mode 100644 index 0000000..69485a0 --- /dev/null +++ b/trunk/examples/extra/l_shape.cc @@ -0,0 +1,69 @@ +// Irregular packing example code +// +// Author : Chris H. Rycroft (LBL / UC Berkeley) +// Email : chr@alum.mit.edu +// Date : August 30th 2011 + +#include "voro++.hh" +using namespace voro; + +// Set the number of particles that are going to be randomly introduced +const int particles=30; + +// This function returns a random double between 0 and 1 +double rnd() {return double(rand())/RAND_MAX;} + +// Create a wall class that, whenever called, will replace the Voronoi cell +// with a prescribed shape, in this case a dodecahedron +class wall_l_shape : public wall { + public: + wall_l_shape() { + v.init_l_shape(); + }; + bool point_inside(double x,double y,double z) {return true;} + bool cut_cell(voronoicell &c,double x,double y,double z) { + + // Set the cell to be equal to the dodecahedron + c=v; + c.translate(-x,-y,-z); + c.big_tol=100; + return true; + } + bool cut_cell(voronoicell_neighbor &c,double x,double y,double z) { + + // Set the cell to be equal to the dodecahedron + c=v; + c.translate(-x,-y,-z); + c.big_tol=100; + return true; + } + private: + voronoicell v; +}; + +int main() { + int i=0; + double x,y,z; + + // Create a container with the geometry given above. This is bigger + // than the particle packing itself. + container con(-1,1,-1,1,-1,1,5,5,5,false,false,false,8); + + // Create the L-shape wall class and add it to the container + wall_l_shape(wls); + con.add_wall(wls); + + // Import the irregular particle packing + while(i0) continue; + z=2*rnd()-1; + con.put(i,x,y,z); + i++; + } + + // Save the particles and Voronoi cells in POV-Ray format + con.draw_particles("l_shape_p.gnu"); + con.draw_cells_gnuplot("l_shape_v.gnu"); +} diff --git a/trunk/examples/timing/timing_test.cc b/trunk/examples/timing/timing_test.cc index d889a24..f3dedd7 100644 --- a/trunk/examples/timing/timing_test.cc +++ b/trunk/examples/timing/timing_test.cc @@ -7,7 +7,7 @@ #include using namespace std; -#include "voro++.hh" +#include "voro++.cc" using namespace voro; // Set up constants for the container geometry diff --git a/trunk/examples/timing/timing_test.pl b/trunk/examples/timing/timing_test.pl index f1ff487..85817d9 100644 --- a/trunk/examples/timing/timing_test.pl +++ b/trunk/examples/timing/timing_test.pl @@ -14,8 +14,8 @@ $opt="-O3"; foreach $r (@range) { # Compile the code with the current grid size - system "g++ $opt -I../../src -DNNN=$r -o timing_test " - ."-L../../src timing_test.cc -lvoro++"; + system "g++-mp-4.8 $opt -I../../src -DNNN=$r -o timing_test " + ."-L../../src timing_test.cc"; # Carry out the trials for this grid size $st=$stt=0; diff --git a/trunk/src/cell.cc b/trunk/src/cell.cc index f480912..2223626 100644 --- a/trunk/src/cell.cc +++ b/trunk/src/cell.cc @@ -112,7 +112,7 @@ void voronoicell_base::translate(double x,double y,double z) { x*=2;y*=2;z*=2; double *ptsp=pts; while(ptsp