11 #include "geometry.hh" 27 double xmin=0,xmax=
nx;
28 double ymin=0,ymax=
ny;
29 double zmin=0,zmax=
nz;
30 const int n_x=6,n_y=6,n_z=6;
33 cout <<
"voro++ is creating Voronoi tesselation..." << endl;
39 xmin,xmax,ymin,ymax,zmin,zmax,n_x,n_y,n_z,
true,
true,
true,8);
40 for (i=0; i<
ncell; i++) {
41 con.put(i,center_x[i],center_y[i],center_z[i]);
44 con.draw_cells_gnuplot(filename.c_str());
59 double xmin=0,xmax=
nx;
60 double ymin=0,ymax=
ny;
61 double zmin=0,zmax=
nz;
62 double x[6],
y[6],z[6];
69 cout <<
"loading cell vertices and edges" << endl;
73 cout <<
"can't open gnuplot file with foam skeleton" << endl;
76 for (i=0; i<vmax; i++) {
80 for (j=0; j<incmax; j++) vinc[i][j]=-1;
84 istringstream tmp(line);
86 tmp >> x[0]; tmp >> y[0]; tmp >> z[0];
88 tmp >> z[0]; tmp >> y[0]; tmp >> x[0];
93 while (getline(fin,line)) {
96 istringstream tmp(line);
98 tmp >> x[1]; tmp >> y[1]; tmp >> z[1];
100 tmp >> z[1]; tmp >> y[1]; tmp >> x[1];
107 for (i=0; i<2; i++) {
109 for (j=0; j<sv; j++) {
110 if (abs(x[i]-vert[j][0])<eps && \
111 abs(y[i]-vert[j][1])<eps && \
112 abs(z[i]-vert[j][2])<eps) {
118 if (found ==
false) {
127 for (i=0; i<incmax; i++) {
129 if (vinc[vind[0]][i] == vind[1])
break;
130 if (vinc[vind[0]][i] == -1) {
131 vinc[vind[0]][i] = vind[1];
135 for (i=0; i<incmax; i++) {
137 if (vinc[vind[1]][i] == vind[0])
break;
138 if (vinc[vind[1]][i] == -1) {
139 vinc[vind[1]][i] = vind[0];
143 }
else if ((
in_domain(x[0],y[0],z[0]) && \
147 if (x[0]<0 || x[1]<0) {
150 }
else if (x[0]>xmax || x[1]>xmax) {
157 if (y[0]<0 || y[1]<0) {
160 }
else if (y[0]>ymax || y[1]>ymax) {
167 if (z[0]<0 || z[1]<0) {
170 }
else if (z[0]>zmax || z[1]>zmax) {
177 for (i=0; i<4; i++) {
179 for (j=0; j<sv; j++) {
180 if (abs(x[i]-vert[j][0])<eps && \
181 abs(y[i]-vert[j][1])<eps && \
182 abs(z[i]-vert[j][2])<eps) {
188 if (found ==
false) {
197 for (i=0; i<incmax; i++) {
199 if (vinc[vind[0]][i] == vind[1])
break;
200 if (vinc[vind[0]][i] == -1) {
201 vinc[vind[0]][i] = vind[1];
205 for (i=0; i<incmax; i++) {
207 if (vinc[vind[1]][i] == vind[0])
break;
208 if (vinc[vind[1]][i] == -1) {
209 vinc[vind[1]][i] = vind[0];
214 for (i=0; i<incmax; i++) {
216 if (vinc[vind[2]][i] == vind[3])
break;
217 if (vinc[vind[2]][i] == -1) {
218 vinc[vind[2]][i] = vind[3];
222 for (i=0; i<incmax; i++) {
224 if (vinc[vind[3]][i] == vind[2])
break;
225 if (vinc[vind[3]][i] == -1) {
226 vinc[vind[3]][i] = vind[2];
235 }
else if (x[0]>xmax) {
245 }
else if (y[0]>ymax) {
255 }
else if (z[0]>zmax) {
265 }
else if (x[1]>xmax) {
275 }
else if (y[1]>ymax) {
285 }
else if (z[1]>zmax) {
292 for (i=2; i<6; i++) {
294 for (j=0; j<sv; j++) {
295 if (abs(x[i]-vert[j][0])<eps && \
296 abs(y[i]-vert[j][1])<eps && \
297 abs(z[i]-vert[j][2])<eps) {
303 if (found ==
false) {
312 for (i=0; i<incmax; i++) {
314 if (vinc[vind[0]][i] == vind[1])
break;
315 if (vinc[vind[0]][i] == -1) {
316 vinc[vind[0]][i] = vind[1];
320 for (i=0; i<incmax; i++) {
322 if (vinc[vind[1]][i] == vind[0])
break;
323 if (vinc[vind[1]][i] == -1) {
324 vinc[vind[1]][i] = vind[0];
328 for (i=0; i<incmax; i++) {
330 if (vinc[vind[2]][i] == vind[3])
break;
331 if (vinc[vind[2]][i] == -1) {
332 vinc[vind[2]][i] = vind[3];
336 for (i=0; i<incmax; i++) {
338 if (vinc[vind[3]][i] == vind[2])
break;
339 if (vinc[vind[3]][i] == -1) {
340 vinc[vind[3]][i] = vind[2];
345 x[0]=x[1]; y[0]=y[1]; z[0]=z[1];
350 istringstream tmp(line);
352 tmp >> x[0]; tmp >> y[0]; tmp >> z[0];
354 tmp >> z[0]; tmp >> y[0]; tmp >> x[0];
void importFoamSkeleton(string filename, double **vert, int **vinc, int vmax, int incmax, int &sv, bool report)
Load geometric tessellation, move it to the domain and store it.
real(dp), dimension(:), allocatable y
state variables
real(dp) eps
foam porosity
Defines global variables, macros, templates and namespace.
bool in_domain(double x, double y, double z)
True if the point is in the domain, False otherwise.
integer ncell
number of cells
integer nz
spatial discretization
namespace with global variables
bool import_vtk
import morphology from vtk
void makeFoamSkeleton(string filename, int ncell, int *center_x, int *center_y, int *center_z, bool report)
Make geometric tessellation using voro++ and store it to a file.