Skip to content
Snippets Groups Projects
Commit 6cea41bd authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Add a function that returns the name of a specific chemistry element. Use that...

Add a function that returns the name of a specific chemistry element. Use that function to print the names in the snapshot header.
parent 448bc854
No related branches found
No related tags found
1 merge request!486Add chemistry in part
......@@ -37,6 +37,19 @@
#include "physical_constants.h"
#include "units.h"
/**
* @brief Return a string containing the name of a given #chemistry_element.
*/
__attribute__((always_inline)) INLINE static const char*
chemistry_get_element_name(enum chemistry_element elem) {
static const char* chemistry_element_names[chemistry_element_count] = {
"Hydrogen", "Helium", "Carbon", "Nitrogen", "Oxygen",
"Neon", "Magnesium", "Silicium", "Iron"};
return chemistry_element_names[elem];
}
/**
* @brief Sets the chemistry properties of the (x-)particles to a valid start
* state.
......
......@@ -19,6 +19,7 @@
#ifndef SWIFT_CHEMISTRY_IO_EAGLE_H
#define SWIFT_CHEMISTRY_IO_EAGLE_H
#include "chemistry.h"
#include "io_properties.h"
/**
......@@ -98,9 +99,14 @@ int chemistry_write_particles(const struct part* parts, struct io_props* list) {
* @brief Writes the current model of SPH to the file
* @param h_grpsph The HDF5 group in which to write
*/
void chemistry_write_flavour(hid_t h_grpsph) {
io_write_attribute_s(h_grpsph, "Chemistry Model", "EAGLE");
void chemistry_write_flavour(hid_t h_grp) {
io_write_attribute_s(h_grp, "Chemistry Model", "EAGLE");
for (int elem = 0; elem < chemistry_element_count; ++elem) {
char buffer[20];
sprintf(buffer, "Element %d", elem);
io_write_attribute_s(h_grp, buffer, chemistry_get_element_name(elem));
}
}
#endif /* SWIFT_CHEMISTRY_IO_EAGLE_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment