Skip to content
Snippets Groups Projects
Commit 350f5733 authored by lhausamm's avatar lhausamm
Browse files

Initialize the chemistry structure

parent 8b7ccec8
Branches
Tags
1 merge request!486Add chemistry in part
/*******************************************************************************
* 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/>.
*
******************************************************************************/
/* Config parameters. */
#include "../config.h"
/* This object's header. */
#include "chemistry.h"
/**
* @brief Initialises the chemistry properties.
*
* Calls chemistry_init_backend for the chosen chemistry function.
*
* @param parameter_file The parsed parameter file.
* @param us The current internal system of units.
* @param phys_const The physical constants in internal units.
* @param chemistry The chemistry properties to initialize
*/
void chemistry_init(const struct swift_params* parameter_file,
const struct unit_system* us,
const struct phys_const* phys_const,
struct chemistry_data* chemistry) {
chemistry_init_backend(parameter_file, us, phys_const, chemistry);
}
/**
* @brief Prints the properties of the chemistry model to stdout.
*
* Calls chemistry_print_backend for the chosen chemistry function.
*
* @param chemistry The properties of the chemistry function.
*/
void chemistry_print(const struct chemistry_data* chemistry) {
chemistry_print_backend(chemistry);
}
/*******************************************************************************
* 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_CHEMISTRY_H
#define SWIFT_CHEMISTRY_H
/**
* @file src/chemistry.h
* @brief Branches between the different chemistry functions.
*/
/* Config parameters. */
#include "../config.h"
#include "chemistry_struct.h"
/* Import the right chemistry definition */
#if defined(CHEMISTRY_NONE)
#include "./chemistry/none/chemistry.h"
#else
#error "Invalid choice of chemistry function."
#endif
/* Common functions */
void chemistry_init(const struct swift_params* parameter_file,
const struct unit_system* us,
const struct phys_const* phys_const,
struct chemistry_data* chem);
void chemistry_print(const struct chemistry_data* chem);
#endif /* SWIFT_CHEMISTRY_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_CHEMISTRY_NONE_H
#define SWIFT_CHEMISTRY_NONE_H
/**
* @file src/chemistry/none/chemistry.h
* @brief Empty infrastructure for the cases without chemistry function
*/
/* Some standard headers. */
#include <float.h>
#include <math.h>
/* Local includes. */
#include "error.h"
#include "hydro.h"
#include "parser.h"
#include "part.h"
#include "physical_constants.h"
#include "units.h"
/**
* @brief Sets the chemistry properties of the (x-)particles to a valid start
* state.
*
* Nothing to do here.
*
* @param p Pointer to the particle data.
* @param xp Pointer to the extended particle data.
*/
__attribute__((always_inline)) INLINE static void chemistry_init_part(
const struct part* restrict p, struct xpart* restrict xp) {}
/**
* @brief Initialises the chemistry properties.
*
* Nothing to do here.
*
* @param parameter_file The parsed parameter file.
* @param us The current internal system of units.
* @param phys_const The physical constants in internal units.
* @param chemistry The chemistry properties to initialize
*/
static INLINE void chemistry_init_backend(
const struct swift_params* parameter_file, const struct unit_system* us,
const struct phys_const* phys_const,
struct chemistry_data* chemistry) {}
/**
* @brief Prints the properties of the chemistry model to stdout.
*
* @param chemistry The properties of the chemistry function.
*/
static INLINE void chemistry_print_backend(
const struct chemistry_data* chemistry) {
message("Chemistry function is 'No chemistry'.");
}
#endif /* SWIFT_CHEMISTRY_NONE_H */
/*******************************************************************************
* 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 chemistry_read_particles(struct part* parts, struct io_props* list,
int* num_fields) {
/* update num_fields and list according to hydro_io */
}
/**
* @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 chemistry_write_particles(const struct part* parts, struct io_props* list,
int* num_fields) {
/* update num_fields and list according to hydro_io */
}
/**
* @brief Writes the current model of SPH to the file
* @param h_grpsph The HDF5 group in which to write
*/
void writeChemistryFlavor(hid_t h_grpsph) {
/* Viscosity and thermal conduction */
io_write_attribute_s(
h_grpsph, "Chemistry Model",
"None");
}
/*******************************************************************************
* 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_CHEMISTRY_STRUCT_NONE_H
#define SWIFT_CHEMISTRY_STRUCT_NONE_H
/**
* @file src/chemistry/none/chemistry_struct.h
* @brief Empty infrastructure for the cases without chemistry function
*/
/**
* @brief Properties of the chemistry function.
*/
struct chemistry_part_data {};
#endif /* SWIFT_CHEMISTRY_STRUCT_NONE_H */
/*******************************************************************************
* 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_CHEMISTRY_IO_H
#define SWIFT_CHEMISTRY_IO_H
/* Config parameters. */
#include "../config.h"
/* Import the right functions */
#if defined(CHEMISTRY_NONE)
#include "./chemistry/none/chemistry_io.h"
#else
#error "Invalid choice of chemistry function."
#endif
#endif /* SWIFT_CHEMISTRY_IO_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_CHEMISTRY_STRUCT_H
#define SWIFT_CHEMISTRY_STRUCT_H
/**
* @file src/chemistry_struct.h
* @brief Branches between the different chemistry functions.
*/
/* Config parameters. */
#include "../config.h"
/* Import the right chemistry definition */
#if defined(CHEMISTRY_NONE)
#include "./chemistry/none/chemistry_struct.h"
#else
#error "Invalid choice of chemistry function."
#endif
#endif /* SWIFT_CHEMISTRY_STRUCT_H */
......@@ -32,6 +32,7 @@
/* Local includes. */
#include "error.h"
#include "hydro.h"
#include "io_properties.h"
#include "parser.h"
#include "part.h"
#include "physical_constants.h"
......@@ -41,6 +42,18 @@
#define GRACKLE_NPART 1
#define GRACKLE_RANK 3
/**
* @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");
}
/**
* @brief Sets the cooling properties of the (x-)particles to a valid start
* state.
......
......@@ -19,46 +19,6 @@
#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, COMPULSORY,
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
......
......@@ -62,13 +62,4 @@ struct cooling_xpart_data {
float radiated_energy;
};
/**
* @brief Properties of the cooling stored in the particle data
*/
struct cooling_part_data {
/*! Quick example */
float He_density;
};
#endif /* SWIFT_COOLING_STRUCT_NONE_H */
......@@ -31,7 +31,7 @@
* Gadget-2 tree-code neighbours search.
*/
#include "cooling_struct.h"
#include "chemistry_struct.h"
/* Extra particle data not needed during the SPH loops over neighbours. */
struct xpart {
......@@ -133,7 +133,7 @@ struct part {
/* Time-step length */
timebin_t time_bin;
struct cooling_part_data cooling_data;
struct chemistry_part_data chemistry_data;
#ifdef SWIFT_DEBUG_CHECKS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment