/** ![An example Z-order indexing curve of size $4^3$, the structure is also known as a Morton Curve. Image courtesy of [Asger Hoedt](http://asgerhoedt.dk/?p=276)](http://asgerhoedt.dk/wp-content/uploads/2012/10/MortonCurve-4x4x4.png) # The prime numbers allong a Z-order space-filling curve, in Three Dimensions Inspired by Ulam's spiral and the results that were obtained in [two dimensions](primes.c) (2D), it seems atractive to extend the analysis of the locations of the prime numbers (primes) along a Z-order space filling curve to 3D. Convieniently, Basilisk also includes a 3D grid that is iterated in a Z-ordering fashion, namely the Octree grid. #The set-up The code is copied from the 2D analysis and required only slight alterations. Well done everything that ensures a proper distinction between 2D and 3D grids in the source code! Hence this page only adress the differences in the set-up and results. */ #define BV 1 // For Bview movie output #include "grid/octree.h" #include "utils.h" #include "tag.h" #if BV #include "view.h" #endif /** Because of 3D scaling reasons, we can only go to 6 levels of refinement. that corresponds to $2^6=64$ points in each direction. We also still use the *getprimes* function we have used previously on the 2D grid. */ int i=6; void getprimes(int b[],int n){ b[0]=0;// 0 is not prime b[1]=0;// 1 is not prime for (int j=2;j0) regsize[(int)field[]]++; sprintf(name,"prime3d%d.dat",maxlevel); FILE * fp = fopen (name, "w"); /** ## Output The output is again similar to what was done in 2D. 1. We store the size of each connected region, for each refinement iteration in seperate files. 2. We store the number of connected regions for each refinement iteration in a single file. 3. A movie is rendered to provide some visual reference. */ for (m=1;m