From 7a49ef5bb659f17110b6cb1984fd49784ccde3db Mon Sep 17 00:00:00 2001 From: t-barnard Date: Wed, 1 Oct 2025 15:09:37 -0400 Subject: [PATCH 1/3] Change grid to pass by reference in solvers.h functions --- include/solvers.h | 35 ++++++++++++++++++----------------- src/solver_gradients.cpp | 39 ++++++++++++++++++++++++++------------- 2 files changed, 44 insertions(+), 30 deletions(-) diff --git a/include/solvers.h b/include/solvers.h index 4e5ebb6f..c8a90121 100644 --- a/include/solvers.h +++ b/include/solvers.h @@ -83,23 +83,24 @@ fmat interpolate_1d_w_index(std::vector values, double interpolation_index, int interpolation_type); -arma_cube calc_gradient_lon(arma_cube value, Grid grid); -arma_cube calc_gradient_lat(arma_cube value, Grid grid); -arma_cube calc_gradient_alt(arma_cube value, Grid grid); -std::vector calc_gradient_vector(arma_cube value_scgc, Grid grid); -std::vector calc_gradient_cubesphere(arma_cube value, Grid grid); -arma_cube calc_gradient_alt_4th(arma_cube value, Grid grid); -arma_mat project_onesided_alt_3rd(arma_cube value, Grid grid, int64_t iAlt); +arma_cube calc_gradient_lon(arma_cube value, Grid &grid); +arma_cube calc_gradient_lat(arma_cube value, Grid &grid); +arma_cube calc_gradient_alt(arma_cube value, Grid &grid); +// std::vector calc_gradient_vector(arma_cube value_scgc, Grid grid); +void calc_gradient_vector(arma_cube value_scgc, Grid &grid, std::vector &gradient_vcgc); +std::vector calc_gradient_cubesphere(arma_cube value, Grid &grid); +arma_cube calc_gradient_alt_4th(arma_cube value, Grid &grid); +arma_mat project_onesided_alt_3rd(arma_cube value, Grid &grid, int64_t iAlt); // Calculate 4th-order gradients in the native coordinate system: -arma_cube calc_gradient4o_i(arma_cube value, Grid grid); -arma_cube calc_gradient4o_j(arma_cube value, Grid grid); -arma_cube calc_gradient4o_k(arma_cube value, Grid grid); +arma_cube calc_gradient4o_i(arma_cube value, Grid &grid); +arma_cube calc_gradient4o_j(arma_cube value, Grid &grid); +arma_cube calc_gradient4o_k(arma_cube value, Grid &grid); // Calculate 2nd-order gradients in the native coordinate system: -arma_cube calc_gradient2o_i(arma_cube value, Grid grid); -arma_cube calc_gradient2o_j(arma_cube value, Grid grid); -arma_cube calc_gradient2o_k(arma_cube value, Grid grid); +arma_cube calc_gradient2o_i(arma_cube value, Grid &grid); +arma_cube calc_gradient2o_j(arma_cube value, Grid &grid); +arma_cube calc_gradient2o_k(arma_cube value, Grid &grid); // interpolation in 1D precision_t linear_interpolation(const precision_t y0, @@ -122,9 +123,9 @@ precision_t limiter_mc(precision_t dUp, \param dt returns the neutral time-step \param grid The grid to define the neutrals on **/ - precision_t calc_dt(Grid grid, std::vector cMax_vcgc); - precision_t calc_dt_sphere(Grid grid, std::vector cMax_vcgc); - precision_t calc_dt_cubesphere(Grid grid, std::vector cMax_vcgc); - precision_t calc_dt_vertical(Grid grid, std::vector cMax_vcgc); + precision_t calc_dt(Grid &grid, std::vector cMax_vcgc); + precision_t calc_dt_sphere(Grid &grid, std::vector cMax_vcgc); + precision_t calc_dt_cubesphere(Grid &grid, std::vector cMax_vcgc); + precision_t calc_dt_vertical(Grid &grid, std::vector cMax_vcgc); #endif // INCLUDE_SOLVERS_H_ diff --git a/src/solver_gradients.cpp b/src/solver_gradients.cpp index 6843eaa3..5d21eb6a 100644 --- a/src/solver_gradients.cpp +++ b/src/solver_gradients.cpp @@ -8,7 +8,7 @@ // It is assumed that this is lon, lat, rad // -------------------------------------------------------------------------- -std::vector calc_gradient_vector(arma_cube value_scgc, Grid grid) { +std::vector calc_gradient_vector(arma_cube value_scgc, Grid &grid) { std::vector gradient_vcgc; @@ -56,7 +56,11 @@ std::vector calc_gradient_vector(arma_cube value_scgc, Grid grid) { // - these formulas assume that the grid is uniform. // -------------------------------------------------------------------------- -arma_cube calc_gradient2o_i(arma_cube value, Grid grid) { +arma_cube calc_gradient2o_i(arma_cube value, Grid &grid) { + + std::string function = "calc_gradient2o_i"; + static int iFunction = -1; + report.enter(function, iFunction); int64_t nX = grid.get_nX(); int64_t nY = grid.get_nY(); @@ -85,7 +89,7 @@ arma_cube calc_gradient2o_i(arma_cube value, Grid grid) { (value.row(iX) - value.row(iX - 1)) / grid.di_center_m_scgc.row(iX); } - + report.exit(function); return gradient; } @@ -94,7 +98,7 @@ arma_cube calc_gradient2o_i(arma_cube value, Grid grid) { // - these formulas assume that the grid is uniform. // -------------------------------------------------------------------------- -arma_cube calc_gradient4o_i(arma_cube value, Grid grid) { +arma_cube calc_gradient4o_i(arma_cube value, Grid &grid) { int64_t nX = grid.get_nX(); int64_t nY = grid.get_nY(); @@ -182,7 +186,7 @@ arma_cube calc_gradient_stretched_i(arma_cube value, Grid grid) { // Calculate the gradient in the longitudinal direction // -------------------------------------------------------------------------- -arma_cube calc_gradient_lon(arma_cube value, Grid grid) { +arma_cube calc_gradient_lon(arma_cube value, Grid &grid) { return calc_gradient2o_i(value, grid); } @@ -191,7 +195,11 @@ arma_cube calc_gradient_lon(arma_cube value, Grid grid) { // - these formulas assume that the grid is uniform. // -------------------------------------------------------------------------- -arma_cube calc_gradient2o_j(arma_cube value, Grid grid) { +arma_cube calc_gradient2o_j(arma_cube value, Grid &grid) { + + std::string function = "calc_gradient2o_j"; + static int iFunction = -1; + report.enter(function, iFunction); int64_t nX = grid.get_nX(); int64_t nY = grid.get_nY(); @@ -220,7 +228,7 @@ arma_cube calc_gradient2o_j(arma_cube value, Grid grid) { (value.col(iY) - value.col(iY - 1)) / grid.dj_center_m_scgc.col(iY); } - + report.exit(function); return gradient; } @@ -229,7 +237,7 @@ arma_cube calc_gradient2o_j(arma_cube value, Grid grid) { // - these formulas assume that the grid is uniform. // -------------------------------------------------------------------------- -arma_cube calc_gradient4o_j(arma_cube value, Grid grid) { +arma_cube calc_gradient4o_j(arma_cube value, Grid &grid) { int64_t nX = grid.get_nX(); int64_t nY = grid.get_nY(); @@ -317,7 +325,7 @@ arma_cube calc_gradient_stretched_j(arma_cube value, Grid grid) { // Calculate the gradient in the latitudinal direction // -------------------------------------------------------------------------- -arma_cube calc_gradient_lat(arma_cube value, Grid grid) { +arma_cube calc_gradient_lat(arma_cube value, Grid &grid) { return calc_gradient2o_j(value, grid); } @@ -325,7 +333,11 @@ arma_cube calc_gradient_lat(arma_cube value, Grid grid) { // Calculate the gradient in the altitudinal direction // -------------------------------------------------------------------------- -arma_cube calc_gradient_alt(arma_cube value, Grid grid) { +arma_cube calc_gradient_alt(arma_cube value, Grid &grid) { + + std::string function = "calc_gradient_alt"; + static int iFunction = -1; + report.enter(function, iFunction); int64_t nX = grid.get_nLons(); int64_t nY = grid.get_nLats(); @@ -358,6 +370,7 @@ arma_cube calc_gradient_alt(arma_cube value, Grid grid) { (value.slice(iK) - value.slice(iK - 1)) / grid.dk_edge_m.slice(iK); } + report.exit(function); return gradient; } @@ -366,7 +379,7 @@ arma_cube calc_gradient_alt(arma_cube value, Grid grid) { // Calculate the 4th order gradient in the altitudinal direction // -------------------------------------------------------------------------- -arma_cube calc_gradient_alt_4th(arma_cube value, Grid grid) { +arma_cube calc_gradient_alt_4th(arma_cube value, Grid &grid) { int64_t nLons = grid.get_nLons(); int64_t nLats = grid.get_nLats(); @@ -393,7 +406,7 @@ arma_cube calc_gradient_alt_4th(arma_cube value, Grid grid) { // - this is only defined for the bottom ghostcells! // -------------------------------------------------------------------------- -arma_mat project_onesided_alt_3rd(arma_cube value, Grid grid, int64_t iAlt) { +arma_mat project_onesided_alt_3rd(arma_cube value, Grid &grid, int64_t iAlt) { int64_t nLons = grid.get_nLons(); int64_t nLats = grid.get_nLats(); @@ -418,7 +431,7 @@ arma_mat project_onesided_alt_3rd(arma_cube value, Grid grid, int64_t iAlt) { // -------------------------------------------------------------------------- // Calculate the gradient in cubesphere spatial discretization // -------------------------------------------------------------------------- -std::vector calc_gradient_cubesphere(arma_cube value, Grid grid) { +std::vector calc_gradient_cubesphere(arma_cube value, Grid &grid) { // Must be used for cubesphere (Probably need a boolean check) int64_t nXs = grid.get_nY(); int64_t nYs = grid.get_nX(); From 819e68bc06fa02f9904ca17c5440e9ce1b441dc1 Mon Sep 17 00:00:00 2001 From: t-barnard Date: Wed, 1 Oct 2025 15:12:11 -0400 Subject: [PATCH 2/3] Added new timing function and option to use old timing function --- CMakeLists.txt | 8 ++++++++ include/report.h | 5 +++++ src/report.cpp | 20 ++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a479a1fe..17159e86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,6 +100,14 @@ if (USE_NETCDF) target_link_libraries(aether PUBLIC ${NETCDF_LIBRARIES_C}) endif() +# use_old_timing +# cmake -DUSE_OLD_TIMING=ON .. +option(USE_OLD_TIMING "Use old timing for performance - default is off" OFF) +if (USE_OLD_TIMING) + add_definitions(-DOLD_TIMING) + set(OLD_TIMING "YES") +endif() + # Set up links for executable file(CREATE_LINK ${CMAKE_BINARY_DIR}/aether ${PROJECT_SOURCE_DIR}/share/run/aether SYMBOLIC) diff --git a/include/report.h b/include/report.h index e29696eb..892c65f1 100644 --- a/include/report.h +++ b/include/report.h @@ -23,6 +23,7 @@ #include #include #include +#include #include "aether.h" @@ -211,6 +212,8 @@ class Report { precision_t timing_total; /// This is the start-gate for the timer unsigned long long timing_start; + + struct timeval timing_start_new; /// This is the level of the function that is then compared to verbose int iLevel; /// This is a string that holds all of the function names above this one @@ -250,6 +253,8 @@ class Report { std::string error; }; + struct timeval start, end; + //Vector of error structs std::vector error_list; }; diff --git a/src/report.cpp b/src/report.cpp index 29bbc129..fc4b4f14 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -75,12 +75,20 @@ void Report::enter(std::string input, int &iFunction) { iVerbose = entries[iEntry].iFunctionVerbose; + #ifdef OLD_TIMING // This was taken from // https://stackoverflow.com/questions/19555121/how-to-get-current-timestamp-in-milliseconds-since-1970-just-the-way-java-gets unsigned long long now = std::chrono::duration_cast (std::chrono::system_clock::now().time_since_epoch()).count(); entries[iEntry].timing_start = now; + + #else//New timing + gettimeofday(&start, NULL); + entries[iEntry].timing_start_new = start; + + #endif + iLevel++; entries[iEntry].iLevel = iLevel; iCurrentFunction = iEntry; @@ -110,6 +118,7 @@ void Report::exit(std::string input) { if (DoReportOnExit) print(iLevel, "Exiting function : " + current_entry); + #ifdef OLD_TIMING // Get current system time: unsigned long long now = std::chrono::duration_cast (std::chrono::system_clock::now().time_since_epoch()).count(); @@ -118,6 +127,17 @@ void Report::exit(std::string input) { entries[iEntry].timing_total = entries[iEntry].timing_total + float(now - entries[iEntry].timing_start) / 1000.0; + #else //new timing + gettimeofday(&end, NULL); + start = entries[iEntry].timing_start_new; + long seconds = end.tv_sec - start.tv_sec; + long microseconds = end.tv_usec - start.tv_usec; + long elapsed_micro = seconds * 1000000 + microseconds; + precision_t elapsed_sec = elapsed_micro / 1000000.0; + + entries[iEntry].timing_total = entries[iEntry].timing_total + elapsed_sec; + #endif + // Increment the total number of times that the function has been called: entries[iEntry].nTimes++; From 3626e2a75a5c804da8e3222a008c96abf619b1fc Mon Sep 17 00:00:00 2001 From: t-barnard Date: Thu, 13 Nov 2025 12:30:16 -0500 Subject: [PATCH 3/3] change calls to grid, ion, neutral , etc. to references --- include/aurora.h | 2 +- include/calc_euv.h | 2 +- include/chemistry.h | 2 +- include/ions.h | 28 ++++++++++++------------- include/neutrals.h | 32 ++++++++++++++--------------- src/add_sources.cpp | 2 +- src/aurora.cpp | 2 +- src/calc_chemistry.cpp | 2 +- src/calc_dt.cpp | 8 ++++---- src/calc_electron_temperature.cpp | 2 +- src/calc_euv.cpp | 2 +- src/calc_ion_drift.cpp | 4 ++-- src/calc_ion_temperature.cpp | 4 ++-- src/calc_neutral_derived.cpp | 4 ++-- src/ions_advect.cpp | 2 +- src/ions_bcs.cpp | 6 +++--- src/neutrals.cpp | 8 ++++---- src/neutrals_advect.cpp | 2 +- src/neutrals_bcs.cpp | 8 ++++---- src/neutrals_energy.cpp | 2 +- src/neutrals_ics.cpp | 2 +- src/neutrals_momentum_viscosity.cpp | 2 +- src/solver_vertical_rusanov.cpp | 4 ++-- 23 files changed, 66 insertions(+), 66 deletions(-) diff --git a/include/aurora.h b/include/aurora.h index 75889cc9..f09c27f7 100644 --- a/include/aurora.h +++ b/include/aurora.h @@ -31,7 +31,7 @@ arma_vec calculate_fang(float eflux, // in ergs/cm2/s * param ions the class that contains all info about the ions **/ -void calc_aurora(Grid grid, +void calc_aurora(Grid &grid, Neutrals &neutrals, Ions &ions); diff --git a/include/calc_euv.h b/include/calc_euv.h index 561930a2..2de06b18 100644 --- a/include/calc_euv.h +++ b/include/calc_euv.h @@ -21,7 +21,7 @@ // ------------------------------------------------------------------------- bool calc_euv(Planets planet, - Grid grid, + Grid &grid, Times time, Euv &euv, Neutrals &neutrals, diff --git a/include/chemistry.h b/include/chemistry.h index 118d0189..e127412d 100644 --- a/include/chemistry.h +++ b/include/chemistry.h @@ -87,7 +87,7 @@ class Chemistry { void calc_chemistry(Neutrals &neutrals, Ions &ions, Times time, - Grid grid); + Grid &grid); void calc_chemical_sources(Neutrals &neutrals, Ions &ions); diff --git a/include/ions.h b/include/ions.h index 05ab7bbe..979490e5 100644 --- a/include/ions.h +++ b/include/ions.h @@ -216,13 +216,13 @@ class Ions { \param grid The grid to define the ions on \param planet contains information about the species to simulate **/ - Ions(Grid grid, Planets planet); + Ions(Grid &grid, Planets planet); /********************************************************************** \brief Creates the variables within the species_chars structure \param grid The grid to define the ions on **/ - species_chars create_species(Grid grid); + species_chars create_species(Grid &grid); /********************************************************************** \brief @@ -235,7 +235,7 @@ class Ions { \param neutrals the neutral class to grab the temperature from \param grid The grid that the ions are defined on **/ - void init_ion_temperature(Neutrals neutrals, Grid grid); + void init_ion_temperature(Neutrals neutrals, Grid &grid); /********************************************************************** \brief Sets the floor of the ion densities, just in case! @@ -277,13 +277,13 @@ class Ions { \param time The time class to get dt and the current time \param indices The indices class to get different indices that may be needed **/ - bool set_bcs(Grid grid, Times time, Indices indices); + bool set_bcs(Grid &grid, Times time, Indices indices); /********************************************************************** \brief Sets the upper boundary conditions for the ions \param grid The grid that the ions are defined on **/ - bool set_upper_bcs(Grid grid); + bool set_upper_bcs(Grid &grid); /********************************************************************** \brief Sets the lower boundary condition for the ions @@ -291,14 +291,14 @@ class Ions { \param time The time class to get dt and the current time \param indices The indices class to get different indices that may be needed **/ - bool set_lower_bcs(Grid grid, Times time, Indices indices); + bool set_lower_bcs(Grid &grid, Times time, Indices indices); /********************************************************************** \brief Advect the ions along the 3rd dimension (could be altitude) \param grid The grid that the ions are defined on \param time The time class to get dt and the current time **/ - bool advect_vertical(Grid grid, Times time); + bool advect_vertical(Grid &grid, Times time); /********************************************************************** \brief Get the ID of the ion species with the given name @@ -310,13 +310,13 @@ class Ions { \brief Calculates the electric field \param grid The grid that the ions are defined on **/ - void calc_efield(Grid grid); + void calc_efield(Grid &grid); /********************************************************************** \brief Calculates the E x B drift \param grid The grid that the ions are defined on **/ - void calc_exb_drift(Grid grid); + void calc_exb_drift(Grid &grid); /********************************************************************** \brief Calculate the ion drift @@ -324,8 +324,8 @@ class Ions { \param grid The grid that the ions are defined on \param dt the delta-t for the current time **/ - void calc_ion_drift(Neutrals neutrals, - Grid grid, + void calc_ion_drift(const Neutrals &neutrals, + Grid &grid, precision_t dt); /********************************************************************** @@ -342,7 +342,7 @@ class Ions { \param grid this is the grid to solve the equation on \param time the time class to know dt **/ - void calc_ion_temperature(Neutrals neutrals, Grid grid, Times time); + void calc_ion_temperature(const Neutrals &neutrals, Grid &grid, Times time); /********************************************************************** \brief Calculates the electron temperature on the given grid @@ -350,7 +350,7 @@ class Ions { \param grid this is the grid to solve the equation on \param time the time class to know dt **/ - void calc_electron_temperature(Neutrals neutrals, Grid grid, Times time); + void calc_electron_temperature(Neutrals neutrals, Grid &grid, Times time); /********************************************************************** /// @brief Calculate epsilon @@ -449,7 +449,7 @@ class Ions { \param grid The grid to define the neutrals on \param time contains information about the current time **/ - void solver_vertical_rusanov(Grid grid, Times time); + void solver_vertical_rusanov(Grid &grid, Times time); }; #endif // INCLUDE_IONS_H_ diff --git a/include/neutrals.h b/include/neutrals.h index d7ac5321..36d4ce16 100644 --- a/include/neutrals.h +++ b/include/neutrals.h @@ -256,7 +256,7 @@ class Neutrals { \param time contains information about the current time \param indices used to help set initial conditions **/ - Neutrals(Grid grid, + Neutrals(Grid &grid, Planets planet, Times time, Indices indices); @@ -265,7 +265,7 @@ class Neutrals { \brief Creates the variables within the species_chars structure \param grid The grid to define the neutrals on **/ - species_chars create_species(Grid grid); + species_chars create_species(Grid &grid); /********************************************************************** \brief Read in the planet-specific file @@ -284,7 +284,7 @@ class Neutrals { \param time contains information about the current time \param indices used to help set initial conditions **/ - bool initial_conditions(Grid grid, + bool initial_conditions(Grid &grid, Times time, Indices indices); @@ -302,12 +302,12 @@ class Neutrals { **/ void fill_with_hydrostatic(int64_t iStart, int64_t iEnd, - Grid grid); + Grid &grid); void fill_with_hydrostatic(int64_t iSpecies, int64_t iStart, int64_t iEnd, - Grid grid); + Grid &grid); /********************************************************************** \brief Limit the density to a floor and a ceiling @@ -323,7 +323,7 @@ class Neutrals { \brief Calculate the scale heights for the individual species \param grid The grid to define the neutrals on **/ - void calc_scale_height(Grid grid); + void calc_scale_height(Grid &grid); /********************************************************************** \brief Calculate the viscosity coefficient @@ -380,21 +380,21 @@ class Neutrals { \brief Calculate the chapman integrals for the individual species \param grid The grid to define the neutrals on **/ - void calc_chapman(Grid grid); + void calc_chapman(Grid &grid); /********************************************************************** \brief Calculate the neutral bulk vertical thermal conduction \param grid The grid to define the neutrals on \param time The times within the model (dt is needed) **/ - void update_temperature(Grid grid, Times time); + void update_temperature(Grid &grid, Times time); /********************************************************************** \brief Calculate the neutral bulk horizontal viscosity \param grid The grid to define the neutrals on \param time The times within the model (dt is needed) **/ - void update_horizontal_velocity(Grid grid, Times time); + void update_horizontal_velocity(Grid &grid, Times time); /********************************************************************** \brief Calculate the O radiative cooling @@ -412,7 +412,7 @@ class Neutrals { \param planet Need things like rotation rate \param grid Need things like radius **/ - void add_sources(Times time, Planets planet, Grid grid); + void add_sources(Times time, Planets planet, Grid &grid); /********************************************************************** \brief Set boundary conditions for the neutrals @@ -420,7 +420,7 @@ class Neutrals { \param time contains information about the current time \param indices used to help set initial conditions **/ - bool set_bcs(Grid grid, + bool set_bcs(Grid &grid, Times time, Indices indices); @@ -430,7 +430,7 @@ class Neutrals { \param time contains information about the current time \param indices used to help set initial conditions **/ - bool set_lower_bcs(Grid grid, + bool set_lower_bcs(Grid &grid, Times time, Indices indices); @@ -440,14 +440,14 @@ class Neutrals { \param time contains information about the current time \param indices used to help set initial conditions **/ - bool set_upper_bcs(Grid grid); + bool set_upper_bcs(Grid &grid); /********************************************************************** \brief Set boundary conditions for the neutrals \param iDir direction of the BC to set \param grid The grid to define the neutrals on **/ - bool set_horizontal_bcs(int64_t iDir, Grid grid); + bool set_horizontal_bcs(int64_t iDir, Grid &grid); /********************************************************************** \brief Get the species ID number (int) given the species name (string) @@ -523,7 +523,7 @@ class Neutrals { \param grid The grid to define the neutrals on \param time contains information about the current time **/ - void solver_vertical_rusanov(Grid grid, + void solver_vertical_rusanov(Grid &grid, Times time); /********************************************************************** @@ -531,7 +531,7 @@ class Neutrals { \param grid The grid to define the neutrals on \param time contains information about the current time **/ - bool advect_vertical(Grid grid, Times time); + bool advect_vertical(Grid &grid, Times time); /********************************************************************** \brief Calculate the neutral friction in one cell using an implicit solver diff --git a/src/add_sources.cpp b/src/add_sources.cpp index b9eaf2a9..acd2922d 100644 --- a/src/add_sources.cpp +++ b/src/add_sources.cpp @@ -10,7 +10,7 @@ // Adds all of the sources to the states. Needs time to get dt. // ----------------------------------------------------------------------------- -void Neutrals::add_sources(Times time, Planets planet, Grid grid) { +void Neutrals::add_sources(Times time, Planets planet, Grid &grid) { std::string function = "add_sources"; static int iFunction = -1; diff --git a/src/aurora.cpp b/src/aurora.cpp index 93a731bc..cd35ad02 100644 --- a/src/aurora.cpp +++ b/src/aurora.cpp @@ -112,7 +112,7 @@ arma_vec calculate_fang_v2(precision_t energy_bin, // ----------------------------------------------------------------------------- // Calculate aurora // ----------------------------------------------------------------------------- -void calc_aurora(Grid grid, +void calc_aurora(Grid &grid, Neutrals &neutrals, Ions &ions) { diff --git a/src/calc_chemistry.cpp b/src/calc_chemistry.cpp index 9d8d2eec..7a82845c 100644 --- a/src/calc_chemistry.cpp +++ b/src/calc_chemistry.cpp @@ -13,7 +13,7 @@ void Chemistry::calc_chemistry(Neutrals &neutrals, Ions &ions, Times time, - Grid grid) { + Grid &grid) { int iSpecies; diff --git a/src/calc_dt.cpp b/src/calc_dt.cpp index dc51d5b4..e951a028 100644 --- a/src/calc_dt.cpp +++ b/src/calc_dt.cpp @@ -8,7 +8,7 @@ // -------------------------------------------------------------------------- -precision_t calc_dt(Grid grid, std::vector cMax_vcgc) { +precision_t calc_dt(Grid &grid, std::vector cMax_vcgc) { std::string function = "calc_dt"; static int iFunction = -1; @@ -29,7 +29,7 @@ precision_t calc_dt(Grid grid, std::vector cMax_vcgc) { // // -------------------------------------------------------------------------- -precision_t calc_dt_sphere(Grid grid, std::vector cMax_vcgc) { +precision_t calc_dt_sphere(Grid &grid, std::vector cMax_vcgc) { std::string function = "calc_dt_sphere"; static int iFunction = -1; @@ -70,7 +70,7 @@ precision_t calc_dt_sphere(Grid grid, std::vector cMax_vcgc) { // // -------------------------------------------------------------------------- -precision_t calc_dt_cubesphere(Grid grid, std::vector cMax_vcgc) { +precision_t calc_dt_cubesphere(Grid &grid, std::vector cMax_vcgc) { std::string function = "calc_dt_sphere"; static int iFunction = -1; @@ -132,7 +132,7 @@ precision_t calc_dt_cubesphere(Grid grid, std::vector cMax_vcgc) { // // -------------------------------------------------------------------------- -precision_t calc_dt_vertical(Grid grid, std::vector cMax_vcgc) { +precision_t calc_dt_vertical(Grid &grid, std::vector cMax_vcgc) { std::string function = "calc_dt_vertical"; static int iFunction = -1; diff --git a/src/calc_electron_temperature.cpp b/src/calc_electron_temperature.cpp index a5a00552..cf5a2bb2 100644 --- a/src/calc_electron_temperature.cpp +++ b/src/calc_electron_temperature.cpp @@ -8,7 +8,7 @@ // TODO (#24): this currently just sets the electron temperature to the neutral temperature // -------------------------------------------------------------------------- -void Ions::calc_electron_temperature(Neutrals neutrals, Grid grid, Times time) { +void Ions::calc_electron_temperature(Neutrals neutrals, Grid &grid, Times time) { std::string function = "Ions::calc_electron_temperature"; static int iFunction = -1; diff --git a/src/calc_euv.cpp b/src/calc_euv.cpp index 2c971f2d..d1bb5af5 100644 --- a/src/calc_euv.cpp +++ b/src/calc_euv.cpp @@ -14,7 +14,7 @@ // ----------------------------------------------------------------------------- bool calc_euv(Planets planet, - Grid grid, + Grid &grid, Times time, Euv &euv, Neutrals &neutrals, diff --git a/src/calc_ion_drift.cpp b/src/calc_ion_drift.cpp index ab1c6acb..e3ee58c9 100644 --- a/src/calc_ion_drift.cpp +++ b/src/calc_ion_drift.cpp @@ -7,7 +7,7 @@ // Calculate the electric field from the potential // -------------------------------------------------------------------------- -void Ions::calc_efield(Grid grid) { +void Ions::calc_efield(Grid &grid) { // efield = - grad(potential) efield_vcgc = calc_gradient_vector(potential_scgc, grid); @@ -27,7 +27,7 @@ void Ions::calc_efield(Grid grid) { // Calculate the E x B drift from the electric field and magnetic field // -------------------------------------------------------------------------- -void Ions::calc_exb_drift(Grid grid) { +void Ions::calc_exb_drift(Grid &grid) { arma_cube bmag2 = (grid.bfield_mag_scgc) % (grid.bfield_mag_scgc); exb_vcgc = cross_product(efield_vcgc, grid.bfield_vcgc); diff --git a/src/calc_ion_temperature.cpp b/src/calc_ion_temperature.cpp index 84af5aaa..19e9b7c1 100644 --- a/src/calc_ion_temperature.cpp +++ b/src/calc_ion_temperature.cpp @@ -11,7 +11,7 @@ // Initialize the ion temperature - set equal to the neutral temperature // -------------------------------------------------------------------------- -void Ions::init_ion_temperature(Neutrals neutrals, Grid grid) { +void Ions::init_ion_temperature(Neutrals neutrals, Grid &grid) { int64_t iIon; @@ -46,7 +46,7 @@ void Ions::init_ion_temperature(Neutrals neutrals, Grid grid) { // Calculate the ion temperature // -------------------------------------------------------------------------- -void Ions::calc_ion_temperature(Neutrals neutrals, Grid grid, +void Ions::calc_ion_temperature(const Neutrals &neutrals, Grid &grid, Times time) { std::string function = "Ions::calc_ion_temperature"; diff --git a/src/calc_neutral_derived.cpp b/src/calc_neutral_derived.cpp index 541dbb77..824c974d 100644 --- a/src/calc_neutral_derived.cpp +++ b/src/calc_neutral_derived.cpp @@ -239,7 +239,7 @@ void Neutrals::assign_bulk_velocity() { // Calculate scale heights of different species //---------------------------------------------------------------------- -void Neutrals::calc_scale_height(Grid grid) { +void Neutrals::calc_scale_height(Grid &grid) { int64_t nAlts = grid.get_nAlts(); @@ -518,7 +518,7 @@ precision_t Neutrals::calc_dt_cubesphere(Grid grid) { // this is taken from Smith and Smith, JGR 1972, vol. 77, page 3592 // ---------------------------------------------------------------------- -void Neutrals::calc_chapman(Grid grid) { +void Neutrals::calc_chapman(Grid &grid) { int64_t iAlt, iLon, iLat; diff --git a/src/ions_advect.cpp b/src/ions_advect.cpp index 36bed83b..38ae889f 100644 --- a/src/ions_advect.cpp +++ b/src/ions_advect.cpp @@ -9,7 +9,7 @@ // This is where we will call the different advection schemes // ----------------------------------------------------------------------------- -bool Ions::advect_vertical(Grid grid, Times time) { +bool Ions::advect_vertical(Grid &grid, Times time) { bool didWork = true; diff --git a/src/ions_bcs.cpp b/src/ions_bcs.cpp index 29d4cc89..a6aac659 100644 --- a/src/ions_bcs.cpp +++ b/src/ions_bcs.cpp @@ -20,7 +20,7 @@ // set_bcs - This is for setting the vertical BCs //---------------------------------------------------------------------- -bool Ions::set_bcs(Grid grid, +bool Ions::set_bcs(Grid &grid, Times time, Indices indices) { @@ -51,7 +51,7 @@ bool Ions::set_bcs(Grid grid, // set upper boundary conditions for the ions //---------------------------------------------------------------------- -bool Ions::set_upper_bcs(Grid grid) { +bool Ions::set_upper_bcs(Grid &grid) { std::string function = "Ions::set_upper_bcs"; static int iFunction = -1; @@ -104,7 +104,7 @@ bool Ions::set_upper_bcs(Grid grid) { // set lower boundary conditions for the ions //---------------------------------------------------------------------- -bool Ions::set_lower_bcs(Grid grid, Times time, Indices indices) { +bool Ions::set_lower_bcs(Grid &grid, Times time, Indices indices) { std::string function = "Ions::set_lower_bcs"; static int iFunction = -1; diff --git a/src/neutrals.cpp b/src/neutrals.cpp index b452f6f6..5f73634d 100644 --- a/src/neutrals.cpp +++ b/src/neutrals.cpp @@ -11,7 +11,7 @@ // Create a single species by filling the species structure // ----------------------------------------------------------------------------- -Neutrals::species_chars Neutrals::create_species(Grid grid) { +Neutrals::species_chars Neutrals::create_species(Grid &grid) { species_chars tmp; @@ -81,7 +81,7 @@ Neutrals::species_chars Neutrals::create_species(Grid grid) { // Initialize neutrals // ----------------------------------------------------------------------------- -Neutrals::Neutrals(Grid grid, +Neutrals::Neutrals(Grid &grid, Planets planet, Times time, Indices indices) { @@ -251,7 +251,7 @@ int Neutrals::read_planet_file(Planets planet) { void Neutrals::fill_with_hydrostatic(int64_t iStart, int64_t iEnd, - Grid grid) { + Grid &grid) { int64_t iNeutral, iSpecies; @@ -281,7 +281,7 @@ void Neutrals::fill_with_hydrostatic(int64_t iStart, void Neutrals::fill_with_hydrostatic(int64_t iSpecies, int64_t iStart, int64_t iEnd, - Grid grid) { + Grid &grid) { // Integrate with hydrostatic equilibrium up: for (int iAlt = iStart; iAlt < iEnd; iAlt++) { diff --git a/src/neutrals_advect.cpp b/src/neutrals_advect.cpp index a80dc274..96a93251 100644 --- a/src/neutrals_advect.cpp +++ b/src/neutrals_advect.cpp @@ -9,7 +9,7 @@ // This is where we will call the different advection schemes // ----------------------------------------------------------------------------- -bool Neutrals::advect_vertical(Grid grid, Times time) { +bool Neutrals::advect_vertical(Grid &grid, Times time) { bool didWork = true; diff --git a/src/neutrals_bcs.cpp b/src/neutrals_bcs.cpp index e9308e23..112086a1 100644 --- a/src/neutrals_bcs.cpp +++ b/src/neutrals_bcs.cpp @@ -20,7 +20,7 @@ // set_bcs - This is for setting the vertical BCs //---------------------------------------------------------------------- -bool Neutrals::set_bcs(Grid grid, +bool Neutrals::set_bcs(Grid &grid, Times time, Indices indices) { @@ -51,7 +51,7 @@ bool Neutrals::set_bcs(Grid grid, // set lower boundary conditions for the neutrals //---------------------------------------------------------------------- -bool Neutrals::set_upper_bcs(Grid grid) { +bool Neutrals::set_upper_bcs(Grid &grid) { std::string function = "Neutrals::set_upper_bcs"; static int iFunction = -1; @@ -105,7 +105,7 @@ bool Neutrals::set_upper_bcs(Grid grid) { // set lower boundary conditions for the neutrals //---------------------------------------------------------------------- -bool Neutrals::set_lower_bcs(Grid grid, +bool Neutrals::set_lower_bcs(Grid &grid, Times time, Indices indices) { @@ -261,7 +261,7 @@ bool Neutrals::set_lower_bcs(Grid grid, // iDir = 3 -> -y //---------------------------------------------------------------------- -bool Neutrals::set_horizontal_bcs(int64_t iDir, Grid grid) { +bool Neutrals::set_horizontal_bcs(int64_t iDir, Grid &grid) { std::string function = "Neutrals::set_horizontal_bcs"; static int iFunction = -1; diff --git a/src/neutrals_energy.cpp b/src/neutrals_energy.cpp index 893ab86e..7bc503a5 100644 --- a/src/neutrals_energy.cpp +++ b/src/neutrals_energy.cpp @@ -7,7 +7,7 @@ // Calculate thermal conduction // --------------------------------------------------------------------------- -void Neutrals::update_temperature(Grid grid, Times time) { +void Neutrals::update_temperature(Grid &grid, Times time) { std::string function = "Neutrals::calc_conduction"; static int iFunction = -1; diff --git a/src/neutrals_ics.cpp b/src/neutrals_ics.cpp index 225eeb19..07f60762 100644 --- a/src/neutrals_ics.cpp +++ b/src/neutrals_ics.cpp @@ -19,7 +19,7 @@ // file and fill with hydrostatic. // ----------------------------------------------------------------------------- -bool Neutrals::initial_conditions(Grid grid, +bool Neutrals::initial_conditions(Grid &grid, Times time, Indices indices) { diff --git a/src/neutrals_momentum_viscosity.cpp b/src/neutrals_momentum_viscosity.cpp index 4efaaaee..200128b4 100644 --- a/src/neutrals_momentum_viscosity.cpp +++ b/src/neutrals_momentum_viscosity.cpp @@ -7,7 +7,7 @@ // Calculate viscosity // --------------------------------------------------------------------------- -void Neutrals::update_horizontal_velocity(Grid grid, Times time) { +void Neutrals::update_horizontal_velocity(Grid &grid, Times time) { std::string function = "Neutrals::update_horizontal_velocity"; static int iFunction = -1; diff --git a/src/solver_vertical_rusanov.cpp b/src/solver_vertical_rusanov.cpp index 8027cd94..545a8428 100644 --- a/src/solver_vertical_rusanov.cpp +++ b/src/solver_vertical_rusanov.cpp @@ -187,7 +187,7 @@ void calc_grad_and_diff_alts_rusanov(Grid &grid, // // -------------------------------------------------------------------------- -void Neutrals::solver_vertical_rusanov(Grid grid, +void Neutrals::solver_vertical_rusanov(Grid &grid, Times time) { std::string function = "Neutrals::solver_vertical_rusanov"; @@ -436,7 +436,7 @@ void Neutrals::solver_vertical_rusanov(Grid grid, // // -------------------------------------------------------------------------- -void Ions::solver_vertical_rusanov(Grid grid, +void Ions::solver_vertical_rusanov(Grid &grid, Times time) { std::string function = "Ions::solver_vertical_rusanov";