Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ src/clib/time_deriv_0d.hpp
src/clib/update_UVbackground_rates.cpp
src/clib/utils-cpp.cpp
src/clib/utils-cpp.hpp
src/clib/utils.c
src/clib/utils.h
src/example/c_example.c
src/example/c_local_example.c
src/example/cxx_example.C
Expand Down
3 changes: 1 addition & 2 deletions src/clib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ add_library(Grackle_Grackle
initialize_UVbackground_data.c initialize_UVbackground_data.h
rate_functions.c
status_reporting.c status_reporting.h
utils.c

# auto-generated C source files
${CMAKE_CURRENT_BINARY_DIR}/auto_general.c
Expand Down Expand Up @@ -122,6 +121,7 @@ add_library(Grackle_Grackle
rate_utils.cpp
solve_chemistry.cpp
scale_fields.cpp scale_fields.hpp
self_shielding_err_check.hpp
set_default_chemistry_parameters.cpp
solve_rate_cool_g-cpp.cpp solve_rate_cool_g-cpp.h
step_rate_gauss_seidel.hpp
Expand Down Expand Up @@ -178,7 +178,6 @@ add_library(Grackle_Grackle
interp_table_utils.h
phys_constants.h
collisional_rxn_rate_members.def # <-- acts as a C header
utils.h
dust_const.def

# Fortran public headers
Expand Down
1 change: 0 additions & 1 deletion src/clib/Make.config.objects
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,5 @@ OBJS_CONFIG_LIB = \
rate_functions.lo \
rate_utils.lo \
gaussj_g.lo \
utils.lo \
utils-cpp.lo \
internal_types.lo
7 changes: 4 additions & 3 deletions src/clib/calculate_cooling_time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "grackle.h"
#include "cool_multi_time_g.h"
#include "internal_units.h"
#include "self_shielding_err_check.hpp"
#include "update_UVbackground_rates.hpp"
#include "utils.h"

extern "C" int local_calculate_cooling_time(chemistry_data *my_chemistry,
chemistry_data_storage *my_rates,
Expand Down Expand Up @@ -72,8 +72,9 @@ extern "C" int local_calculate_cooling_time(chemistry_data *my_chemistry,
InternalGrUnits internalu = new_internalu_(my_units);

/* Error checking for H2 shielding approximation */
if (self_shielding_err_check(my_chemistry, my_fields,
"local_calculate_temperature") != GR_SUCCESS) {
if (grackle::impl::self_shielding_err_check(my_chemistry, my_fields,
"local_calculate_temperature")
!= GR_SUCCESS) {
return GR_FAIL;
}

Expand Down
55 changes: 55 additions & 0 deletions src/clib/self_shielding_err_check.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//===----------------------------------------------------------------------===//
//
// See the LICENSE file for license and copyright information
// SPDX-License-Identifier: NCSA AND BSD-3-Clause
//
//===----------------------------------------------------------------------===//
///
/// @file
/// Defines self_shielding_err_check
///
//===----------------------------------------------------------------------===//

#ifndef SELF_SHIELDING_ERR_CHECK_HPP
#define SELF_SHIELDING_ERR_CHECK_HPP

#include <cstdio> // std::fprintf, stderr
#include "grackle.h"

namespace grackle::impl {

/// Perform an error check related to self-shielding. If the check fails, the
/// function returns FAIL and prints an error message to stderr
///
/// @param my_chemistry Holds configuration of chemistry solver
/// @param fields Specify the field names
/// @param func_name Name of the function that is calling the error check
inline int self_shielding_err_check(const chemistry_data* my_chemistry,
const grackle_field_data* fields,
const char* func_name) {
if (my_chemistry->H2_self_shielding == 1) {
if (fields->grid_rank != 3) {
std::fprintf(stderr,
"Error in %s: H2 self-shielding option 1 "
"will only work for 3D Cartesian grids. Use option 2 "
"to provide an array of shielding lengths with "
"H2_self_shielding_length or option 3 to use the "
"local Jeans length.",
func_name);
return GR_FAIL;
} else if (my_chemistry->primordial_chemistry >= 2 &&
fields->grid_dx <= 0) {
std::fprintf(stderr,
"Error in %s: H2 self-shielding option 1 and primordial "
"chemistry options of 2 or more require that grid_dx "
"has a positive value.",
func_name);
return GR_FAIL;
}
}
return GR_SUCCESS;
}

} // namespace grackle::impl

#endif // SELF_SHIELDING_ERR_CHECK_HPP
9 changes: 5 additions & 4 deletions src/clib/solve_chemistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "grackle.h"
#include "internal_units.h"
#include "solve_rate_cool_g-cpp.h"
#include "self_shielding_err_check.hpp"
#include "update_UVbackground_rates.hpp"
#include "utils.h"

extern "C" int local_solve_chemistry(chemistry_data *my_chemistry,
chemistry_data_storage *my_rates,
Expand Down Expand Up @@ -75,9 +75,10 @@ extern "C" int local_solve_chemistry(chemistry_data *my_chemistry,
InternalGrUnits internalu = new_internalu_(my_units);

/* Error checking for H2 shielding approximation */
if (self_shielding_err_check(my_chemistry, my_fields,
"local_solve_chemistry") != GR_SUCCESS) {
return GR_SUCCESS;
if (grackle::impl::self_shielding_err_check(my_chemistry, my_fields,
"local_solve_chemistry")
!= GR_SUCCESS) {
return GR_FAIL;
}

/* Call the routine to solve cooling equations. */
Expand Down
40 changes: 0 additions & 40 deletions src/clib/utils.c

This file was deleted.

39 changes: 0 additions & 39 deletions src/clib/utils.h

This file was deleted.