From 8e2d8c0bdbfe4951633461a0f56ec4737b06bdd9 Mon Sep 17 00:00:00 2001 From: chr Date: Wed, 27 May 2015 03:46:23 +0000 Subject: [PATCH] Minkowski test code. git-svn-id: https://codeforge.lbl.gov/anonscm/voro@586 6221c96e-593b-4ce1-a500-64c4038a1943 --- trunk/examples/basic/convex_test.cc | 6 ++-- trunk/examples/basic/platonic.cc | 6 ++++ trunk/examples/no_release/Makefile | 2 +- trunk/examples/no_release/minkowski.cc | 57 ++++++++++++++++++++++++++++++++++ trunk/src/cell.cc | 12 +------ 5 files changed, 68 insertions(+), 15 deletions(-) create mode 100644 trunk/examples/no_release/minkowski.cc diff --git a/trunk/examples/basic/convex_test.cc b/trunk/examples/basic/convex_test.cc index 601368e..6dee3fd 100644 --- a/trunk/examples/basic/convex_test.cc +++ b/trunk/examples/basic/convex_test.cc @@ -16,8 +16,8 @@ int main() { v.init_l_shape(); v.draw_gnuplot(0,0,0,"single_cell.gnu"); - int lp,ls; - double l,u; + int lp=-1,ls=-1; + double l=1e-20,u=1e-20; //bool suc=v.search_upward(-1,3,0,0.5,lp,ls,l,u); v.plane(-1,3,0,0.5); v.draw_gnuplot(0,0,0,"single_cell2.gnu"); @@ -28,7 +28,7 @@ int main() { v.check_duplicates(); puts("fi"); // v.plane(-1,3,-0.2,0.54); -bool suc=true; + bool suc=true; printf("%s lp=%d ls=%d l=%g u=%g up=%d\n",suc?"True":"False",lp,ls,l,u,v.up); diff --git a/trunk/examples/basic/platonic.cc b/trunk/examples/basic/platonic.cc index 76dade5..48387f8 100644 --- a/trunk/examples/basic/platonic.cc +++ b/trunk/examples/basic/platonic.cc @@ -21,12 +21,18 @@ int main() { v.plane(-1,1,-1); v.plane(-1,-1,1); v.draw_gnuplot(0,0,0,"tetrahedron.gnu"); + double r,ar,vo; + for(r=0;r<=3;r+=0.02) { + v.minkowski(r,ar,vo); + printf("%g %g %g HO\n",r,ar,vo); + } // Create a cube. Since this is the default shape // we don't need to do any plane cutting. v.init(-1,1,-1,1,-1,1); v.draw_gnuplot(0,0,0,"cube.gnu"); + // Create an octahedron v.init(-2,2,-2,2,-2,2); v.plane(1,1,1); diff --git a/trunk/examples/no_release/Makefile b/trunk/examples/no_release/Makefile index deb342a..5518335 100644 --- a/trunk/examples/no_release/Makefile +++ b/trunk/examples/no_release/Makefile @@ -8,7 +8,7 @@ include ../../config.mk # List of executables -EXECUTABLES=rad_test finite_sys cylinder_inv single_cell_2d period sphere_mesh lloyd_box import_rahman import_nguyen polycrystal_rahman random_points_10 random_points_200 import_freeman voro_lf split_cell ghost_test neigh_test tri_mesh sphere r_pts_interface +EXECUTABLES=rad_test finite_sys cylinder_inv single_cell_2d period sphere_mesh lloyd_box import_rahman import_nguyen polycrystal_rahman random_points_10 random_points_200 import_freeman voro_lf split_cell ghost_test neigh_test tri_mesh sphere r_pts_interface minkowski # Makefile rules all: $(EXECUTABLES) diff --git a/trunk/examples/no_release/minkowski.cc b/trunk/examples/no_release/minkowski.cc new file mode 100644 index 0000000..bd71fd7 --- /dev/null +++ b/trunk/examples/no_release/minkowski.cc @@ -0,0 +1,57 @@ +// Voronoi calculation 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 up constants for the container geometry +const double x_min=-1,x_max=1; +const double y_min=-1,y_max=1; +const double z_min=-1,z_max=1; + +// Set up the number of blocks that the container is divided into +const int n_x=6,n_y=6,n_z=6; + +// Set the number of particles that are going to be randomly introduced +const int particles=20; + +// This function returns a random double between 0 and 1 +double rnd() {return double(rand())/RAND_MAX;} + +int main() { + int i; + double x,y,z; + + // Create a container with the geometry given above, and make it + // non-periodic in each of the three coordinates. Allocate space for + // eight particles within each computational block + container con(x_min,x_max,y_min,y_max,z_min,z_max,n_x,n_y,n_z, + false,false,false,8); + + // Randomly add particles into the container + for(i=0;i