[newchem-cpp] transcribe calc_tdust_3d#385
Conversation
The main goal is to construct an instance of `InternalGrUnits` that will be passed into `calc_tdust_3d_g`, once it is transcribed. `local_calculate_cooling_time`, `local_calculate_temperature`, and `local_solve_chemistry` similarly pass instances of `InternalGrUnits` into functions that have already been transcribed from Fortran. When I added `#include "internal_units.h"`, I decided to also replace 2 existing include directives with `#include "grackle.h"` - this is a convention I have been moving us towards (it lets us avoid multiple copies of some function declarations and we will be moving the replaced headers in future releases) - I removed all the declarations now made redundant by "grackle.h" I also removed both `#include "phys_constants.h"` and `#include <omp.h>` since they are entirely unnecessary (as far as I can tell, they have never, ever been used!)
I essentially started to use ``grackle_index_helper`` & ``idx_range``: - I localized declarations of variables that are provided by these types - loops over ``i`` now access bounds from ``idx_range.i_start`` and ``idx_range.i_stop``
As per usual, we aggregate all of the scratch buffers for temporarily storing grain temperatures within a `GrainSpeciesCollection` type. The first 3 parts of this commit were manual: - I removed the declarations of tSiM, tFeM, ... tH2Oice vectors - I inserted the declaration/allocation of the grain_temperatures scratch buffer collection - I called the function to free the memory associated with grain_temperatures The 4th and final part of this commit was accomplished with the commnd: ``` $ sed -f cleanup_tgrain.sed -i \.backup calc_tdust_3d.C ``` This command replaced ``calc_tdust_3d.C`` and stored a backup at ``calc_tdust_3d.C.backup``. The command made use of the ``cleanup_tgrain.sed`` script that contained a bunch of sed commands. The contents of this file are shown down below: ``` s/tSiM\.data()/grain_temperatures\.data[OnlyGrainSpLUT::SiM_dust]/g s/tFeM\.data()/grain_temperatures\.data[OnlyGrainSpLUT::FeM_dust]/g s/tMg2SiO4\.data()/grain_temperatures.data[OnlyGrainSpLUT::Mg2SiO4_dust]/g s/tMgSiO3\.data()/grain_temperatures.data[OnlyGrainSpLUT::MgSiO3_dust]/g s/tFe3O4\.data()/grain_temperatures.data[OnlyGrainSpLUT::Fe3O4_dust]/g s/tAC\.data()/grain_temperatures.data[OnlyGrainSpLUT::AC_dust]/g s/tSiO2D\.data()/grain_temperatures.data[OnlyGrainSpLUT::SiO2_dust]/g s/tMgO\.data()/grain_temperatures.data[OnlyGrainSpLUT::MgO_dust]/g s/tFeS\.data()/grain_temperatures.data[OnlyGrainSpLUT::FeS_dust]/g s/tAl2O3\.data()/grain_temperatures.data[OnlyGrainSpLUT::Al2O3_dust]/g s/treforg\.data()/grain_temperatures.data[OnlyGrainSpLUT::ref_org_dust]/g s/tvolorg\.data()/grain_temperatures.data[OnlyGrainSpLUT::vol_org_dust]/g s/tH2Oice\.data()/grain_temperatures.data[OnlyGrainSpLUT::H2O_ice_dust]/g s/tSiM[[:space:]]*\[/grain_temperatures\.data[OnlyGrainSpLUT::SiM_dust][/g s/tFeM[[:space:]]*\[/grain_temperatures\.data[OnlyGrainSpLUT::FeM_dust][/g s/tMg2SiO4[[:space:]]*\[/grain_temperatures.data[OnlyGrainSpLUT::Mg2SiO4_dust][/g s/tMgSiO3[[:space:]]*\[/grain_temperatures.data[OnlyGrainSpLUT::MgSiO3_dust][/g s/tFe3O4[[:space:]]*\[/grain_temperatures.data[OnlyGrainSpLUT::Fe3O4_dust][/g s/tAC[[:space:]]*\[/grain_temperatures.data[OnlyGrainSpLUT::AC_dust][/g s/tSiO2D[[:space:]]*\[/grain_temperatures.data[OnlyGrainSpLUT::SiO2_dust][/g s/tMgO[[:space:]]*\[/grain_temperatures.data[OnlyGrainSpLUT::MgO_dust][/g s/tFeS[[:space:]]*\[/grain_temperatures.data[OnlyGrainSpLUT::FeS_dust][/g s/tAl2O3[[:space:]]*\[/grain_temperatures.data[OnlyGrainSpLUT::Al2O3_dust][/g s/treforg[[:space:]]*\[/grain_temperatures.data[OnlyGrainSpLUT::ref_org_dust][/g s/tvolorg[[:space:]]*\[/grain_temperatures.data[OnlyGrainSpLUT::vol_org_dust][/g s/tH2Oice[[:space:]]*\[/grain_temperatures.data[OnlyGrainSpLUT::H2O_ice_dust][/g ```
We aggregate all of the scratch buffers for temporarily storing the "geometric cross section per unit gas mass" within as members of the `InternalDustPropBuf` type. Most of these buffers are stored within a member of type `GrainSpeciesCollection` called `grain_sigma_per_gas_mass`. The first 4 parts of this commit were manual: - I removed the declarations of sgSiM, sgFeM, ... sgH2Oice vectors - I inserted the declaration/allocation of the internal_dust_prop_buf.grain_sigma_per_gas_mass scratch buffer collection - I called the function to free the memory associated with internal_dust_prop_buf.grain_sigma_per_gas_mass - I moved the `sgtot` buffer into `InternalDustPropBuf` and renamed it so that it is now the `sigma_per_gas_mass_tot` member The 5th and final part of this commit was accomplished with the commnd: ``` $ sed -f cleanup_sggrain.sed -i \.backup calc_tdust_3d.C ``` This command replaced ``calc_tdust_3d.C`` and stored a backup at ``calc_tdust_3d.C.backup``. The command made use of the ``cleanup_sggrain.sed`` script that contained a bunch of sed commands. The contents of this file are shown down below: ``` s/sgSiM\.data()/internal_dust_prop_buf.grain_sigma_per_gas_mass\.data[OnlyGrainSpLUT::SiM_dust]/g s/sgFeM\.data()/internal_dust_prop_buf.grain_sigma_per_gas_mass\.data[OnlyGrainSpLUT::FeM_dust]/g s/sgMg2SiO4\.data()/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust]/g s/sgMgSiO3\.data()/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust]/g s/sgFe3O4\.data()/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust]/g s/sgAC\.data()/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust]/g s/sgSiO2D\.data()/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust]/g s/sgMgO\.data()/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust]/g s/sgFeS\.data()/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust]/g s/sgAl2O3\.data()/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust]/g s/sgreforg\.data()/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust]/g s/sgvolorg\.data()/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust]/g s/sgH2Oice\.data()/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust]/g s/sgtot\.data()/internal_dust_prop_buf.sigma_per_gas_mass_tot/g s/sgSiM[[:space:]]*\[/internal_dust_prop_buf.grain_sigma_per_gas_mass\.data[OnlyGrainSpLUT::SiM_dust][/g s/sgFeM[[:space:]]*\[/internal_dust_prop_buf.grain_sigma_per_gas_mass\.data[OnlyGrainSpLUT::FeM_dust][/g s/sgMg2SiO4[[:space:]]*\[/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Mg2SiO4_dust][/g s/sgMgSiO3[[:space:]]*\[/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgSiO3_dust][/g s/sgFe3O4[[:space:]]*\[/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Fe3O4_dust][/g s/sgAC[[:space:]]*\[/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::AC_dust][/g s/sgSiO2D[[:space:]]*\[/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::SiO2_dust][/g s/sgMgO[[:space:]]*\[/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::MgO_dust][/g s/sgFeS[[:space:]]*\[/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::FeS_dust][/g s/sgAl2O3[[:space:]]*\[/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::Al2O3_dust][/g s/sgreforg[[:space:]]*\[/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::ref_org_dust][/g s/sgvolorg[[:space:]]*\[/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::vol_org_dust][/g s/sgH2Oice[[:space:]]*\[/internal_dust_prop_buf.grain_sigma_per_gas_mass.data[OnlyGrainSpLUT::H2O_ice_dust][/g s/sgtot[[:space:]]*\[/internal_dust_prop_buf.sigma_per_gas_mass_tot[/g ```
We aggregate all of the scratch buffers for storing dynamically computed tables of opacity coefficients at each zone for an IndexRange within members of the `InternalDustPropBuf` type. The buffers (previously called `alSiM`, `alFeM`, ..., `alH2Oice`) are stored within a member of type `GrainSpeciesCollection` called `internal_dust_prop_buf.grain_dyntab_kappa`. It's pretty obvious that this is a significant change in the naming convention. The documentation of the `InternalDustPropBuf` provides significant justification for this -- once you fully understand how the variables get used, it becomes clear that the old naming convention was VERY confusing. (we should maintain this documentation until dust-routines get transcribed!) The first 4 parts of this commit were manual: - I removed the declarations of `alSiM`, `alFeM`, ..., `alH2Oice` vectors - I inserted the declaration/allocation of the `internal_dust_prop_buf.grain_dyntab_kappa` scratch buffer collection - I called the function to free the memory associated with `internal_dust_prop_buf.grain_dyntab_kappa` - I moved the `altot` buffer into `InternalDustPropBuf` and renamed it so that it is now the `dyntab_kappa_tot` member The 5th and final part of this commit was accomplished with the command: ``` $ sed -f cleanup_algrain.sed -i \.backup calc_tdust_3d.C ``` This command replaced ``calc_tdust_3d.C`` and stored a backup at ``calc_tdust_3d.C.backup``. The command made use of the ``cleanup_algrain.sed`` script that contained a bunch of sed commands. The contents of this file are shown down below: ``` s/alSiM\.data()/internal_dust_prop_buf.grain_dyntab_kappa\.data[OnlyGrainSpLUT::SiM_dust]/g s/alFeM\.data()/internal_dust_prop_buf.grain_dyntab_kappa\.data[OnlyGrainSpLUT::FeM_dust]/g s/alMg2SiO4\.data()/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust]/g s/alMgSiO3\.data()/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgSiO3_dust]/g s/alFe3O4\.data()/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Fe3O4_dust]/g s/alAC\.data()/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::AC_dust]/g s/alSiO2D\.data()/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust]/g s/alMgO\.data()/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust]/g s/alFeS\.data()/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust]/g s/alAl2O3\.data()/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Al2O3_dust]/g s/alreforg\.data()/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::ref_org_dust]/g s/alvolorg\.data()/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::vol_org_dust]/g s/alH2Oice\.data()/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust]/g s/altot\.data()/internal_dust_prop_buf.dyntab_kappa_tot/g s/alSiM[[:space:]]*\[/internal_dust_prop_buf.grain_dyntab_kappa\.data[OnlyGrainSpLUT::SiM_dust][/g s/alFeM[[:space:]]*\[/internal_dust_prop_buf.grain_dyntab_kappa\.data[OnlyGrainSpLUT::FeM_dust][/g s/alMg2SiO4[[:space:]]*\[/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust][/g s/alMgSiO3[[:space:]]*\[/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgSiO3_dust][/g s/alFe3O4[[:space:]]*\[/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Fe3O4_dust][/g s/alAC[[:space:]]*\[/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::AC_dust][/g s/alSiO2D[[:space:]]*\[/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::SiO2_dust][/g s/alMgO[[:space:]]*\[/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::MgO_dust][/g s/alFeS[[:space:]]*\[/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::FeS_dust][/g s/alAl2O3[[:space:]]*\[/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::Al2O3_dust][/g s/alreforg[[:space:]]*\[/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::ref_org_dust][/g s/alvolorg[[:space:]]*\[/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::vol_org_dust][/g s/alH2Oice[[:space:]]*\[/internal_dust_prop_buf.grain_dyntab_kappa.data[OnlyGrainSpLUT::H2O_ice_dust][/g s/altot[[:space:]]*\[/internal_dust_prop_buf.dyntab_kappa_tot/g ```
As is a common convention, we aggregate all of the scratch buffers for temporarily storing grain-related quantity within a `GrainSpeciesCollection` type. In this case we are aggregating buffers used to hold the opacity coefficient The first 3 parts of this commit were manual: - I removed the declarations of `kpSiM`, `kpFeM`, ..., `kpH2Oice` vectors - I inserted the declaration/allocation of the `grain_kappa` scratch buffer collection - I called the function to free the memory associated with grain_kappa The 4th and final part of this commit was accomplished with the commnd: ``` $ sed -f cleanup_kpgrain.sed -i \.backup calc_tdust_3d.C ``` This command replaced ``calc_tdust_3d.C`` and stored a backup at ``calc_tdust_3d.C.backup``. The command made use of the ``cleanup_kpgrain.sed`` script that contained a bunch of sed commands. The contents of this file are shown down below: ``` s/kpSiM\.data()/grain_kappa\.data[OnlyGrainSpLUT::SiM_dust]/g s/kpFeM\.data()/grain_kappa\.data[OnlyGrainSpLUT::FeM_dust]/g s/kpMg2SiO4\.data()/grain_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust]/g s/kpMgSiO3\.data()/grain_kappa.data[OnlyGrainSpLUT::MgSiO3_dust]/g s/kpFe3O4\.data()/grain_kappa.data[OnlyGrainSpLUT::Fe3O4_dust]/g s/kpAC\.data()/grain_kappa.data[OnlyGrainSpLUT::AC_dust]/g s/kpSiO2D\.data()/grain_kappa.data[OnlyGrainSpLUT::SiO2_dust]/g s/kpMgO\.data()/grain_kappa.data[OnlyGrainSpLUT::MgO_dust]/g s/kpFeS\.data()/grain_kappa.data[OnlyGrainSpLUT::FeS_dust]/g s/kpAl2O3\.data()/grain_kappa.data[OnlyGrainSpLUT::Al2O3_dust]/g s/kpreforg\.data()/grain_kappa.data[OnlyGrainSpLUT::ref_org_dust]/g s/kpvolorg\.data()/grain_kappa.data[OnlyGrainSpLUT::vol_org_dust]/g s/kpH2Oice\.data()/grain_kappa.data[OnlyGrainSpLUT::H2O_ice_dust]/g s/kptot\.data()/kappa_tot\.data()/g s/kpSiM[[:space:]]*\[/grain_kappa\.data[OnlyGrainSpLUT::SiM_dust][/g s/kpFeM[[:space:]]*\[/grain_kappa\.data[OnlyGrainSpLUT::FeM_dust][/g s/kpMg2SiO4[[:space:]]*\[/grain_kappa.data[OnlyGrainSpLUT::Mg2SiO4_dust][/g s/kpMgSiO3[[:space:]]*\[/grain_kappa.data[OnlyGrainSpLUT::MgSiO3_dust][/g s/kpFe3O4[[:space:]]*\[/grain_kappa.data[OnlyGrainSpLUT::Fe3O4_dust][/g s/kpAC[[:space:]]*\[/grain_kappa.data[OnlyGrainSpLUT::AC_dust][/g s/kpSiO2D[[:space:]]*\[/grain_kappa.data[OnlyGrainSpLUT::SiO2_dust][/g s/kpMgO[[:space:]]*\[/grain_kappa.data[OnlyGrainSpLUT::MgO_dust][/g s/kpFeS[[:space:]]*\[/grain_kappa.data[OnlyGrainSpLUT::FeS_dust][/g s/kpAl2O3[[:space:]]*\[/grain_kappa.data[OnlyGrainSpLUT::Al2O3_dust][/g s/kpreforg[[:space:]]*\[/grain_kappa.data[OnlyGrainSpLUT::ref_org_dust][/g s/kpvolorg[[:space:]]*\[/grain_kappa.data[OnlyGrainSpLUT::vol_org_dust][/g s/kpH2Oice[[:space:]]*\[/grain_kappa.data[OnlyGrainSpLUT::H2O_ice_dust][/g s/kptot[[:space:]]*\[/kappa_tot[/g ```
As is a common convention, we aggregate all of the scratch buffers for temporarily storing grain-related quantity within a `GrainSpeciesCollection` type. In this case we are aggregating buffers used to hold the gas/grain-species heat transfer rate The first 3 parts of this commit were manual: - I removed the declarations of `gasSiM`, `gasFeM`, ... `gasH2Oice` vectors - I inserted the declaration/allocation of the `gas_grainsp_heatrate` scratch buffer collection - I called the function to free the memory associated with `gas_grainsp_heatrate` The 4th and final part of this commit was accomplished with the commnd: ``` $ sed -f cleanup_gasgrain.sed -i \.backup calc_tdust_3d.C ``` This command replaced ``calc_tdust_3d.C`` and stored a backup at ``calc_tdust_3d.C.backup``. The command made use of the ``cleanup_kpgrain.sed`` script that contained a bunch of sed commands. The contents of this file are shown down below: ``` s/gasSiM\.data()/gas_grainsp_heatrate\.data[OnlyGrainSpLUT::SiM_dust]/g s/gasFeM\.data()/gas_grainsp_heatrate\.data[OnlyGrainSpLUT::FeM_dust]/g s/gasMg2SiO4\.data()/gas_grainsp_heatrate.data[OnlyGrainSpLUT::Mg2SiO4_dust]/g s/gasMgSiO3\.data()/gas_grainsp_heatrate.data[OnlyGrainSpLUT::MgSiO3_dust]/g s/gasFe3O4\.data()/gas_grainsp_heatrate.data[OnlyGrainSpLUT::Fe3O4_dust]/g s/gasAC\.data()/gas_grainsp_heatrate.data[OnlyGrainSpLUT::AC_dust]/g s/gasSiO2D\.data()/gas_grainsp_heatrate.data[OnlyGrainSpLUT::SiO2_dust]/g s/gasMgO\.data()/gas_grainsp_heatrate.data[OnlyGrainSpLUT::MgO_dust]/g s/gasFeS\.data()/gas_grainsp_heatrate.data[OnlyGrainSpLUT::FeS_dust]/g s/gasAl2O3\.data()/gas_grainsp_heatrate.data[OnlyGrainSpLUT::Al2O3_dust]/g s/gasreforg\.data()/gas_grainsp_heatrate.data[OnlyGrainSpLUT::ref_org_dust]/g s/gasvolorg\.data()/gas_grainsp_heatrate.data[OnlyGrainSpLUT::vol_org_dust]/g s/gasH2Oice\.data()/gas_grainsp_heatrate.data[OnlyGrainSpLUT::H2O_ice_dust]/g s/gasSiM[[:space:]]*\[/gas_grainsp_heatrate\.data[OnlyGrainSpLUT::SiM_dust][/g s/gasFeM[[:space:]]*\[/gas_grainsp_heatrate\.data[OnlyGrainSpLUT::FeM_dust][/g s/gasMg2SiO4[[:space:]]*\[/gas_grainsp_heatrate.data[OnlyGrainSpLUT::Mg2SiO4_dust][/g s/gasMgSiO3[[:space:]]*\[/gas_grainsp_heatrate.data[OnlyGrainSpLUT::MgSiO3_dust][/g s/gasFe3O4[[:space:]]*\[/gas_grainsp_heatrate.data[OnlyGrainSpLUT::Fe3O4_dust][/g s/gasAC[[:space:]]*\[/gas_grainsp_heatrate.data[OnlyGrainSpLUT::AC_dust][/g s/gasSiO2D[[:space:]]*\[/gas_grainsp_heatrate.data[OnlyGrainSpLUT::SiO2_dust][/g s/gasMgO[[:space:]]*\[/gas_grainsp_heatrate.data[OnlyGrainSpLUT::MgO_dust][/g s/gasFeS[[:space:]]*\[/gas_grainsp_heatrate.data[OnlyGrainSpLUT::FeS_dust][/g s/gasAl2O3[[:space:]]*\[/gas_grainsp_heatrate.data[OnlyGrainSpLUT::Al2O3_dust][/g s/gasreforg[[:space:]]*\[/gas_grainsp_heatrate.data[OnlyGrainSpLUT::ref_org_dust][/g s/gasvolorg[[:space:]]*\[/gas_grainsp_heatrate.data[OnlyGrainSpLUT::vol_org_dust][/g s/gasH2Oice[[:space:]]*\[/gas_grainsp_heatrate.data[OnlyGrainSpLUT::H2O_ice_dust][/g ```
…nscribe/calc_tdust_3d
|
|
||
| if (imetal == 1) { | ||
| for (int i = idx_range.i_start; i < idx_range.i_stop; i++) { | ||
| metal(i,j,k) = metal(i,j,k)/(gr_float)(std::pow(internalu.a_value,3) ); |
There was a problem hiding this comment.
Is this calling out for a generic scale_field function that accepts a generic field array and scales it?
There was a problem hiding this comment.
I'm not really sure. I was thinking that maybe we want to focus on relocating all of the rescaling logic (used at every "entry-point") into a single file and then figure out what the best thing to do is from there. #386 moves in that direction
| if (imetal == 1) { | ||
| metallicity[i] = metal(i,j,k) / d(i,j,k) / my_chemistry->SolarMetalFractionByMass; | ||
| } |
There was a problem hiding this comment.
I realize this is a direct transcription, but I'm just making notes. I can't imagine any scenario where we are calculating dust temperatures without metal fields present. When this gets refactored, I think we should be stopping well short of this portion of the code if imetal is 0.
| } else { | ||
| dust2gas[i] = my_chemistry->local_dust_to_gas_ratio * metallicity[i]; | ||
| } |
There was a problem hiding this comment.
Just noticing that we assume imetal == 1 here.
This was originally proposed as brittonsmith#40
This must be reviewed after #383 has been merged
This PR transcribes
calc_tdust_3dfrom Fortran to C++. This was the last of the top-level Fortran routines to be translated.Figuring out how a bunch of the variables got used (so we could logically aggregate the variables) was fairly tedious. In fact the immediate impetus for making this PR was my review of brittonsmith#39, where I wanted to give recommendation on how to organize the same variables. The whole process was so involved, I wanted to put together this PR before I lost my train of thought (and so I could make more concrete suggestions).1
A little bit of cleanup is performed in the followup PR, #386.
NOTE: I have not run the OpenMP tests. I'm pretty confident that the transcribed code is all valid. But, since Gen broke OpenMP support, I have not been tempted to test it yet. The fact that I have been developing on MacOS complicates this to some degree2
Footnotes
In particular, understanding the purpose and use of the
alSiM,alFeM, ...,alH2Oicefamily of variables were especially annoying. These were named in a particularly confusing way that made it impossible to understand how they related to thekpSiM,kpFeM, ...,kpH2Oicefamily of variables without fully digging in. (I suspect my frustration comes through, to some degree in some of the code comments) ↩I think it should definitely be possible using a compiler other than the built-in apple-clang compilers. But, I haven't gotten a chance to dig into this. I suspect this will easier to deal with once we have removed the last of the Fortran code that references OpenMP. ↩