Skip to content

Commit e1112e5

Browse files
committed
write APS to markers; use file header as a version number for backward compatibility
1 parent f3444c8 commit e1112e5

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/LaMEM_io.jl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,15 @@ function save_LaMEM_markers_parallel(Grid::CartData; PartitioningFile = empty, d
421421
Temp = zeros(size(Phases))
422422
end
423423

424+
if haskey(Grid.fields, :APS)
425+
APS = Grid.fields[:APS]
426+
else
427+
if verbose
428+
println("Field :APS is not provided; setting it to zero")
429+
end
430+
APS = zeros(size(Phases))
431+
end
432+
424433
if PartitioningFile == empty
425434
# in case we run this on 1 processor only
426435
Nprocx = 1
@@ -459,10 +468,11 @@ function save_LaMEM_markers_parallel(Grid::CartData; PartitioningFile = empty, d
459468
part_z = ustrip.(Grid.z.val[x_start[n]:x_end[n], y_start[n]:y_end[n], z_start[n]:z_end[n]])
460469
part_phs = Phases[x_start[n]:x_end[n], y_start[n]:y_end[n], z_start[n]:z_end[n]]
461470
part_T = Temp[x_start[n]:x_end[n], y_start[n]:y_end[n], z_start[n]:z_end[n]]
471+
part_APS = APS[x_start[n]:x_end[n], y_start[n]:y_end[n], z_start[n]:z_end[n]]
462472
num_particles = size(part_x, 1) * size(part_x, 2) * size(part_x, 3)
463473

464474
# Information vector per processor
465-
num_prop = 5 # number of properties we save [x/y/z/phase/T]
475+
num_prop = 6 # number of properties we save [x/y/z/phase/T/APS]
466476
lvec_info = num_particles
467477

468478
lvec_prtcls = zeros(Float64, num_prop * num_particles)
@@ -472,6 +482,7 @@ function save_LaMEM_markers_parallel(Grid::CartData; PartitioningFile = empty, d
472482
lvec_prtcls[3:num_prop:end] = part_z[:]
473483
lvec_prtcls[4:num_prop:end] = part_phs[:]
474484
lvec_prtcls[5:num_prop:end] = part_T[:]
485+
lvec_prtcls[6:num_prop:end] = part_APS[:]
475486

476487
# Write output files
477488
if ~isdir(directory)
@@ -482,7 +493,7 @@ function save_LaMEM_markers_parallel(Grid::CartData; PartitioningFile = empty, d
482493
println("Writing LaMEM marker file -> $fname") # print info
483494
end
484495
lvec_output = [lvec_info; lvec_prtcls] # one vec with info about length
485-
496+
486497
PetscBinaryWrite_Vec(fname, lvec_output) # Write PETSc vector as binary file
487498

488499
end
@@ -552,7 +563,10 @@ function PetscBinaryWrite_Vec(filename, A)
552563
n = length(A)
553564
nummark = A[1] # number of markers
554565

555-
write(f, hton(Float64(1211214))) # header (not actually used)
566+
# header number encodes the version of particle data file
567+
# version with APS is 1211215
568+
# version without APS was 1211214
569+
write(f, hton(Float64(1211215))) # header
556570
write(f, hton(Float64(nummark))) # info about # of markers written
557571

558572
for i in 2:n

0 commit comments

Comments
 (0)