Skip to content

Commit c6fa64f

Browse files
authored
Merge pull request #181 from t-barnard/develop
Speed Optimizations - this passes the grid by reference and provides a new timer.
2 parents 9030957 + 2e2bca7 commit c6fa64f

29 files changed

+171
-126
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ if (USE_NETCDF)
101101
target_link_libraries(aether PUBLIC ${NETCDF_LIBRARIES_C})
102102
endif()
103103

104+
# use_old_timing
105+
# cmake -DUSE_OLD_TIMING=ON ..
106+
option(USE_OLD_TIMING "Use old timing for performance - default is off" OFF)
107+
if (USE_OLD_TIMING)
108+
add_definitions(-DOLD_TIMING)
109+
set(OLD_TIMING "YES")
110+
endif()
111+
104112
# Set up links for executable
105113
file(CREATE_LINK ${CMAKE_BINARY_DIR}/aether
106114
${PROJECT_SOURCE_DIR}/share/run/aether SYMBOLIC)

include/aurora.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ arma_vec calculate_fang(float eflux, // in ergs/cm2/s
3131
* param ions the class that contains all info about the ions
3232
**/
3333

34-
void calc_aurora(Grid grid,
34+
void calc_aurora(Grid &grid,
3535
Neutrals &neutrals,
3636
Ions &ions);
3737

include/calc_euv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// -------------------------------------------------------------------------
2222

2323
bool calc_euv(Planets planet,
24-
Grid grid,
24+
Grid &grid,
2525
Times time,
2626
Euv &euv,
2727
Neutrals &neutrals,

include/chemistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Chemistry {
8787
void calc_chemistry(Neutrals &neutrals,
8888
Ions &ions,
8989
Times time,
90-
Grid grid);
90+
Grid &grid);
9191

9292
void calc_chemical_sources(Neutrals &neutrals,
9393
Ions &ions);

include/ions.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ class Ions {
229229
\param grid The grid to define the ions on
230230
\param planet contains information about the species to simulate
231231
**/
232-
Ions(Grid grid, Planets planet);
232+
Ions(Grid &grid, Planets planet);
233233

234234
/**********************************************************************
235235
\brief Creates the variables within the species_chars structure
236236
\param grid The grid to define the ions on
237237
**/
238-
species_chars create_species(Grid grid);
238+
species_chars create_species(Grid &grid);
239239

240240
/**********************************************************************
241241
\brief
@@ -248,7 +248,7 @@ class Ions {
248248
\param neutrals the neutral class to grab the temperature from
249249
\param grid The grid that the ions are defined on
250250
**/
251-
void init_ion_temperature(Neutrals neutrals, Grid grid);
251+
void init_ion_temperature(Neutrals neutrals, Grid &grid);
252252

253253
/**********************************************************************
254254
\brief Sets the floor of the ion densities, just in case!
@@ -290,28 +290,28 @@ class Ions {
290290
\param time The time class to get dt and the current time
291291
\param indices The indices class to get different indices that may be needed
292292
**/
293-
bool set_bcs(Grid grid, Times time, Indices indices);
293+
bool set_bcs(Grid &grid, Times time, Indices indices);
294294

295295
/**********************************************************************
296296
\brief Sets the upper boundary conditions for the ions
297297
\param grid The grid that the ions are defined on
298298
**/
299-
bool set_upper_bcs(Grid grid);
299+
bool set_upper_bcs(Grid &grid);
300300

301301
/**********************************************************************
302302
\brief Sets the lower boundary condition for the ions
303303
\param grid The grid that the ions are defined on
304304
\param time The time class to get dt and the current time
305305
\param indices The indices class to get different indices that may be needed
306306
**/
307-
bool set_lower_bcs(Grid grid, Times time, Indices indices);
307+
bool set_lower_bcs(Grid &grid, Times time, Indices indices);
308308

309309
/**********************************************************************
310310
\brief Advect the ions along the 3rd dimension (could be altitude)
311311
\param grid The grid that the ions are defined on
312312
\param time The time class to get dt and the current time
313313
**/
314-
bool advect_vertical(Grid grid, Times time);
314+
bool advect_vertical(Grid &grid, Times time);
315315

316316
/**********************************************************************
317317
\brief Get the ID of the ion species with the given name
@@ -323,24 +323,24 @@ class Ions {
323323
\brief Calculates the electric field
324324
\param grid The grid that the ions are defined on
325325
**/
326-
void calc_efield(Grid grid);
326+
void calc_efield(Grid &grid);
327327

328328
/**********************************************************************
329329
\brief Calculates the E x B drift
330330
\param grid The grid that the ions are defined on
331331
**/
332-
void calc_exb_drift(Grid grid);
332+
void calc_exb_drift(Grid &grid);
333333

334334
/**********************************************************************
335335
\brief Calculate the ion drift
336336
\param neutrals these are needed for the collision terms
337337
\param grid The grid that the ions are defined on
338338
\param dt the delta-t for the current time
339339
**/
340-
void calc_ion_drift(Neutrals neutrals,
341-
Grid grid,
342-
precision_t dt);
343-
340+
void calc_ion_drift(Neutrals &neutrals,
341+
Grid &grid,
342+
precision_t dt);
343+
344344
/**********************************************************************
345345
\brief Calculate the ion + electron pressure gradient
346346
\param iIon which ion to act upon
@@ -355,15 +355,15 @@ class Ions {
355355
\param grid this is the grid to solve the equation on
356356
\param time the time class to know dt
357357
**/
358-
void calc_ion_temperature(Neutrals neutrals, Grid grid, Times time);
358+
void calc_ion_temperature(const Neutrals &neutrals, Grid &grid, Times time);
359359

360360
/**********************************************************************
361361
\brief Calculates the electron temperature on the given grid
362362
\param neutrals these are needed for the collision terms
363363
\param grid this is the grid to solve the equation on
364364
\param time the time class to know dt
365365
**/
366-
void calc_electron_temperature(Neutrals neutrals, Grid grid, Times time);
366+
void calc_electron_temperature(Neutrals neutrals, Grid &grid, Times time);
367367

368368
/**********************************************************************
369369
/// @brief Calculate epsilon
@@ -464,7 +464,7 @@ class Ions {
464464
\param grid The grid to define the neutrals on
465465
\param time contains information about the current time
466466
**/
467-
void solver_vertical_rusanov(Grid grid, Times time);
467+
void solver_vertical_rusanov(Grid &grid, Times time);
468468

469469
};
470470
#endif // INCLUDE_IONS_H_

include/neutrals.h

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,16 @@ class Neutrals {
257257
\param time contains information about the current time
258258
\param indices used to help set initial conditions
259259
**/
260-
Neutrals(Grid grid,
261-
Planets planet,
262-
Times time,
263-
Indices indices);
260+
Neutrals(Grid &grid,
261+
Planets planet,
262+
Times time,
263+
Indices indices);
264264

265265
/**********************************************************************
266266
\brief Creates the variables within the species_chars structure
267267
\param grid The grid to define the neutrals on
268268
**/
269-
species_chars create_species(Grid grid);
269+
species_chars create_species(Grid &grid);
270270

271271
/**********************************************************************
272272
\brief Read in the planet-specific file
@@ -285,9 +285,9 @@ class Neutrals {
285285
\param time contains information about the current time
286286
\param indices used to help set initial conditions
287287
**/
288-
bool initial_conditions(Grid grid,
289-
Times time,
290-
Indices indices);
288+
bool initial_conditions(Grid &grid,
289+
Times time,
290+
Indices indices);
291291

292292
/**********************************************************************
293293
\brief temporary function to set neutral densities with in the model
@@ -302,14 +302,14 @@ class Neutrals {
302302
\param grid The grid to define the neutrals on
303303
**/
304304
void fill_with_hydrostatic(int64_t iStart,
305-
int64_t iEnd,
306-
Grid grid);
305+
int64_t iEnd,
306+
Grid &grid);
307307

308308
void fill_with_hydrostatic(int64_t iSpecies,
309-
int64_t iStart,
310-
int64_t iEnd,
311-
Grid grid);
312-
309+
int64_t iStart,
310+
int64_t iEnd,
311+
Grid &grid);
312+
313313
/**********************************************************************
314314
\brief Limit the density to a floor and a ceiling
315315
**/
@@ -324,8 +324,8 @@ class Neutrals {
324324
\brief Calculate the scale heights for the individual species
325325
\param grid The grid to define the neutrals on
326326
**/
327-
void calc_scale_height(Grid grid);
328-
327+
void calc_scale_height(Grid &grid);
328+
329329
/**********************************************************************
330330
\brief Calculate the viscosity coefficient
331331
**/
@@ -381,21 +381,21 @@ class Neutrals {
381381
\brief Calculate the chapman integrals for the individual species
382382
\param grid The grid to define the neutrals on
383383
**/
384-
void calc_chapman(Grid grid);
384+
void calc_chapman(Grid &grid);
385385

386386
/**********************************************************************
387387
\brief Calculate the neutral bulk vertical thermal conduction
388388
\param grid The grid to define the neutrals on
389389
\param time The times within the model (dt is needed)
390390
**/
391-
void update_temperature(Grid grid, Times time);
391+
void update_temperature(Grid &grid, Times time);
392392

393393
/**********************************************************************
394394
\brief Calculate the neutral bulk horizontal viscosity
395395
\param grid The grid to define the neutrals on
396396
\param time The times within the model (dt is needed)
397397
**/
398-
void update_horizontal_velocity(Grid grid, Times time);
398+
void update_horizontal_velocity(Grid &grid, Times time);
399399

400400
/**********************************************************************
401401
\brief Calculate the O radiative cooling
@@ -413,43 +413,43 @@ class Neutrals {
413413
\param planet Need things like rotation rate
414414
\param grid Need things like radius
415415
**/
416-
void add_sources(Times time, Planets planet, Grid grid);
416+
void add_sources(Times time, Planets planet, Grid &grid);
417417

418418
/**********************************************************************
419419
\brief Set boundary conditions for the neutrals
420420
\param grid The grid to define the neutrals on
421421
\param time contains information about the current time
422422
\param indices used to help set initial conditions
423423
**/
424-
bool set_bcs(Grid grid,
425-
Times time,
426-
Indices indices);
424+
bool set_bcs(Grid &grid,
425+
Times time,
426+
Indices indices);
427427

428428
/**********************************************************************
429429
\brief Set lower boundary conditions for the neutrals
430430
\param grid The grid to define the neutrals on
431431
\param time contains information about the current time
432432
\param indices used to help set initial conditions
433433
**/
434-
bool set_lower_bcs(Grid grid,
435-
Times time,
436-
Indices indices);
434+
bool set_lower_bcs(Grid &grid,
435+
Times time,
436+
Indices indices);
437437

438438
/**********************************************************************
439439
\brief Set upper boundary conditions for the neutrals
440440
\param grid The grid to define the neutrals on
441441
\param time contains information about the current time
442442
\param indices used to help set initial conditions
443443
**/
444-
bool set_upper_bcs(Grid grid);
444+
bool set_upper_bcs(Grid &grid);
445445

446446
/**********************************************************************
447447
\brief Set boundary conditions for the neutrals
448448
\param iDir direction of the BC to set
449449
\param grid The grid to define the neutrals on
450450
**/
451-
bool set_horizontal_bcs(int64_t iDir, Grid grid);
452-
451+
bool set_horizontal_bcs(int64_t iDir, Grid &grid);
452+
453453
/**********************************************************************
454454
\brief Get the species ID number (int) given the species name (string)
455455
\param name string holding the species name (e.g., "O+")
@@ -524,15 +524,15 @@ class Neutrals {
524524
\param grid The grid to define the neutrals on
525525
\param time contains information about the current time
526526
**/
527-
void solver_vertical_rusanov(Grid grid,
528-
Times time);
529-
527+
void solver_vertical_rusanov(Grid &grid,
528+
Times time);
529+
530530
/**********************************************************************
531531
\brief Call the correct vertical advection scheme
532532
\param grid The grid to define the neutrals on
533533
\param time contains information about the current time
534534
**/
535-
bool advect_vertical(Grid grid, Times time);
535+
bool advect_vertical(Grid &grid, Times time);
536536

537537
/**********************************************************************
538538
\brief Calculate the neutral friction in one cell using an implicit solver

include/report.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <string>
2424
#include <vector>
2525
#include <map>
26+
#include <sys/time.h>
2627

2728
#include "aether.h"
2829

@@ -211,6 +212,8 @@ class Report {
211212
precision_t timing_total;
212213
/// This is the start-gate for the timer
213214
unsigned long long timing_start;
215+
216+
struct timeval timing_start_new;
214217
/// This is the level of the function that is then compared to verbose
215218
int iLevel;
216219
/// This is a string that holds all of the function names above this one
@@ -250,6 +253,8 @@ class Report {
250253
std::string error;
251254
};
252255

256+
struct timeval start, end;
257+
253258
//Vector of error structs
254259
std::vector<error_struct> error_list;
255260
};

0 commit comments

Comments
 (0)