10 #include "allocation.hh" 14 #define COUNT(i,j,k,a) (((V_CELL(0,(i),(j),(k)) == (a)) ? 1 : 0) + \ 15 ((V_CELL(1,(i),(j),(k)) == (a)) ? 1 : 0) + \ 16 ((V_CELL(2,(i),(j),(k)) == (a)) ? 1 : 0) + \ 17 ((V_CELL(3,(i),(j),(k)) == (a)) ? 1 : 0) + \ 18 ((V_CELL(4,(i),(j),(k)) == (a)) ? 1 : 0) + \ 19 ((V_CELL(5,(i),(j),(k)) == (a)) ? 1 : 0) + \ 20 ((V_CELL(6,(i),(j),(k)) == (a)) ? 1 : 0) + \ 21 ((V_CELL(7,(i),(j),(k)) == (a)) ? 1 : 0) ) 33 int min_distance, m_cell;
34 int dx, dy,
dz, mx, my, mz;
37 printf(
"creating walls\n");
40 v = (
int *)calloc((
size_t)
ncell,
sizeof(int));
44 v_cell = (
int ****)calloc((
size_t)8,
sizeof(
int ***));
45 for (m = 0; m < 8; m++) {
47 if (v_cell[m] == NULL) {
48 fprintf (stderr,
"Insufficient memory.\n");
55 for (m = 0; m < 8 ; m++)
56 for (i = 0; i <
nx; i++)
57 for (j = 0; j <
ny; j++)
58 for (k = 0; k <
nz; k++)
59 v_cell[m][i][j][k] = -1;
64 for (i = 0; i <
nx; i++)
65 for (j = 0; j <
ny; j++)
66 for (k = 0; k <
nz; k++) {
71 for (m = 0; m <
ncell; m++) {
78 v[
m] = dx * dx + dy * dy + dz *
dz;
83 min_distance = 3 * nx * ny *
nz;
84 for (m = 0; m <
ncell; m++)
85 if (v[m] < min_distance)
91 for (m = 0; m <
ncell; m++)
92 if (v[m] == min_distance) {
93 v_cell[m_cell][i][j][k] =
m;
105 for (i = 0; i <
nx; i++)
106 for (j = 0; j <
ny; j++)
107 for (k = 0; k <
nz; k++)
108 if (v_cell[1][i][j][k] != -1) {
109 amat[i][j][k] = 8 -
COUNT(i,j,k,-1);
113 printf(
"Voxels with multiplicity: m_cell = %d\n", m_cell);
122 for (i = 0; i <
nx; i++)
123 for (j = 0; j <
ny; j++)
124 for (k = 0; k <
nz; k++) {
125 if (amat[i][j][k] > 1) {
127 }
else if (
AMAT(i+1,j,k) > 1 ||
130 }
else if (
AMAT(i-1,j,k) > 1 ||
133 }
else if (
AMAT(i,j+1,k) > 1 ||
136 }
else if (
AMAT(i,j-1,k) > 1 ||
139 }
else if (
AMAT(i,j,k+1) > 1 ||
142 }
else if (
AMAT(i,j,k-1) > 1 ||
148 for (i=0; i<8; i++) {
void makeWalls(int ***amat, int ncell, int *center_x, int *center_y, int *center_z, bool report)
Creates walls based on position of seeds and Voronoi tessellation.
real(dp), dimension(:), allocatable dz
spatial discretization
int *** free_3Dmatrix(int ***amat)
free 3D integer matrix
#define AMAT(i, j, k)
Respect periodic boundary conditions in matrix.
#define MIN(x, y)
Lesser of two values.
Defines global variables, macros, templates and namespace.
m
Bubble Growth Application Recipe.
#define COUNT(i, j, k, a)
integer ncell
number of cells
namespace with global variables
int *** alloc_3Dmatrix(int nx, int ny, int nz)
allocate 3D integer matrix
#define ABS(x)
Absolute value.
#define V_CELL(m, i, j, k)
Respect periodic boundary conditions cell volume matrix.