FrontISTR
5.7.0
Large-scale structural analysis program with finit element method
hecmw_vis_read_voxel.c
Go to the documentation of this file.
1
/*****************************************************************************
2
* Copyright (c) 2019 FrontISTR Commons
3
* This software is released under the MIT License, see LICENSE.txt
4
*****************************************************************************/
5
6
#include "
hecmw_vis_read_voxel.h
"
7
8
#include <stdio.h>
9
#include "
hecmw_vis_mem_util.h
"
10
11
int
read_voxel_file
(
char
*filename,
int
n_voxel,
double
*
voxel_dxyz
,
12
double
*
voxel_orig_xyz
,
int
*
level
,
13
int
*
voxel_n_neighbor_pe
,
int
**
voxel_neighbor_pe
) {
14
FILE *fp;
15
int
i, j;
16
int
ret;
17
if
((fp = fopen(filename,
"r"
)) ==
NULL
)
18
HECMW_vis_print_exit
(
"ERROR: HEC-MW-VIS-E0010: Cannot open voxel file"
);
19
for
(j = 0; j < n_voxel; j++) {
20
/* read parallel information */
21
ret = fscanf(fp,
"%lf %lf %lf"
, &
voxel_orig_xyz
[j * 3],
22
&
voxel_orig_xyz
[j * 3 + 1], &
voxel_orig_xyz
[j * 3 + 2]);
23
if
(ret != 3)
HECMW_vis_print_exit
(
"ERROR: voxel file format error\n"
);
24
ret = fscanf(fp,
"%lf %lf %lf"
, &
voxel_dxyz
[j * 3], &
voxel_dxyz
[j * 3 + 1],
25
&
voxel_dxyz
[j * 3 + 2]);
26
if
(ret != 3)
HECMW_vis_print_exit
(
"ERROR: voxel file format error\n"
);
27
28
ret = fscanf(fp,
"%d"
, &
voxel_n_neighbor_pe
[j]);
29
if
(ret != 1)
HECMW_vis_print_exit
(
"ERROR: voxel file format error\n"
);
30
31
for
(i = 0; i <
voxel_n_neighbor_pe
[j]; i++) {
32
ret = fscanf(fp,
"%d"
, &
voxel_neighbor_pe
[j][i]);
33
if
(ret != 1)
HECMW_vis_print_exit
(
"ERROR: voxel file format error\n"
);
34
}
35
36
level
[j * 3 + 0] = 0;
37
level
[j * 3 + 1] = 0;
38
level
[j * 3 + 2] = 0;
39
}
40
fclose(fp);
41
42
return
1;
43
}
44
#ifdef later
45
int
write_voxel_file(
Voxel_data
*vox) {
46
int
i, j;
47
48
for
(i = 0; i < vox->
n_voxel
; i++) {
49
fprintf(stderr,
"%d: %lf %lf %lf(%lf %lf %lf)\n"
, i, vox->
info
[i].
dx
,
50
vox->
info
[i].
dy
, vox->
info
[i].
dz
, vox->
info
[i].
orig_x
,
51
vox->
info
[i].
orig_y
, vox->
info
[i].
orig_z
);
52
for
(j = 0; j < vox->
info
[i].
n_neighbor_pe
; j++) {
53
fprintf(stderr,
"%d "
, vox->
info
[i].
neighbor_pe
[j]);
54
}
55
fprintf(stderr,
"\n"
);
56
}
57
58
return
1;
59
}
60
61
#endif
hecmw_vis_mem_util.h
read_voxel_file
int read_voxel_file(char *filename, int n_voxel, double *voxel_dxyz, double *voxel_orig_xyz, int *level, int *voxel_n_neighbor_pe, int **voxel_neighbor_pe)
Definition:
hecmw_vis_read_voxel.c:11
voxel_info::dz
double dz
Definition:
hecmw_vis_resampling.h:50
voxel_info::orig_x
double orig_x
Definition:
hecmw_vis_resampling.h:51
voxel_n_neighbor_pe
int * voxel_n_neighbor_pe
Definition:
hecmw_vis_pvr_main.c:26
HECMW_vis_print_exit
void HECMW_vis_print_exit(char *var)
Definition:
hecmw_vis_mem_util.c:21
voxel_data::info
Voxel_info * info
Definition:
hecmw_vis_resampling.h:61
voxel_dxyz
double * voxel_dxyz
Definition:
hecmw_vis_pvr_main.c:25
level
int * level
Definition:
hecmw_vis_pvr_main.c:26
voxel_orig_xyz
double * voxel_orig_xyz
Definition:
hecmw_vis_pvr_main.c:25
voxel_info::dx
double dx
Definition:
hecmw_vis_resampling.h:48
voxel_info::dy
double dy
Definition:
hecmw_vis_resampling.h:49
voxel_info::orig_y
double orig_y
Definition:
hecmw_vis_resampling.h:52
voxel_info::neighbor_pe
int * neighbor_pe
Definition:
hecmw_vis_resampling.h:56
voxel_data::n_voxel
int n_voxel
Definition:
hecmw_vis_resampling.h:60
voxel_neighbor_pe
int ** voxel_neighbor_pe
Definition:
hecmw_vis_pvr_main.c:26
NULL
#define NULL
Definition:
hecmw_io_nastran.c:30
voxel_info::n_neighbor_pe
int n_neighbor_pe
Definition:
hecmw_vis_resampling.h:55
hecmw_vis_read_voxel.h
voxel_data
Definition:
hecmw_vis_resampling.h:59
voxel_info::orig_z
double orig_z
Definition:
hecmw_vis_resampling.h:53
hecmw1
src
visualizer
hecmw_vis_read_voxel.c
Generated by
1.8.17