diff --git a/examples/BigCosmoVolume/makeIC.py b/examples/BigCosmoVolume/makeIC.py index 411ac54b41fadc4209b314b5b9976e5ac95d8000..c141337c06fb28aa4049e2823fcc7cd3e9d5513c 100644 --- a/examples/BigCosmoVolume/makeIC.py +++ b/examples/BigCosmoVolume/makeIC.py @@ -133,6 +133,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = 0 +grp.attrs["Dimension"] = 3 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/ExternalPointMass/makeIC.py b/examples/ExternalPointMass/makeIC.py index 37fc46a9243b2a4c42029de4587082f9efb11f43..326183398933c88d7348e72e00343064b3e3a64c 100644 --- a/examples/ExternalPointMass/makeIC.py +++ b/examples/ExternalPointMass/makeIC.py @@ -83,7 +83,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0] - +grp.attrs["Dimension"] = 3 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/GreshoVortex_2D/makeIC.py b/examples/GreshoVortex_2D/makeIC.py index 96fa7f098d5eb26c42a984e2b5ec94bafc710dc3..4f4ec3407b04971882fbf3d7d7479e74bf56c762 100644 --- a/examples/GreshoVortex_2D/makeIC.py +++ b/examples/GreshoVortex_2D/makeIC.py @@ -87,6 +87,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFileOutputsPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0] +grp.attrs["Dimension"] = 2 #Runtime parameters grp = fileOutput.create_group("/RuntimePars") diff --git a/examples/IsothermalPotential/GravityOnly/makeIC.py b/examples/IsothermalPotential/GravityOnly/makeIC.py index 88115668bd11e19f93765860540dcf33c6ae5c64..07993f19d40a9a3b9a4b86c9dd8c44f7e6fa3d7e 100644 --- a/examples/IsothermalPotential/GravityOnly/makeIC.py +++ b/examples/IsothermalPotential/GravityOnly/makeIC.py @@ -101,7 +101,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0] - +grp.attrs["Dimension"] = 3 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/KelvinHelmholtz_2D/makeIC.py b/examples/KelvinHelmholtz_2D/makeIC.py index 5c8632dea52ef301c453cfbf21c35923f12e2d5a..bd0f39ed90faf0d67ff4a508bff83067bf748d43 100644 --- a/examples/KelvinHelmholtz_2D/makeIC.py +++ b/examples/KelvinHelmholtz_2D/makeIC.py @@ -120,6 +120,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFileOutputsPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0] +grp.attrs["Dimension"] = 2 #Runtime parameters grp = fileOutput.create_group("/RuntimePars") diff --git a/examples/MultiTypes/makeIC.py b/examples/MultiTypes/makeIC.py index cf889f9b6eab502f692cd6c8b4506c31664ecdcb..229450b67c02258553b588483d7cbd4fef887817 100644 --- a/examples/MultiTypes/makeIC.py +++ b/examples/MultiTypes/makeIC.py @@ -61,6 +61,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, massDM, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = 0 +grp.attrs["Dimension"] = 3 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/PerturbedBox_2D/makeIC.py b/examples/PerturbedBox_2D/makeIC.py index 20b720419ff095016daad23828b81ca880ea9c2e..87a41517772570870e04c79d3694c115a909e214 100644 --- a/examples/PerturbedBox_2D/makeIC.py +++ b/examples/PerturbedBox_2D/makeIC.py @@ -84,6 +84,7 @@ grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0] grp.attrs["NumPart_Total"] = numPart +grp.attrs["Dimension"] = 2 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/PerturbedBox_3D/makeIC.py b/examples/PerturbedBox_3D/makeIC.py index cc7fffe14d4f361153a07101ddcec20a3c979b4a..1b0fc284e4c40b51fca45f117b92175a0ea45f31 100644 --- a/examples/PerturbedBox_3D/makeIC.py +++ b/examples/PerturbedBox_3D/makeIC.py @@ -86,6 +86,7 @@ grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0] grp.attrs["NumPart_Total"] = numPart +grp.attrs["Dimension"] = 3 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/SedovBlast_1D/makeIC.py b/examples/SedovBlast_1D/makeIC.py index 4bdf69eee99d98956d5e657be3f963d0cf9ea15b..0c3a311703651003dbf17da099e53bf8a607b881 100644 --- a/examples/SedovBlast_1D/makeIC.py +++ b/examples/SedovBlast_1D/makeIC.py @@ -70,6 +70,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = 0 +grp.attrs["Dimension"] = 1 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/SedovBlast_2D/makeIC.py b/examples/SedovBlast_2D/makeIC.py index 05233576f63f90b8d448aaa75fa6bfe7fce1f0e8..0e83c7b19b9ac9bd69e20950a64e8a49dd8d0df9 100644 --- a/examples/SedovBlast_2D/makeIC.py +++ b/examples/SedovBlast_2D/makeIC.py @@ -70,6 +70,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = 0 +grp.attrs["Dimension"] = 2 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/SedovBlast_3D/makeIC.py b/examples/SedovBlast_3D/makeIC.py index 3c1e36a74b53ece8b886e2fcbe5d9178d9deefbc..e1b743c6cdcd8dcc2f8da14d1d5589fb9ed111f0 100644 --- a/examples/SedovBlast_3D/makeIC.py +++ b/examples/SedovBlast_3D/makeIC.py @@ -70,6 +70,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = 0 +grp.attrs["Dimension"] = 3 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/SodShock_1D/makeIC.py b/examples/SodShock_1D/makeIC.py index e024188e867c1f2636187c2c53157c214752d6f7..a5c7f03b24d10e81057dbe25855f33f795218f19 100644 --- a/examples/SodShock_1D/makeIC.py +++ b/examples/SodShock_1D/makeIC.py @@ -90,6 +90,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = 0 +grp.attrs["Dimension"] = 1 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/SodShock_2D/makeIC.py b/examples/SodShock_2D/makeIC.py index ac2b9ab45fb68921bce7971c46048b344955140d..fdc1610df8cb87b3057323b1330e4c3044f36241 100644 --- a/examples/SodShock_2D/makeIC.py +++ b/examples/SodShock_2D/makeIC.py @@ -96,6 +96,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = 0 +grp.attrs["Dimension"] = 2 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/SodShock_3D/makeIC.py b/examples/SodShock_3D/makeIC.py index 84283732afc497825417546be8bc25e183ecb1cb..c71c07c6c97bb715c580f747cf8d39ddf08445c3 100644 --- a/examples/SodShock_3D/makeIC.py +++ b/examples/SodShock_3D/makeIC.py @@ -96,6 +96,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = 0 +grp.attrs["Dimension"] = 3 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/SquareTest_2D/makeIC.py b/examples/SquareTest_2D/makeIC.py index 2cb624f9944fcd421d95934ffeded089613e8bc9..186e653124a6ff62a964c37cf0fb2220f1152a0e 100644 --- a/examples/SquareTest_2D/makeIC.py +++ b/examples/SquareTest_2D/makeIC.py @@ -94,6 +94,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0] +grp.attrs["Dimension"] = 2 #Runtime parameters grp = fileOutput.create_group("/RuntimePars") diff --git a/examples/UniformBox_2D/makeIC.py b/examples/UniformBox_2D/makeIC.py index 41b7d695a2376b990703706977ef111be8f3a355..642896c6ec406a5a75127e024d19775ea4a8e09b 100644 --- a/examples/UniformBox_2D/makeIC.py +++ b/examples/UniformBox_2D/makeIC.py @@ -83,6 +83,7 @@ grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = [0, 0, 0, 0, 0, 0] grp.attrs["NumPart_Total"] = numPart +grp.attrs["Dimension"] = 2 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/UniformBox_3D/makeIC.py b/examples/UniformBox_3D/makeIC.py index 1484f60596e68734f0f98685ab2ab845f2e0b407..01e37c67b6e2eec2984d62f4ffd503b23b5bd9ec 100644 --- a/examples/UniformBox_3D/makeIC.py +++ b/examples/UniformBox_3D/makeIC.py @@ -55,6 +55,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = 0 +grp.attrs["Dimension"] = 3 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/examples/UniformDMBox/makeIC.py b/examples/UniformDMBox/makeIC.py index 2aee89798a5b8bbd425a6b73528779fb1aa7db23..8e032500016eb6cc8e0decc54968bb5b841d7f93 100644 --- a/examples/UniformDMBox/makeIC.py +++ b/examples/UniformDMBox/makeIC.py @@ -51,6 +51,7 @@ grp.attrs["Time"] = 0.0 grp.attrs["NumFilesPerSnapshot"] = 1 grp.attrs["MassTable"] = [0.0, mass, 0.0, 0.0, 0.0, 0.0] grp.attrs["Flag_Entropy_ICs"] = 0 +grp.attrs["Dimension"] = 3 #Runtime parameters grp = file.create_group("/RuntimePars") diff --git a/src/parallel_io.c b/src/parallel_io.c index 262ab7d9e4405b54538e5b687c0aadfccf1da2f0..d543aac7e700dc008c439ffca7e45108c6c1904e 100644 --- a/src/parallel_io.c +++ b/src/parallel_io.c @@ -37,6 +37,7 @@ /* Local includes. */ #include "common_io.h" +#include "dimension.h" #include "engine.h" #include "error.h" #include "gravity_io.h" @@ -383,6 +384,7 @@ void read_ic_parallel(char* fileName, const struct UnitSystem* internal_units, size_t N[NUM_PARTICLE_TYPES] = {0}; long long N_total[NUM_PARTICLE_TYPES] = {0}; long long offset[NUM_PARTICLE_TYPES] = {0}; + int dimension = 3; /* Assume 3D if nothing is specified */ /* Open file */ /* message("Opening file '%s' as IC.", fileName); */ @@ -409,6 +411,15 @@ void read_ic_parallel(char* fileName, const struct UnitSystem* internal_units, h_grp = H5Gopen(h_file, "/Header", H5P_DEFAULT); if (h_grp < 0) error("Error while opening file header\n"); + /* Check the dimensionality of the ICs (if the info exists) */ + const hid_t hid_dim = H5Aexists(h_grp, "Dimension"); + if (hid_dim < 0) + error("Error while testing existance of 'Dimension' attribute"); + if (hid_dim > 0) readAttribute(h_grp, "Dimension", INT, &dimension); + if (dimension != hydro_dimension) + error("ICs dimensionality (%dD) does not match code dimensionality (%dD)", + dimension, (int)hydro_dimension); + /* Read the relevant information and print status */ int flag_entropy_temp[6]; readAttribute(h_grp, "Flag_Entropy_ICs", INT, flag_entropy_temp); diff --git a/src/serial_io.c b/src/serial_io.c index c981e5e31db1868e6cd2590c6bb36d51282f94c7..508168282791120b0befbe741fa06c9212de1f93 100644 --- a/src/serial_io.c +++ b/src/serial_io.c @@ -37,6 +37,7 @@ /* Local includes. */ #include "common_io.h" +#include "dimension.h" #include "engine.h" #include "error.h" #include "gravity_io.h" @@ -426,6 +427,7 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units, size_t N[NUM_PARTICLE_TYPES] = {0}; long long N_total[NUM_PARTICLE_TYPES] = {0}; long long offset[NUM_PARTICLE_TYPES] = {0}; + int dimension = 3; /* Assume 3D if nothing is specified */ struct UnitSystem* ic_units = malloc(sizeof(struct UnitSystem)); /* First read some information about the content */ @@ -453,6 +455,15 @@ void read_ic_serial(char* fileName, const struct UnitSystem* internal_units, h_grp = H5Gopen(h_file, "/Header", H5P_DEFAULT); if (h_grp < 0) error("Error while opening file header\n"); + /* Check the dimensionality of the ICs (if the info exists) */ + const hid_t hid_dim = H5Aexists(h_grp, "Dimension"); + if (hid_dim < 0) + error("Error while testing existance of 'Dimension' attribute"); + if (hid_dim > 0) readAttribute(h_grp, "Dimension", INT, &dimension); + if (dimension != hydro_dimension) + error("ICs dimensionality (%dD) does not match code dimensionality (%dD)", + dimension, (int)hydro_dimension); + /* Read the relevant information and print status */ int flag_entropy_temp[6]; readAttribute(h_grp, "Flag_Entropy_ICs", INT, flag_entropy_temp); diff --git a/src/single_io.c b/src/single_io.c index 93faab6717fb8c136559511ada2c928f185f9f42..1aab1b846df662dbdde258a326e6888818dd8a62 100644 --- a/src/single_io.c +++ b/src/single_io.c @@ -36,6 +36,7 @@ /* Local includes. */ #include "common_io.h" +#include "dimension.h" #include "engine.h" #include "error.h" #include "gravity_io.h" @@ -339,6 +340,7 @@ void read_ic_single(char* fileName, const struct UnitSystem* internal_units, int numParticles[NUM_PARTICLE_TYPES] = {0}; int numParticles_highWord[NUM_PARTICLE_TYPES] = {0}; size_t N[NUM_PARTICLE_TYPES] = {0}; + int dimension = 3; /* Assume 3D if nothing is specified */ size_t Ndm; /* Open file */ @@ -364,6 +366,15 @@ void read_ic_single(char* fileName, const struct UnitSystem* internal_units, h_grp = H5Gopen(h_file, "/Header", H5P_DEFAULT); if (h_grp < 0) error("Error while opening file header\n"); + /* Check the dimensionality of the ICs (if the info exists) */ + const hid_t hid_dim = H5Aexists(h_grp, "Dimension"); + if (hid_dim < 0) + error("Error while testing existance of 'Dimension' attribute"); + if (hid_dim > 0) readAttribute(h_grp, "Dimension", INT, &dimension); + if (dimension != hydro_dimension) + error("ICs dimensionality (%dD) does not match code dimensionality (%dD)", + dimension, (int)hydro_dimension); + /* Read the relevant information and print status */ int flag_entropy_temp[6]; readAttribute(h_grp, "Flag_Entropy_ICs", INT, flag_entropy_temp);