Canoe
Comprehensive Atmosphere N' Ocean Engine
mesh_destroy.cpp
Go to the documentation of this file.
1 // C/C++
2 #include <iostream>
3 
4 // athena
5 #include <athena/mesh/mesh.hpp>
6 #include <athena/outputs/io_wrapper.hpp>
7 #include <athena/parameter_input.hpp>
8 
9 // application
10 #include <application/globals.hpp>
11 
12 // canoe
13 #include <configure.hpp>
14 
15 #include "index_map.hpp"
16 
17 // snap
19 
20 // outputs
21 #include "outputs/output_utils.hpp"
22 
23 // n-body
24 #include "nbody/particle_data.hpp"
25 
26 void mesh_destroy(ParameterInput *&pinput, Mesh *&pmesh, int mbcnt) {
27  clock_t tstop = clock();
28 
29  if (Globals::my_rank == 0) {
30  pmesh->OutputCycleDiagnostics();
31  if (pmesh->ncycle == pmesh->nlim) {
32  std::cout << std::endl << "Terminating on cycle limit" << std::endl;
33  }
34 
35  std::cout << "time=" << pmesh->time << " cycle=" << pmesh->ncycle
36  << std::endl;
37  std::cout << "tlim=" << pmesh->tlim << " nlim=" << pmesh->nlim << std::endl;
38 
39  if (pmesh->adaptive) {
40  std::cout << std::endl
41  << "Number of MeshBlocks = " << pmesh->nbtotal << "; "
42  << pmesh->nbnew << " created, " << pmesh->nbdel
43  << " destroyed during this simulation." << std::endl;
44  }
45 
46  // Calculate and print the zone-cycles/cpu-second and wall-second
47 #ifdef OPENMP_PARALLEL
48  double omp_time = omp_get_wtime() - omp_start_time;
49 #endif
50  clock_t tstop = clock();
51  double cpu_time =
52  (tstop > Globals::tstart ? static_cast<double>(tstop - Globals::tstart)
53  : 1.0) /
54  static_cast<double>(CLOCKS_PER_SEC);
55  std::uint64_t zonecycles =
56  mbcnt * static_cast<std::uint64_t>(
57  pmesh->my_blocks(0)->GetNumberOfMeshBlockCells());
58  double zc_cpus = static_cast<double>(zonecycles) / cpu_time;
59 
60  std::cout << std::endl << "zone-cycles = " << zonecycles << std::endl;
61  std::cout << "zone-cycles/cpu_second = " << zc_cpus << std::endl;
62 #ifdef OPENMP_PARALLEL
63  double zc_omps = static_cast<double>(zonecycles) / omp_time;
64  std::cout << std::endl << "omp wtime used = " << omp_time << std::endl;
65  std::cout << "zone-cycles/omp_wsecond = " << zc_omps << std::endl;
66 #endif
67  }
68 
69  delete pinput;
70  delete pmesh;
71 
76 }
static void Destroy()
Definition: index_map.cpp:144
static void Destroy()
static void Destroy()
Destroy the one and only instance of Thermodynamics.
void mesh_destroy(ParameterInput *&pinput, Mesh *&pmesh, int mbcnt)
void free_mpi_particle_data()