Value defined at particles¶
When you output value defined at particles, please use the functions in Table 74.
List 106 shows an example of the process to output value defined at grid nodes.
Note
These functions are deprecated
When you want to output value defined at particles, we recommend that you use functions described at Value defined at particles (groups supported). Using those new functions, you can output particles with multiple groups, and you can visualize particles with different settings for color and size for each group.
Subroutine |
Remarks |
|---|---|
cg_iric_write_sol_particle_pos2d_f |
Outputs particle positions (two-dimensions) |
cg_iric_write_sol_particle_pos3d_f |
Outputs particle positions (three-dimensions) |
cg_iric_write_sol_particle_integer_f |
Outputs integer-type calculation results, giving a value for each particle. |
cg_iric_write_sol_particle_real_f |
Outputs double-precision real-type calculation results, giving a value for each particle. |
1program SampleProgram
2 implicit none
3 include 'cgnslib_f.h'
4
5 integer:: fin, ier, isize, jsize
6 integer:: canceled
7 integer:: locked
8 double precision:: time
9 double precision, dimension(:,:), allocatable::grid_x, grid_y
10 integer:: numparticles = 10
11 double precision, dimension(:), allocatable:: particle_x, particle_y
12 double precision, dimension(:), allocatable:: velocity_x, velocity_y, temperature
13 character(len=20):: condFile
14
15 condFile = 'test.cgn'
16
17 ! Open CGNS file
18 call cg_open_f(condFile, CG_MODE_MODIFY, fin, ier)
19 if (ier /=0) STOP "*** Open error of CGNS file ***"
20
21 ! Initialize iRIClib
22 call cg_iric_init_f(fin, ier)
23 if (ier /=0) STOP "*** Initialize error of CGNS file ***"
24
25 ! Check the grid size
26 call cg_iric_gotogridcoord2d_f(isize, jsize, ier)
27 ! Allocate memory for loading the grid
28 allocate(grid_x(isize, jsize), grid_y(isize, jsize))
29 ! Allocate memory for calculation result
30 allocate(particle_x(numparticles), particle_y(numparticles))
31 allocate(velocity_x(numparticles), velocity_y(numparticles), temperature(numparticles))
32
33 ! Read the grid into memory
34 call cg_iric_getgridcoord2d_f (grid_x, grid_y, ier)
35
36 ! Output the initial state information.
37 time = 0
38 call cg_iric_write_sol_time_f(time, ier)
39 call cg_iric_write_sol_particle_pos2d_f(numparticles, particle_x, particle_y, ier)
40 call cg_iric_write_sol_particle_real_f('VelocityX', velocity_x, ier)
41 call cg_iric_write_sol_particle_real_f('VelocityY', velocity_y, ier)
42 call cg_iric_write_sol_particle_real_f('Temperature', temperature, ier)
43 do
44 time = time + 10.0
45
46 ! (Perform calculation here)
47
48 call iric_check_cancel_f(canceled)
49 if (canceled == 1) exit
50
51 ! Output calculation results
52 call iric_write_sol_start_f(condFile, ier)
53 call cg_iric_write_sol_time_f(time, ier)
54 call cg_iric_write_sol_particle_pos2d_f(numparticles, particle_x, particle_y, ier)
55 call cg_iric_write_sol_particle_real_f('VelocityX', velocity_x, ier)
56 call cg_iric_write_sol_particle_real_f('VelocityY', velocity_y, ier)
57 call cg_iric_write_sol_particle_real_f('Temperature', temperature, ier)
58 call cg_iric_flush_f(condFile, fin, ier)
59 call iric_write_sol_end_f(condFile, ier)
60
61 if (time > 1000) exit
62 end do
63
64 ! Close CGNS file
65 call cg_close_f(fin, ier)
66 stop
67end program SampleProgram