Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
6616adfc
Commit
6616adfc
authored
8 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
New i/o mechanism ported to the other flavours of SPH
parent
b5a21907
No related branches found
No related tags found
1 merge request
!194
Io unit conversion
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/hydro/Default/hydro_io.h
+53
-67
53 additions, 67 deletions
src/hydro/Default/hydro_io.h
src/hydro/Minimal/hydro_io.h
+53
-67
53 additions, 67 deletions
src/hydro/Minimal/hydro_io.h
with
106 additions
and
134 deletions
src/hydro/Default/hydro_io.h
+
53
−
67
View file @
6616adfc
...
...
@@ -17,83 +17,69 @@
*
******************************************************************************/
#include
"io_properties.h"
#include
"kernel_hydro.h"
/**
* @brief Reads the different particles to the HDF5 file
*
* @param h_grp The HDF5 group in which to read the arrays.
* @param N The number of particles on that MPI rank.
* @param N_total The total number of particles (only used in MPI mode)
* @param offset The offset of the particles for this MPI rank (only used in MPI
*mode)
* @param parts The particle array
* @brief Specifies which particle fields to read from a dataset
*
* @param parts The particle array.
* @param list The list of i/o properties to read.
* @param num_fields The number of i/o fields to read.
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_read_particles
(
hid_t
h_grp
,
int
N
,
long
long
N_total
,
long
long
offset
,
struct
part
*
parts
)
{
void
hydro_read_particles
(
struct
part
*
parts
,
struct
io_props
*
list
,
int
*
num_fields
)
{
*
num_fields
=
8
;
/*
Read arrays
*/
readArray
(
h_grp
,
"Coordinates"
,
DOUBLE
,
N
,
3
,
parts
,
N_total
,
offset
,
x
,
COMPULSORY
);
readArray
(
h_grp
,
"Velocities"
,
FLOAT
,
N
,
3
,
parts
,
N_total
,
offset
,
v
,
COMPULSORY
);
readArray
(
h_grp
,
"Masses"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
offset
,
mass
,
COMPULSORY
);
readArray
(
h_grp
,
"SmoothingLength"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
offset
,
h
,
COMPULSORY
);
readArray
(
h_grp
,
"InternalEnergy"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
offset
,
u
,
COMPULSORY
);
readArray
(
h_grp
,
"ParticleIDs"
,
ULONGLONG
,
N
,
1
,
parts
,
N_total
,
offset
,
id
,
COMPULSORY
);
readArray
(
h_grp
,
"Acceleration"
,
FLOAT
,
N
,
3
,
parts
,
N_total
,
offset
,
a_hydro
,
OPTIONAL
);
readArray
(
h_grp
,
"Density"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
offset
,
rho
,
OPTIONAL
);
/*
List what we want to read
*/
list
[
0
]
=
io_make_input_field
(
"Coordinates"
,
DOUBLE
,
3
,
COMPULSORY
,
UNIT_CONV_LENGTH
,
parts
,
x
);
list
[
1
]
=
io_make_input_field
(
"Velocities"
,
FLOAT
,
3
,
COMPULSORY
,
UNIT_CONV_SPEED
,
parts
,
v
);
list
[
2
]
=
io_make_input_field
(
"Masses"
,
FLOAT
,
1
,
COMPULSORY
,
UNIT_CONV_MASS
,
parts
,
mass
);
list
[
3
]
=
io_make_input_field
(
"SmoothingLength"
,
FLOAT
,
1
,
COMPULSORY
,
UNIT_CONV_LENGTH
,
parts
,
h
);
list
[
4
]
=
io_make_input_field
(
"InternalEnergy"
,
FLOAT
,
1
,
COMPULSORY
,
UNIT_CONV_ENERGY
,
parts
,
u
);
list
[
5
]
=
io_make_input_field
(
"ParticleIDs"
,
ULONGLONG
,
1
,
COMPULSORY
,
UNIT_CONV_NO_UNITS
,
parts
,
id
);
list
[
6
]
=
io_make_input_field
(
"Acceleration
s
"
,
FLOAT
,
3
,
OPTIONAL
,
UNIT_CONV_ACCELERATION
,
parts
,
a_hydro
);
list
[
7
]
=
io_make_input_field
(
"Density"
,
FLOAT
,
1
,
OPTIONAL
,
UNIT_CONV_DENSITY
,
parts
,
rho
);
}
/**
* @brief Writes the different particles to the HDF5 file
*
* @param h_grp The HDF5 group in which to write the arrays.
* @param fileName The name of the file (unsued in MPI mode).
* @param partTypeGroupName The name of the group containing the particles in
*the HDF5 file.
* @param xmfFile The XMF file to write to (unused in MPI mode).
* @param N The number of particles on that MPI rank.
* @param N_total The total number of particles (only used in MPI mode)
* @param mpi_rank The MPI rank of this node (only used in MPI mode)
* @param offset The offset of the particles for this MPI rank (only used in MPI
*mode)
* @param parts The particle array
* @param us The unit system to use
* @brief Specifies which particle fields to write to a dataset
*
* @param parts The particle array.
* @param list The list of i/o properties to write.
* @param num_fields The number of i/o fields to write.
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_write_particles
(
hid_t
h_grp
,
char
*
fileName
,
char
*
partTypeGroupName
,
FILE
*
xmfFile
,
int
N
,
long
long
N_total
,
int
mpi_rank
,
long
long
offset
,
struct
part
*
parts
,
struct
UnitSystem
*
us
)
{
void
hydro_write_particles
(
struct
part
*
parts
,
struct
io_props
*
list
,
int
*
num_fields
)
{
*
num_fields
=
8
;
/* Write arrays */
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"Coordinates"
,
DOUBLE
,
N
,
3
,
parts
,
N_total
,
mpi_rank
,
offset
,
x
,
us
,
UNIT_CONV_LENGTH
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"Velocities"
,
FLOAT
,
N
,
3
,
parts
,
N_total
,
mpi_rank
,
offset
,
v
,
us
,
UNIT_CONV_SPEED
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"Masses"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
mpi_rank
,
offset
,
mass
,
us
,
UNIT_CONV_MASS
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"SmoothingLength"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
mpi_rank
,
offset
,
h
,
us
,
UNIT_CONV_LENGTH
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"InternalEnergy"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
mpi_rank
,
offset
,
u
,
us
,
UNIT_CONV_ENERGY_PER_UNIT_MASS
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"ParticleIDs"
,
ULONGLONG
,
N
,
1
,
parts
,
N_total
,
mpi_rank
,
offset
,
id
,
us
,
UNIT_CONV_NO_UNITS
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"Acceleration"
,
FLOAT
,
N
,
3
,
parts
,
N_total
,
mpi_rank
,
offset
,
a_hydro
,
us
,
UNIT_CONV_ACCELERATION
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"Density"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
mpi_rank
,
offset
,
rho
,
us
,
UNIT_CONV_DENSITY
);
/* List what we want to write */
list
[
0
]
=
io_make_output_field
(
"Coordinates"
,
DOUBLE
,
3
,
UNIT_CONV_LENGTH
,
parts
,
x
);
list
[
1
]
=
io_make_output_field
(
"Velocities"
,
FLOAT
,
3
,
UNIT_CONV_SPEED
,
parts
,
v
);
list
[
2
]
=
io_make_output_field
(
"Masses"
,
FLOAT
,
1
,
UNIT_CONV_MASS
,
parts
,
mass
);
list
[
3
]
=
io_make_output_field
(
"SmoothingLength"
,
FLOAT
,
1
,
UNIT_CONV_LENGTH
,
parts
,
h
);
list
[
4
]
=
io_make_output_field
(
"Entropy"
,
FLOAT
,
1
,
UNIT_CONV_ENERGY_PER_UNIT_MASS
,
parts
,
u
);
list
[
5
]
=
io_make_output_field
(
"ParticleIDs"
,
ULONGLONG
,
1
,
UNIT_CONV_NO_UNITS
,
parts
,
id
);
list
[
6
]
=
io_make_output_field
(
"Acceleration"
,
FLOAT
,
3
,
UNIT_CONV_ACCELERATION
,
parts
,
a_hydro
);
list
[
7
]
=
io_make_output_field
(
"Density"
,
FLOAT
,
1
,
UNIT_CONV_DENSITY
,
parts
,
rho
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/hydro/Minimal/hydro_io.h
+
53
−
67
View file @
6616adfc
...
...
@@ -17,83 +17,69 @@
*
******************************************************************************/
#include
"io_properties.h"
#include
"kernel_hydro.h"
/**
* @brief Reads the different particles to the HDF5 file
*
* @param h_grp The HDF5 group in which to read the arrays.
* @param N The number of particles on that MPI rank.
* @param N_total The total number of particles (only used in MPI mode)
* @param offset The offset of the particles for this MPI rank (only used in MPI
*mode)
* @param parts The particle array
* @brief Specifies which particle fields to read from a dataset
*
* @param parts The particle array.
* @param list The list of i/o properties to read.
* @param num_fields The number of i/o fields to read.
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_read_particles
(
hid_t
h_grp
,
int
N
,
long
long
N_total
,
long
long
offset
,
struct
part
*
parts
)
{
void
hydro_read_particles
(
struct
part
*
parts
,
struct
io_props
*
list
,
int
*
num_fields
)
{
*
num_fields
=
8
;
/*
Read arrays
*/
readArray
(
h_grp
,
"Coordinates"
,
DOUBLE
,
N
,
3
,
parts
,
N_total
,
offset
,
x
,
COMPULSORY
);
readArray
(
h_grp
,
"Velocities"
,
FLOAT
,
N
,
3
,
parts
,
N_total
,
offset
,
v
,
COMPULSORY
);
readArray
(
h_grp
,
"Masses"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
offset
,
mass
,
COMPULSORY
);
readArray
(
h_grp
,
"SmoothingLength"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
offset
,
h
,
COMPULSORY
);
readArray
(
h_grp
,
"InternalEnergy"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
offset
,
u
,
COMPULSORY
);
readArray
(
h_grp
,
"ParticleIDs"
,
ULONGLONG
,
N
,
1
,
parts
,
N_total
,
offset
,
id
,
COMPULSORY
);
readArray
(
h_grp
,
"Acceleration"
,
FLOAT
,
N
,
3
,
parts
,
N_total
,
offset
,
a_hydro
,
OPTIONAL
);
readArray
(
h_grp
,
"Density"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
offset
,
rho
,
OPTIONAL
);
/*
List what we want to read
*/
list
[
0
]
=
io_make_input_field
(
"Coordinates"
,
DOUBLE
,
3
,
COMPULSORY
,
UNIT_CONV_LENGTH
,
parts
,
x
);
list
[
1
]
=
io_make_input_field
(
"Velocities"
,
FLOAT
,
3
,
COMPULSORY
,
UNIT_CONV_SPEED
,
parts
,
v
);
list
[
2
]
=
io_make_input_field
(
"Masses"
,
FLOAT
,
1
,
COMPULSORY
,
UNIT_CONV_MASS
,
parts
,
mass
);
list
[
3
]
=
io_make_input_field
(
"SmoothingLength"
,
FLOAT
,
1
,
COMPULSORY
,
UNIT_CONV_LENGTH
,
parts
,
h
);
list
[
4
]
=
io_make_input_field
(
"InternalEnergy"
,
FLOAT
,
1
,
COMPULSORY
,
UNIT_CONV_ENERGY
,
parts
,
u
);
list
[
5
]
=
io_make_input_field
(
"ParticleIDs"
,
ULONGLONG
,
1
,
COMPULSORY
,
UNIT_CONV_NO_UNITS
,
parts
,
id
);
list
[
6
]
=
io_make_input_field
(
"Acceleration
s
"
,
FLOAT
,
3
,
OPTIONAL
,
UNIT_CONV_ACCELERATION
,
parts
,
a_hydro
);
list
[
7
]
=
io_make_input_field
(
"Density"
,
FLOAT
,
1
,
OPTIONAL
,
UNIT_CONV_DENSITY
,
parts
,
rho
);
}
/**
* @brief Writes the different particles to the HDF5 file
*
* @param h_grp The HDF5 group in which to write the arrays.
* @param fileName The name of the file (unsued in MPI mode).
* @param partTypeGroupName The name of the group containing the particles in
*the HDF5 file.
* @param xmfFile The XMF file to write to (unused in MPI mode).
* @param N The number of particles on that MPI rank.
* @param N_total The total number of particles (only used in MPI mode)
* @param mpi_rank The MPI rank of this node (only used in MPI mode)
* @param offset The offset of the particles for this MPI rank (only used in MPI
*mode)
* @param parts The particle array
* @param us The unit system to use
* @brief Specifies which particle fields to write to a dataset
*
* @param parts The particle array.
* @param list The list of i/o properties to write.
* @param num_fields The number of i/o fields to write.
*/
__attribute__
((
always_inline
))
INLINE
static
void
hydro_write_particles
(
hid_t
h_grp
,
char
*
fileName
,
char
*
partTypeGroupName
,
FILE
*
xmfFile
,
int
N
,
long
long
N_total
,
int
mpi_rank
,
long
long
offset
,
struct
part
*
parts
,
struct
UnitSystem
*
us
)
{
void
hydro_write_particles
(
struct
part
*
parts
,
struct
io_props
*
list
,
int
*
num_fields
)
{
*
num_fields
=
8
;
/* Write arrays */
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"Coordinates"
,
DOUBLE
,
N
,
3
,
parts
,
N_total
,
mpi_rank
,
offset
,
x
,
us
,
UNIT_CONV_LENGTH
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"Velocities"
,
FLOAT
,
N
,
3
,
parts
,
N_total
,
mpi_rank
,
offset
,
v
,
us
,
UNIT_CONV_SPEED
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"Masses"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
mpi_rank
,
offset
,
mass
,
us
,
UNIT_CONV_MASS
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"SmoothingLength"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
mpi_rank
,
offset
,
h
,
us
,
UNIT_CONV_LENGTH
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"InternalEnergy"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
mpi_rank
,
offset
,
u
,
us
,
UNIT_CONV_ENERGY_PER_UNIT_MASS
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"ParticleIDs"
,
ULONGLONG
,
N
,
1
,
parts
,
N_total
,
mpi_rank
,
offset
,
id
,
us
,
UNIT_CONV_NO_UNITS
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"Acceleration"
,
FLOAT
,
N
,
3
,
parts
,
N_total
,
mpi_rank
,
offset
,
a_hydro
,
us
,
UNIT_CONV_ACCELERATION
);
writeArray
(
h_grp
,
fileName
,
xmfFile
,
partTypeGroupName
,
"Density"
,
FLOAT
,
N
,
1
,
parts
,
N_total
,
mpi_rank
,
offset
,
rho
,
us
,
UNIT_CONV_DENSITY
);
/* List what we want to write */
list
[
0
]
=
io_make_output_field
(
"Coordinates"
,
DOUBLE
,
3
,
UNIT_CONV_LENGTH
,
parts
,
x
);
list
[
1
]
=
io_make_output_field
(
"Velocities"
,
FLOAT
,
3
,
UNIT_CONV_SPEED
,
parts
,
v
);
list
[
2
]
=
io_make_output_field
(
"Masses"
,
FLOAT
,
1
,
UNIT_CONV_MASS
,
parts
,
mass
);
list
[
3
]
=
io_make_output_field
(
"SmoothingLength"
,
FLOAT
,
1
,
UNIT_CONV_LENGTH
,
parts
,
h
);
list
[
4
]
=
io_make_output_field
(
"Entropy"
,
FLOAT
,
1
,
UNIT_CONV_ENERGY_PER_UNIT_MASS
,
parts
,
u
);
list
[
5
]
=
io_make_output_field
(
"ParticleIDs"
,
ULONGLONG
,
1
,
UNIT_CONV_NO_UNITS
,
parts
,
id
);
list
[
6
]
=
io_make_output_field
(
"Acceleration"
,
FLOAT
,
3
,
UNIT_CONV_ACCELERATION
,
parts
,
a_hydro
);
list
[
7
]
=
io_make_output_field
(
"Density"
,
FLOAT
,
1
,
UNIT_CONV_DENSITY
,
parts
,
rho
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment