| 1 |
///////////////////////////////////////////////////////////// |
| 2 |
// // |
| 3 |
// Copyright (c) 2007-2017 by The University of Queensland // |
| 4 |
// Centre for Geoscience Computing // |
| 5 |
// http://earth.uq.edu.au/centre-geoscience-computing // |
| 6 |
// // |
| 7 |
// Primary Business: Brisbane, Queensland, Australia // |
| 8 |
// Licensed under the Open Software License version 3.0 // |
| 9 |
// http://www.apache.org/licenses/LICENSE-2.0 // |
| 10 |
// // |
| 11 |
///////////////////////////////////////////////////////////// |
| 12 |
|
| 13 |
/*! |
| 14 |
\file main.cc |
| 15 |
$Revision:$ |
| 16 |
$Date:$ |
| 17 |
*/ |
| 18 |
|
| 19 |
#include "geometry/Sphere.h" |
| 20 |
#include "geometry/Line2D.h" |
| 21 |
#include "geometry/LineSegment2D.h" |
| 22 |
#include "util/vector3.h" |
| 23 |
#include "MNTable2D.h" |
| 24 |
#include "MNTable3D.h" |
| 25 |
#include "InsertGenerator2D.h" |
| 26 |
#include "InsertGenerator3D.h" |
| 27 |
#include "HexAggregateInsertGenerator2D.h" |
| 28 |
#include "BoxWithLines2D.h" |
| 29 |
#include "BoxWithPlanes3D.h" |
| 30 |
|
| 31 |
// --- IO includes --- |
| 32 |
#include <iostream> |
| 33 |
|
| 34 |
using std::cout; |
| 35 |
using std::cout; |
| 36 |
using std::endl; |
| 37 |
|
| 38 |
// -- System includes -- |
| 39 |
#include <cstdlib> |
| 40 |
#include <sys/time.h> |
| 41 |
using std::atoi; |
| 42 |
using std::atof; |
| 43 |
|
| 44 |
int main(int argc, char** argv) |
| 45 |
{ |
| 46 |
int ret=0; |
| 47 |
double size=atof(argv[1]); |
| 48 |
int ntry=atoi(argv[2]); |
| 49 |
double rmin=atof(argv[3]); |
| 50 |
int outputstyle=atoi(argv[4]); |
| 51 |
int dim=atoi(argv[5]); |
| 52 |
double vol; |
| 53 |
|
| 54 |
// seed RNG |
| 55 |
struct timeval tv; |
| 56 |
gettimeofday(&tv,NULL); |
| 57 |
int random_seed=tv.tv_usec; |
| 58 |
srand(random_seed); |
| 59 |
|
| 60 |
if(dim==2){ |
| 61 |
double ratio=atof(argv[6]); |
| 62 |
double xsize=ratio*size; |
| 63 |
double ysize=size; |
| 64 |
MNTable2D T(Vector3(0.0,0.0,0.0),Vector3(xsize,ysize,0.0),2.5,1); |
| 65 |
Vector3 min=Vector3(0.0,0.0,0.0); |
| 66 |
Vector3 max=Vector3(xsize,ysize,0.0); |
| 67 |
|
| 68 |
MNTable2D::SetOutputStyle(outputstyle); |
| 69 |
|
| 70 |
InsertGenerator2D *G=new InsertGenerator2D(rmin,1.0,ntry,10000,1e-7); |
| 71 |
BoxWithLines2D Box(Vector3(0.0,0.0,0.0),Vector3(xsize,ysize,0.0)); |
| 72 |
Line2D bottom_line(Vector3(xsize,0.0,0.0),min); |
| 73 |
Line2D top_line(max,Vector3(0.0,ysize,0.0)); |
| 74 |
Line2D left_line(Vector3(xsize,0.0,0.0),max); |
| 75 |
Line2D right_line(min,Vector3(0.0,ysize,0.0)); |
| 76 |
|
| 77 |
Box.addLine(top_line); |
| 78 |
Box.addLine(bottom_line); |
| 79 |
Box.addLine(left_line); |
| 80 |
Box.addLine(right_line); |
| 81 |
|
| 82 |
G->generatePacking(&Box,&T,0,0); |
| 83 |
//T.generateBonds(0,1e-5,0); |
| 84 |
|
| 85 |
LineSegment2D bottom_left(Vector3(xsize/2,0.0,0.0),min); |
| 86 |
LineSegment2D bottom_right(Vector3(xsize,0.0,0.0),Vector3(xsize/2,0.0,0.0)); |
| 87 |
|
| 88 |
T.tagParticlesAlongLine(left_line,0.5,4,4,0); |
| 89 |
T.tagParticlesAlongLine(right_line,0.5,8,8,0); |
| 90 |
T.tagParticlesAlongLine(bottom_left,0.5,8,8,0); |
| 91 |
T.tagParticlesAlongLine(bottom_right,0.5,4,4,0); |
| 92 |
|
| 93 |
vol=xsize*ysize; |
| 94 |
double poros=(vol-T.getSumVolume(0))/vol; |
| 95 |
cout << "Porosity: " << poros << endl; |
| 96 |
|
| 97 |
cout << T << endl; |
| 98 |
|
| 99 |
delete G; |
| 100 |
} else if(dim==3){ // 3D block 1x2x1 |
| 101 |
double rmax=atof(argv[6]); |
| 102 |
Vector3 min=Vector3(0.0,0.0,0.0); |
| 103 |
Vector3 max=Vector3(size,2.0*size,size); |
| 104 |
MNTable3D T(min,max,2.5*rmax,1); |
| 105 |
MNTable3D::SetOutputStyle(outputstyle); |
| 106 |
InsertGenerator3D G(rmin,rmax,ntry,1000,1e-6); |
| 107 |
BoxWithPlanes3D Box(min,max); |
| 108 |
Box.addPlane(Plane(min,Vector3(1.0,0.0,0.0))); |
| 109 |
Box.addPlane(Plane(min,Vector3(0.0,1.0,0.0))); |
| 110 |
Box.addPlane(Plane(min,Vector3(0.0,0.0,1.0))); |
| 111 |
Box.addPlane(Plane(max,Vector3(-1.0,0.0,0.0))); |
| 112 |
Box.addPlane(Plane(max,Vector3(0.0,-1.0,0.0))); |
| 113 |
Box.addPlane(Plane(max,Vector3(0.0,0.0,-1.0))); |
| 114 |
G.generatePacking(&Box,&T,0); |
| 115 |
T.generateBonds(0,1e-5,0); |
| 116 |
|
| 117 |
double vol=2.0*size*size*size; |
| 118 |
double poros=(vol-T.getSumVolume(0))/vol; |
| 119 |
cout << "Porosity: " << poros << endl; |
| 120 |
|
| 121 |
cout << T << endl; |
| 122 |
} |
| 123 |
return ret; |
| 124 |
} |