forked from grackle-project/grackle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change was split off from GH PR grackle-project#197. This should be a lot easier to review in isolation (and I think that it is a generally useful change in its own right). Overview -------- The objective of this PR is conceptually very simple. It introduces the following function: ```c++ int gr_initialize_field_data(grackle_field_data *my_fields); ``` The idea is to have users immediately call this function right after they initialize a new `grackle_field_data` instance - When it's called the handful of non data-field members are assigned sensible defaults. It also initializes all data-field members to NULL pointers. - this is analogous to the way that `local_initialize_chemistry_parameters` is used. Motivation ---------- While this function is not strictly necessary, I think it is a useful addition and I think we should tell people to use it (though old code won't break). A large motivation is peace of mind. I have often wished for this sort of thing. I'm always a little concerned when using a new configuration of grackle that I didn't initialize all of the required fields. I would definitely feel a little more comfortable knowing that a field that I forgot about is assigned a ``NULL`` pointer rather than some garbage data that might let the code chug along. It could also facillitate more error checking: - such as checks in the style of the ``grid_dx`` check introduced in PR grackle-project#190 (applying similar checks to `grid_rank`, `grid_dimension`, `grid_start`, and `grid_end` requires that we know their default value). - we could explicitly check that the user specified all required data-fields. We can only do this if we know that unset data-fields have a default value of `NULL`. - **From a user friendliness perspective, I think this check alone is enough to justify the function's existence.** - We could also potentially warn if unnecessary fields were specified - Plus, we could account for the fact that functions like ``calculate_pressure`` require fewer fields that ``solve_chemistry`` - we could also add checks that none of the fields are aliases (an implicit Fortran requirement). This would be much easier to implement if we knew we could just ignore fields that were set to ``NULL`` pointers We would probably need to make these checks opt-in somehow, both because we can't be absolutely certain whether a user actually invoked ``gr_initialize_field_data`` and users might not want the runtime-cost (which could be relatively large for very small grids) Naming ------ I choose to name this function based on my suggestion in grackle-project#189 that we adopt a convention that all new functions in the stable public API share a common prefix (`gr_` or `grackle_`). For the sake of proposing something concrete, I assumed that we choose the `gr_` prefix. (If we decide on a different prefix, this would be easy to change). Alternatively, if we don't want any prefix, we could name it `initialize_grackle_field_data` (I do worry a little that could introduce naming conflicts with existing functions in downstream codes)
- Loading branch information
Showing
13 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/*********************************************************************** | ||
/ | ||
/ this file lists each member of the grackle_field_data struct that is | ||
/ intended to hold field data. This list is intended to be used with | ||
/ X-Macros in *.c files (to reduce the amount of code required to | ||
/ interact with these fields) | ||
/ | ||
/ The following information is specified for each field: | ||
/ 1. the field_name | ||
/ 2. a 1 or 0 to denote whether the field_name corresponds to a | ||
/ passive-scalar density field | ||
/ | ||
/ | ||
/ 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. | ||
************************************************************************/ | ||
|
||
ENTRY(density, 0) | ||
ENTRY(HI_density, 1) | ||
ENTRY(HII_density, 1) | ||
ENTRY(HM_density, 1) | ||
ENTRY(HeI_density, 1) | ||
ENTRY(HeII_density, 1) | ||
ENTRY(HeIII_density, 1) | ||
ENTRY(H2I_density, 1) | ||
ENTRY(H2II_density, 1) | ||
ENTRY(DI_density, 1) | ||
ENTRY(DII_density, 1) | ||
ENTRY(HDI_density, 1) | ||
ENTRY(e_density, 1) | ||
ENTRY(metal_density, 1) | ||
ENTRY(dust_density, 1) | ||
|
||
ENTRY(internal_energy, 0) | ||
ENTRY(x_velocity, 0) | ||
ENTRY(y_velocity, 0) | ||
ENTRY(z_velocity, 0) | ||
|
||
ENTRY(volumetric_heating_rate, 0) | ||
ENTRY(specific_heating_rate, 0) | ||
|
||
ENTRY(temperature_floor, 0) | ||
|
||
ENTRY(RT_heating_rate, 0) | ||
ENTRY(RT_HI_ionization_rate, 0) | ||
ENTRY(RT_HeI_ionization_rate, 0) | ||
ENTRY(RT_HeII_ionization_rate, 0) | ||
ENTRY(RT_H2_dissociation_rate, 0) | ||
|
||
ENTRY(H2_self_shielding_length, 0) | ||
ENTRY(H2_custom_shielding_factor, 0) | ||
|
||
ENTRY(isrf_habing, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters