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,
69 *min_dx = *min_dy = *min_dz =
INFINITE;
70 *max_dx = *max_dy = *max_dz = 0.0;
72 for (i = 0; i < boundary->
elem->
n; i++) {
81 coord_x =
mesh->
node[3 * (node - 1)];
82 coord_y =
mesh->
node[3 * (node - 1) + 1];
83 coord_z =
mesh->
node[3 * (node - 1) + 2];
85 if (coord_x < min_x) min_x = coord_x;
86 if (coord_y < min_y) min_y = coord_y;
87 if (coord_z < min_z) min_z = coord_z;
88 if (coord_x > max_x) max_x = coord_x;
89 if (coord_y > max_y) max_y = coord_y;
90 if (coord_z > max_z) max_z = coord_z;
97 if (
dx < *min_dx) *min_dx =
dx;
98 if (
dy < *min_dy) *min_dy =
dy;
99 if (
dz < *min_dz) *min_dz =
dz;
100 if (
dx > *max_dx) *max_dx =
dx;
101 if (
dy > *max_dy) *max_dy =
dy;
102 if (
dz > *max_dz) *max_dz =
dz;
110 double *min_dx,
double *min_dy,
double *min_dz,
111 double *max_dx,
double *max_dy,
double *max_dz) {
112 double min_x, min_y, min_z, max_x, max_y, max_z,
dx,
dy,
dz, coord_x, coord_y,
117 *min_dx = *min_dy = *min_dz =
INFINITE;
118 *max_dx = *max_dy = *max_dz = 0.0;
120 for (i = 0; i < boundary->
surf->
n; i++) {
129 coord_x =
mesh->
node[3 * (node - 1)];
130 coord_y =
mesh->
node[3 * (node - 1) + 1];
131 coord_z =
mesh->
node[3 * (node - 1) + 2];
133 if (coord_x < min_x) min_x = coord_x;
134 if (coord_y < min_y) min_y = coord_y;
135 if (coord_z < min_z) min_z = coord_z;
136 if (coord_x > max_x) max_x = coord_x;
137 if (coord_y > max_y) max_y = coord_y;
138 if (coord_z > max_z) max_z = coord_z;
145 if (
dx < *min_dx) *min_dx =
dx;
146 if (
dy < *min_dy) *min_dy =
dy;
147 if (
dz < *min_dz) *min_dz =
dz;
148 if (
dx > *max_dx) *max_dx =
dx;
149 if (
dy > *max_dy) *max_dy =
dy;
150 if (
dz > *max_dz) *max_dz =
dz;
163 double min_dx, min_dy, min_dz, max_dx, max_dy, max_dz,
dx,
dy,
dz;
164 double bbox_size_x, bbox_size_y, bbox_size_z;
167 if (boundary_id ==
NULL) {
170 "HECMW_couple_set_background_cell(): 'boundary_id' is NULL");
175 "HECMW_couple_set_background_cell(): 'mesh' is NULL");
180 "HECMW_couple_set_background_cell(): 'bbox' is NULL");
183 if (boundary ==
NULL) {
185 "HECMW_couple_set_background_cell(): 'boundary' is NULL");
189 if ((bgcell = alloc_struct_bgcell()) ==
NULL)
return NULL;
197 "In current version, node group is not supported.");
203 "In current version, element group is not supported.");
210 elem_size_by_surf(
mesh, boundary, &min_dx, &min_dy, &min_dz, &max_dx,
223 dx = max_dx * bgcell->
coef;
228 dy = max_dy * bgcell->
coef;
233 dz = max_dz * bgcell->
coef;
238 nx = bbox_size_x /
dx;
239 ny = bbox_size_y /
dy;
240 nz = bbox_size_z /
dz;
242 bgcell->
nx = (
nx > 0) ?
nx : 1;
243 bgcell->
ny = (
ny > 0) ?
ny : 1;
244 bgcell->
nz = (
nz > 0) ?
nz : 1;
246 bgcell->
dx = bbox_size_x / bgcell->
nx;
247 bgcell->
dy = bbox_size_y / bgcell->
ny;
248 bgcell->
dz = bbox_size_z / bgcell->
nz;
250 bgcell->
n = bgcell->
nx * bgcell->
ny * bgcell->
nz;
struct hecmw_couple_background_cell * HECMW_couple_set_background_cell(const char *boundary_id, const struct hecmwST_local_mesh *mesh, const struct hecmw_couple_bounding_box *bbox, const struct hecmw_couple_boundary *boundary)
void HECMW_couple_free_background_cell(struct hecmw_couple_background_cell *bgcell)
int HECMW_couple_ctrl_get_bgcoef(const char *boundary_id, double *bgcoef)
#define HECMW_COUPLE_ELEMENT_GROUP
#define HECMWCPL_E_NONSUPPORT_GEOMTYPE
#define HECMW_COUPLE_NODE_GROUP
#define HECMWCPL_E_INVALID_ARG
#define HECMW_COUPLE_SURFACE_GROUP
#define HECMWCPL_E_INVALID_GEOMTYPE
struct hecmwST_local_mesh * mesh
int HECMW_set_error(int errorno, const char *fmt,...)
#define HECMW_malloc(size)
struct hecmw_couple_boundary_item * elem
struct hecmw_couple_boundary_item * surf
struct hecmw_couple_box * enlarged
long long * elem_node_index