Commit dcd91e19 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Moved the structure related to cooling into a separate file. Added a structure...

Moved the structure related to cooling into a separate file. Added a structure to the xpart to contain the accumulated radiative information.
parent 7f822cf4
......@@ -43,7 +43,7 @@ include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \
engine.h swift.h serial_io.h timers.h debug.h scheduler.h proxy.h parallel_io.h \
common_io.h single_io.h multipole.h map.h tools.h partition.h clocks.h parser.h \
physical_constants.h physical_constants_cgs.h potentials.h version.h \
hydro_properties.h threadpool.h cooling.h
hydro_properties.h threadpool.h cooling.h cooling_struct.h
# Common source files
......@@ -73,7 +73,9 @@ nobase_noinst_HEADERS = approx_math.h atomic.h cycle.h error.h inline.h kernel_h
hydro/Gizmo/hydro_debug.h hydro/Gizmo/hydro_part.h \
riemann.h riemann/riemann_hllc.h riemann/riemann_trrs.h \
riemann/riemann_exact.h riemann/riemann_vacuum.h \
cooling/const_du/cooling.h cooling/const_lambda/cooling.h
cooling/none/cooling.h cooling/none/cooling_struct.h \
cooling/const_du/cooling.h cooling/const_du/cooling_struct.h \
cooling/const_lambda/cooling.h cooling/const_lambda/cooling_struct.h
# Sources and flags for regular library
......
......@@ -35,6 +35,7 @@
/* Local includes. */
#include "const.h"
#include "cooling_struct.h"
#include "error.h"
#include "hydro.h"
#include "parser.h"
......@@ -42,21 +43,6 @@
#include "physical_constants.h"
#include "units.h"
/**
* @brief Properties of the cooling function.
*/
struct cooling_function_data {
/*! Cooling rate in internal units. du_dt = -cooling_rate */
float cooling_rate;
/*! Minimally allowed internal energy of the particles */
float min_energy;
/*! Constant multiplication factor for time-step criterion */
float cooling_tstep_mult;
};
/**
* @brief Apply the cooling function to a particle.
*
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
* Richard Bower (r.g.bower@durham.ac.uk)
* Stefan Arridge (stefan.arridge@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_STRUCT_CONST_DU_H
#define SWIFT_COOLING_STRUCT_CONST_DU_H
/**
* @file src/cooling/const_du/cooling_struct.h
* @brief Structure related to the "constant cooling" cooling function.
*
* This is the simplest possible cooling function. A constant cooling rate with
* a minimal energy floor is applied. Should be used as a template for more
* realistic functions.
*/
/**
* @brief Properties of the cooling function.
*/
struct cooling_function_data {
/*! Cooling rate in internal units. du_dt = -cooling_rate */
float cooling_rate;
/*! Minimally allowed internal energy of the particles */
float min_energy;
/*! Constant multiplication factor for time-step criterion */
float cooling_tstep_mult;
};
/**
* @brief Properties of the cooling stored in the particle data.
*
* This is used to carry properties such as the total amount of
* energy radiated away.
*/
struct cooling_xpart_data {};
#endif /* SWIFT_COOLING_STRUCT_CONST_DU_H */
......@@ -35,29 +35,6 @@
#include "physical_constants.h"
#include "units.h"
/* Cooling Properties */
struct cooling_function_data {
/*! Cooling rate in cgs units. Defined by 'rho * du/dt = -lambda * n_H^2'*/
float lambda;
/*! Minimum temperature (in Kelvin) for all gas particles*/
float min_temperature;
/*! Fraction of gas mass that is Hydrogen. Used to calculate n_H*/
float hydrogen_mass_abundance;
/* 'mu', used to convert min_temperature to min_internal energy*/
float mean_molecular_weight;
/*! Minimally allowed internal energy of the particles */
float min_energy;
float min_energy_cgs;
/*! Constant multiplication factor for time-step criterion */
float cooling_tstep_mult;
};
/**
* @brief Calculates du/dt in code units for a particle.
*
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2016 Tom Theuns (tom.theuns@durham.ac.uk)
* Matthieu Schaller (matthieu.schaller@durham.ac.uk)
* Richard Bower (r.g.bower@durham.ac.uk)
* Stefan Arridge (stefan.arridge@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_STRUCT_CONST_LAMBDA_H
#define SWIFT_COOLING_STRUCT_CONST_LAMBDA_H
/**
* @brief Properties of the cooling function.
*/
struct cooling_function_data {
/*! Cooling rate in cgs units. Defined by 'rho * du/dt = -lambda * n_H^2'*/
float lambda;
/*! Minimum temperature (in Kelvin) for all gas particles*/
float min_temperature;
/*! Fraction of gas mass that is Hydrogen. Used to calculate n_H*/
float hydrogen_mass_abundance;
/* 'mu', used to convert min_temperature to min_internal energy*/
float mean_molecular_weight;
/*! Minimally allowed internal energy of the particles */
float min_energy;
float min_energy_cgs;
/*! Constant multiplication factor for time-step criterion */
float cooling_tstep_mult;
};
/**
* @brief Properties of the cooling stored in the particle data
*/
struct cooling_xpart_data {};
#endif /* SWIFT_COOLING_STRUCT_CONST_LAMBDA_H */
......@@ -36,11 +36,6 @@
#include "physical_constants.h"
#include "units.h"
/**
* @brief Properties of the cooling function.
*/
struct cooling_function_data {};
/**
* @brief Apply the cooling function to a particle.
*
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (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_STRUCT_NONE_H
#define SWIFT_COOLING_STRUCT_NONE_H
/**
* @file src/cooling/none/cooling_struct.h
* @brief Empty infrastructure for the cases without cooling function
*/
/**
* @brief Properties of the cooling function.
*/
struct cooling_function_data {};
/**
* @brief Properties of the cooling stored in the particle data
*/
struct cooling_xpart_data {};
#endif /* SWIFT_COOLING_STRUCT_NONE_H */
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (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_STRUCT_H
#define SWIFT_COOLING_STRUCT_H
/**
* @file src/cooling_struct.h
* @brief Branches between the different cooling functions.
*/
/* Config parameters. */
#include "../config.h"
/* Local headers. */
#include "const.h"
/* Import the right cooling definition */
#if defined(COOLING_NONE)
#include "./cooling/none/cooling_struct.h"
#elif defined(COOLING_CONST_DU)
#include "./cooling/const_du/cooling_struct.h"
#elif defined(COOLING_CONST_LAMBDA)
#include "./cooling/const_lambda/cooling_struct.h"
#elif defined(COOLING_GRACKLE)
#include "./cooling/grackle/cooling_struct.h"
#else
#error "Invalid choice of cooling function."
#endif
#endif /* SWIFT_COOLING_STRUCT_H */
......@@ -38,7 +38,7 @@
/* Includes. */
#include "clocks.h"
#include "cooling.h"
#include "cooling_struct.h"
#include "parser.h"
#include "partition.h"
#include "potentials.h"
......
......@@ -19,6 +19,8 @@
#ifndef SWIFT_DEFAULT_HYDRO_PART_H
#define SWIFT_DEFAULT_HYDRO_PART_H
#include "cooling_struct.h"
/* Extra particle data not needed during the SPH loops over neighbours. */
struct xpart {
......@@ -28,6 +30,9 @@ struct xpart {
/* Velocity at the last full step. */
float v_full[3];
/* Additional data used to record cooling information */
struct cooling_xpart_data cooling_data;
float u_full;
/* Old density. */
......
......@@ -26,13 +26,10 @@
* @brief SPH interaction functions following the Gadget-2 version of SPH.
*
* The interactions computed here are the ones presented in the Gadget-2 paper
*and use the same
* numerical coefficients as the Gadget-2 code. When used with the Spline-3
*kernel, the results
* should be equivalent to the ones obtained with Gadget-2 up to the rounding
*errors and interactions
* missed by the Gadget-2 tree-code neighbours search.
*
* and use the same numerical coefficients as the Gadget-2 code. When used with
* the Spline-3 kernel, the results should be equivalent to the ones obtained
* with Gadget-2 up to the rounding errors and interactions missed by the
* Gadget-2 tree-code neighbours search.
*/
/**
......
......@@ -19,6 +19,8 @@
#ifndef SWIFT_GADGET2_HYDRO_PART_H
#define SWIFT_GADGET2_HYDRO_PART_H
#include "cooling_struct.h"
/* Extra particle data not needed during the SPH loops over neighbours. */
struct xpart {
......@@ -28,6 +30,9 @@ struct xpart {
/* Velocity at the last full step. */
float v_full[3];
/* Additional data used to record cooling information */
struct cooling_xpart_data cooling_data;
} __attribute__((aligned(xpart_align)));
/* Data of a single particle. */
......
......@@ -16,6 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_GIZMO_HYDRO_PART_H
#define SWIFT_GIZMO_HYDRO_PART_H
#include "cooling_struct.h"
/* Extra particle data not needed during the computation. */
struct xpart {
......@@ -26,6 +30,9 @@ struct xpart {
/* Velocity at the last full step. */
float v_full[3];
/* Additional data used to record cooling information */
struct cooling_xpart_data cooling_data;
} __attribute__((aligned(xpart_align)));
/* Data of a single particle. */
......@@ -197,3 +204,5 @@ struct part {
struct gpart *gpart;
} __attribute__((aligned(part_align)));
#endif /* SWIFT_GIZMO_HYDRO_PART_H */
......@@ -33,6 +33,8 @@
* pp. 759-794.
*/
#include "cooling_struct.h"
/**
* @brief Particle fields not needed during the SPH loops over neighbours.
*
......@@ -47,6 +49,9 @@ struct xpart {
float v_full[3]; /*!< Velocity at the last full step. */
struct cooling_xpart_data
cooling_data; /*!< Additional data used to record cooling information */
} __attribute__((aligned(xpart_align)));
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment