23 #define INFINITE (1.0E+37)
31 if (bgcell ==
NULL)
return;
62 double *min_dx,
double *min_dy,
double *min_dz,
63 double *max_dx,
double *max_dy,
double *max_dz) {
64 double min_x, min_y, min_z, max_x, max_y, max_z,
dx,
dy,
dz, coord_x, coord_y,
68 *min_dx = *min_dy = *min_dz =
INFINITE;
69 *max_dx = *max_dy = *max_dz = 0.0;
71 for (i = 0; i < boundary->
elem->
n; i++) {
80 coord_x =
mesh->
node[3 * (node - 1)];
81 coord_y =
mesh->
node[3 * (node - 1) + 1];
82 coord_z =
mesh->
node[3 * (node - 1) + 2];
84 if (coord_x < min_x) min_x = coord_x;
85 if (coord_y < min_y) min_y = coord_y;
86 if (coord_z < min_z) min_z = coord_z;
87 if (coord_x > max_x) max_x = coord_x;
88 if (coord_y > max_y) max_y = coord_y;
89 if (coord_z > max_z) max_z = coord_z;
96 if (
dx < *min_dx) *min_dx =
dx;
97 if (
dy < *min_dy) *min_dy =
dy;
98 if (
dz < *min_dz) *min_dz =
dz;
99 if (
dx > *max_dx) *max_dx =
dx;
100 if (
dy > *max_dy) *max_dy =
dy;
101 if (
dz > *max_dz) *max_dz =
dz;
109 double *min_dx,
double *min_dy,
double *min_dz,
110 double *max_dx,
double *max_dy,
double *max_dz) {
111 double min_x, min_y, min_z, max_x, max_y, max_z,
dx,
dy,
dz, coord_x, coord_y,
113 int elem, node, i, j;
115 *min_dx = *min_dy = *min_dz =
INFINITE;
116 *max_dx = *max_dy = *max_dz = 0.0;
118 for (i = 0; i < boundary->
surf->
n; i++) {
127 coord_x =
mesh->
node[3 * (node - 1)];
128 coord_y =
mesh->
node[3 * (node - 1) + 1];
129 coord_z =
mesh->
node[3 * (node - 1) + 2];
131 if (coord_x < min_x) min_x = coord_x;
132 if (coord_y < min_y) min_y = coord_y;
133 if (coord_z < min_z) min_z = coord_z;
134 if (coord_x > max_x) max_x = coord_x;
135 if (coord_y > max_y) max_y = coord_y;
136 if (coord_z > max_z) max_z = coord_z;
143 if (
dx < *min_dx) *min_dx =
dx;
144 if (
dy < *min_dy) *min_dy =
dy;
145 if (
dz < *min_dz) *min_dz =
dz;
146 if (
dx > *max_dx) *max_dx =
dx;
147 if (
dy > *max_dy) *max_dy =
dy;
148 if (
dz > *max_dz) *max_dz =
dz;
161 double min_dx, min_dy, min_dz, max_dx, max_dy, max_dz,
dx,
dy,
dz;
162 double bbox_size_x, bbox_size_y, bbox_size_z;
165 if (boundary_id ==
NULL) {
168 "HECMW_couple_set_background_cell(): 'boundary_id' is NULL");
173 "HECMW_couple_set_background_cell(): 'mesh' is NULL");
178 "HECMW_couple_set_background_cell(): 'bbox' is NULL");
181 if (boundary ==
NULL) {
183 "HECMW_couple_set_background_cell(): 'boundary' is NULL");
187 if ((bgcell = alloc_struct_bgcell()) ==
NULL)
return NULL;
195 "In current version, node group is not supported.");
201 "In current version, element group is not supported.");
208 elem_size_by_surf(
mesh, boundary, &min_dx, &min_dy, &min_dz, &max_dx,
221 dx = max_dx * bgcell->
coef;
226 dy = max_dy * bgcell->
coef;
231 dz = max_dz * bgcell->
coef;
236 nx = bbox_size_x /
dx;
237 ny = bbox_size_y /
dy;
238 nz = bbox_size_z /
dz;
240 bgcell->
nx = (
nx > 0) ?
nx : 1;
241 bgcell->
ny = (
ny > 0) ?
ny : 1;
242 bgcell->
nz = (
nz > 0) ?
nz : 1;
244 bgcell->
dx = bbox_size_x / bgcell->
nx;
245 bgcell->
dy = bbox_size_y / bgcell->
ny;
246 bgcell->
dz = bbox_size_z / bgcell->
nz;
248 bgcell->
n = bgcell->
nx * bgcell->
ny * bgcell->
nz;