diff --git a/src/cooling.h b/src/cooling.h index 3d50658b9b2cf03cadb6138315b3936d3c4ea4ad..06085e67941aef2711ad2dd56d82c78dba11d1d4 100644 --- a/src/cooling.h +++ b/src/cooling.h @@ -29,12 +29,16 @@ /* Import the right cooling definition */ #if defined(COOLING_NONE) +#include "./cooling/none/cooling_iact.h" #include "./cooling/none/cooling.h" #elif defined(COOLING_CONST_DU) +#include "./cooling/const_du/cooling_iact.h" #include "./cooling/const_du/cooling.h" #elif defined(COOLING_CONST_LAMBDA) +#include "./cooling/const_lambda/cooling_iact.h" #include "./cooling/const_lambda/cooling.h" #elif defined(COOLING_GRACKLE) +#include "./cooling/grackle/cooling_iact.h" #include "./cooling/grackle/cooling.h" #else #error "Invalid choice of cooling function." diff --git a/src/cooling/grackle/cooling_iact.h b/src/cooling/grackle/cooling_iact.h new file mode 100644 index 0000000000000000000000000000000000000000..502858800d177616f3e0af2afd528cca6f5830ae --- /dev/null +++ b/src/cooling/grackle/cooling_iact.h @@ -0,0 +1,32 @@ +/******************************************************************************* + * This file is part of SWIFT. + * Coypright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ + +#include "part.h" + +/** + * @brief Density loop + */ +__attribute__((always_inline)) INLINE static void cooling_density_iact( + float wi, float wj, struct part *pi, struct part *pj) { + + float diff = pi->cooling_data.He_density - pj->cooling_data.He_density; + + pi->cooling_data.He_density += wj * diff; + pj->cooling_data.He_density += wi * diff; +}; diff --git a/src/cooling/grackle/cooling_io.h b/src/cooling/grackle/cooling_io.h new file mode 100644 index 0000000000000000000000000000000000000000..0d7a1f664ecb0df8c1985757dcd30e07bb395199 --- /dev/null +++ b/src/cooling/grackle/cooling_io.h @@ -0,0 +1,72 @@ +/******************************************************************************* + * This file is part of SWIFT. + * Coypright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ + +#include "io_properties.h" + +/** + * @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. + */ +void cooling_read_particles(struct part* parts, struct io_props* list, + int* num_fields) { + + list += *num_fields; + *num_fields += 1; + + /* List what we want to read */ + list[0] = io_make_input_field("HeDensity", FLOAT, 1, OPTIONAL, + UNIT_CONV_DENSITY, parts, cooling_data.He_density); + +} + + +/** + * @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. + */ +void cooling_write_particles(const struct part* parts, struct io_props* list, + int* num_fields) { + + int i = *num_fields; + /* List what we want to write */ + list[i] = io_make_output_field( + "HeDensity", FLOAT, 1, UNIT_CONV_DENSITY, parts, cooling_data.He_density); + i++; + + *num_fields = i; +} + + +/** + * @brief Writes the current model of SPH to the file + * @param h_grpsph The HDF5 group in which to write + */ +void writeCoolingFlavor(hid_t h_grpsph) { + + /* Viscosity and thermal conduction */ + io_write_attribute_s( + h_grpsph, "Chemistry Model", + "Grackle"); +} diff --git a/src/cooling_io.h b/src/cooling_io.h new file mode 100644 index 0000000000000000000000000000000000000000..2d24e7d191407a716bee37acbac7aeb8dc155533 --- /dev/null +++ b/src/cooling_io.h @@ -0,0 +1,38 @@ +/******************************************************************************* + * This file is part of SWIFT. + * Coypright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + ******************************************************************************/ +#ifndef SWIFT_COOLING_IO_H +#define SWIFT_COOLING_IO_H + +/* Config parameters. */ +#include "../config.h" + +/* Import the right functions */ +#if defined(COOLING_NONE) +#include "./cooling/none/cooling_io.h" +#elif defined(COOLING_CONST_DU) +#include "./cooling/const_du/cooling_io.h" +#elif defined(COOLING_CONST_LAMBDA) +#include "./cooling/const_lambda/cooling_io.h" +#elif defined(COOLING_GRACKLE) +#include "./cooling/grackle/cooling_io.h" +#else +#error "Invalid choice of cooling function." +#endif + +#endif /* SWIFT_COOLING_IO_H */