Added support for more options in reading flash files
This commit is contained in:
parent
607f452f7c
commit
aeb9b33d2d
@ -179,13 +179,13 @@ void h5_read_flash3_particles (H5File* file,
|
|||||||
int* totalparticles,
|
int* totalparticles,
|
||||||
int* localnp,
|
int* localnp,
|
||||||
int* particle_offset,
|
int* particle_offset,
|
||||||
float pos1[],
|
float *pos1,
|
||||||
float pos2[],
|
float *pos2,
|
||||||
float pos3[],
|
float *pos3,
|
||||||
float vel1[],
|
float *vel1,
|
||||||
float vel2[],
|
float *vel2,
|
||||||
float vel3[],
|
float *vel3,
|
||||||
int id[])
|
int *id)
|
||||||
{
|
{
|
||||||
|
|
||||||
herr_t status;
|
herr_t status;
|
||||||
@ -339,15 +339,27 @@ void h5_read_flash3_particles (H5File* file,
|
|||||||
|
|
||||||
/* convert buffer into particle struct */
|
/* convert buffer into particle struct */
|
||||||
|
|
||||||
|
if (id) {
|
||||||
for(p=0; p < (pcount); p++) {
|
for(p=0; p < (pcount); p++) {
|
||||||
id[p+poffset] = (int) *(partBuffer+iptag-1+p*numProps);
|
id[p+poffset] = (int) *(partBuffer+iptag-1+p*numProps);
|
||||||
|
} }
|
||||||
|
|
||||||
|
if (pos1 && pos2 && pos3) {
|
||||||
|
for(p=0; p < (pcount); p++) {
|
||||||
pos1[p+poffset] = (float) *(partBuffer+ipx-1+p*numProps);
|
pos1[p+poffset] = (float) *(partBuffer+ipx-1+p*numProps);
|
||||||
pos2[p+poffset] = (float) *(partBuffer+ipy-1+p*numProps);
|
pos2[p+poffset] = (float) *(partBuffer+ipy-1+p*numProps);
|
||||||
pos3[p+poffset] = (float) *(partBuffer+ipz-1+p*numProps);
|
pos3[p+poffset] = (float) *(partBuffer+ipz-1+p*numProps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (vel1 && vel2 && vel3) {
|
||||||
|
for(p=0; p < (pcount); p++) {
|
||||||
vel1[p+poffset] = (float) *(partBuffer+ipvx-1+p*numProps);
|
vel1[p+poffset] = (float) *(partBuffer+ipvx-1+p*numProps);
|
||||||
vel2[p+poffset] = (float) *(partBuffer+ipvy-1+p*numProps);
|
vel2[p+poffset] = (float) *(partBuffer+ipvy-1+p*numProps);
|
||||||
vel3[p+poffset] = (float) *(partBuffer+ipvz-1+p*numProps);
|
vel3[p+poffset] = (float) *(partBuffer+ipvz-1+p*numProps);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
memspace.close();
|
memspace.close();
|
||||||
//status = H5Sclose(memspace);
|
//status = H5Sclose(memspace);
|
||||||
|
@ -23,13 +23,13 @@ void h5_read_flash3_particles (H5File* file,
|
|||||||
int* totalparticles,
|
int* totalparticles,
|
||||||
int* localnp,
|
int* localnp,
|
||||||
int* particle_offset,
|
int* particle_offset,
|
||||||
float pos1[],
|
float *pos1,
|
||||||
float pos2[],
|
float *pos2,
|
||||||
float pos3[],
|
float *pos3,
|
||||||
float vel1[],
|
float *vel1,
|
||||||
float vel2[],
|
float *vel2,
|
||||||
float vel3[],
|
float *vel3,
|
||||||
int id[]);
|
int *id);
|
||||||
|
|
||||||
void h5_read_flash3_header_info(H5File* file,
|
void h5_read_flash3_header_info(H5File* file,
|
||||||
double* time, /* simulation time */
|
double* time, /* simulation time */
|
||||||
|
@ -51,29 +51,36 @@ SimuData *CosmoTool::loadFlashMulti(const char *fname, int id, int loadflags)
|
|||||||
data->Omega_Lambda = omegalambda;
|
data->Omega_Lambda = omegalambda;
|
||||||
|
|
||||||
// particle data
|
// particle data
|
||||||
|
if (loadflags& NEED_POSITION) {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
data->Pos[i] = new float[data->NumPart];
|
data->Pos[i] = new float[data->NumPart];
|
||||||
if (data->Pos[i] == 0) {
|
if (data->Pos[i] == 0) {
|
||||||
delete data;
|
delete data;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
} }
|
||||||
|
|
||||||
|
|
||||||
|
if (loadflags &NEED_VELOCITY) {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
data->Vel[i] = new float[data->NumPart];
|
data->Vel[i] = new float[data->NumPart];
|
||||||
if (data->Vel[i] == 0) {
|
if (data->Vel[i] == 0) {
|
||||||
delete data;
|
delete data;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
} }
|
||||||
|
|
||||||
|
if (loadflags & NEED_GADGET_ID) {
|
||||||
data->Id = new int[data->NumPart];
|
data->Id = new int[data->NumPart];
|
||||||
if (data->Id == 0) {
|
if (data->Id == 0) {
|
||||||
delete data;
|
delete data;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
|
if (loadflags &(NEED_GADGET_ID|NEED_POSITION|NEED_VELOCITY))
|
||||||
h5_read_flash3_particles(&file, &npart, &npart, &offset,
|
h5_read_flash3_particles(&file, &npart, &npart, &offset,
|
||||||
data->Pos[0], data->Pos[1], data->Pos[2],
|
data->Pos[0], data->Pos[1], data->Pos[2],
|
||||||
data->Vel[0], data->Vel[1], data->Vel[2],
|
data->Vel[0], data->Vel[1], data->Vel[2],
|
||||||
@ -81,8 +88,8 @@ SimuData *CosmoTool::loadFlashMulti(const char *fname, int id, int loadflags)
|
|||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
for (int n = 0; n < data->NumPart; n++) {
|
for (int n = 0; n < data->NumPart; n++) {
|
||||||
data->Pos[i][n] = data->Pos[i][n] * data->Hubble / kpc2cm;
|
if (loadflags& NEED_POSITION) data->Pos[i][n] = data->Pos[i][n] * data->Hubble / kpc2cm;
|
||||||
data->Vel[i][n] = data->Vel[i][n] * data->Hubble / km2cm;
|
if (loadflags&NEED_VELOCITY) data->Vel[i][n] = data->Vel[i][n] * data->Hubble / km2cm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user