Commit da3eec1c authored by lhausamm's avatar lhausamm
Browse files

Remove grackle wrapper

parent 6c3f0c6a
/***********************************************************************
/
/ Grackle c wrapper
/
/
/ Copyright (c) 2013, Enzo/Grackle Development Team.
/
/ Distributed under the terms of the Enzo Public Licence.
/
/ The full license is in the file LICENSE, distributed with this
/ software.
************************************************************************/
#include "grackle_wrapper.h"
#ifdef SWIFT_DEBUG_CHECKS
#include <assert.h>
#define GRACKLE_ASSERT(X) assert((X))
#else
#define GRACKLE_ASSERT(X)
#endif
code_units my_units;
// arrays passed to grackle as input and to be filled
#define FIELD_SIZE 1
gr_float HDI_density[FIELD_SIZE];
// Set grid dimension and size.
// grid_start and grid_end are used to ignore ghost zones.
const int grid_rank = 1;
int wrap_get_cooling_time(double rho, double u, double Z, double a_now,
double *coolingtime) {
gr_float den_factor = 1.0;
gr_float u_factor = 1.0;
gr_float x_velocity[FIELD_SIZE] = {0.0};
gr_float y_velocity[FIELD_SIZE] = {0.0};
gr_float z_velocity[FIELD_SIZE] = {0.0};
gr_float density[FIELD_SIZE] = {rho * den_factor};
gr_float metal_density[FIELD_SIZE] = {Z * density[0]};
gr_float energy[FIELD_SIZE] = {u * u_factor};
gr_float cooling_time[FIELD_SIZE] = {0.0};
int grid_dimension[3] = {1, 0, 0};
int grid_start[3] = {0, 0, 0};
int grid_end[3] = {0, 0, 0};
if (FIELD_SIZE != 1) {
error("field_size must currently be set to 1.");
}
if (calculate_cooling_time_table(&my_units, a_now, grid_rank, grid_dimension,
grid_start, grid_end, density, energy,
x_velocity, y_velocity, z_velocity,
metal_density, cooling_time) == 0) {
error("Error in calculate_cooling_time.");
}
// return updated chemistry and energy
for (int i = 0; i < FIELD_SIZE; i++) {
coolingtime[i] = cooling_time[i];
}
return 1;
}
int wrap_do_cooling(double rho, double *u, double dt, double Z, double a_now) {
GRACKLE_ASSERT(FIELD_SIZE == 1);
gr_float den_factor = 1.0;
gr_float u_factor = 1.0;
gr_float x_velocity[FIELD_SIZE] = {0.0};
gr_float y_velocity[FIELD_SIZE] = {0.0};
gr_float z_velocity[FIELD_SIZE] = {0.0};
gr_float density[FIELD_SIZE] = {rho * den_factor};
gr_float metal_density[FIELD_SIZE] = {Z * density[0]};
gr_float energy[FIELD_SIZE] = {(*u) * u_factor};
int grid_dimension[3] = {1, 0, 0};
int grid_start[3] = {0, 0, 0};
int grid_end[3] = {0, 0, 0};
if (solve_chemistry_table(&my_units, a_now, dt, grid_rank, grid_dimension,
grid_start, grid_end, density, energy, x_velocity,
y_velocity, z_velocity, metal_density) == 0) {
error("Error in solve_chemistry.");
return 0;
}
// return updated chemistry and energy
for (int i = 0; i < FIELD_SIZE; i++) {
u[i] = energy[i] / u_factor;
}
return 1;
}
/***********************************************************************
/
/ Grackle c wrapper
/
/
/ Copyright (c) 2013, Enzo/Grackle Development Team.
/
/ Distributed under the terms of the Enzo Public Licence.
/
/ The full license is in the file LICENSE, distributed with this
/ software.
************************************************************************/
#ifndef SWIFT_COOLING_GRACKLE_WRAPPER_H
#define SWIFT_COOLING_GRACKLE_WRAPPER_H
#include "config.h"
#include "error.h"
#include <chemistry_data.h>
#include <grackle.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "error.h"
int wrap_init_cooling(char *CloudyTable, int UVbackground, double udensity,
double ulength, double utime, int grackle_chemistry);
int wrap_init_cooling(char *CloudyTable, int UVbackground, double udensity,
double ulength, double utime, int grackle_chemistry);
int wrap_set_UVbackground_on();
int wrap_set_UVbackground_off();
int wrap_get_cooling_time(double rho, double u, double Z, double a_now,
double *coolingtime);
int wrap_do_cooling(double density, double *energy, double dtime, double Z,
double a_now);
void grackle_print_data();
void cloudy_print_data(const cloudy_data c, const int print_mmw);
#endif /* SWIFT_COOLING_GRACKLE_WRAPPER_H */
Markdown is supported
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