Canoe
Comprehensive Atmosphere N' Ocean Engine
load_user_output_data.cpp
Go to the documentation of this file.
1 // athena
2 #include <athena/athena.hpp>
3 #include <athena/hydro/hydro.hpp>
4 #include <athena/mesh/mesh.hpp>
5 #include <athena/outputs/outputs.hpp>
6 
7 // canoe
8 #include <impl.hpp>
9 #include <virtual_groups.hpp>
10 
11 // harp
12 #include <harp/radiation.hpp>
13 #include <harp/radiation_band.hpp>
14 
15 // outputs
16 #include "output_utils.hpp"
17 
18 void OutputType::loadUserOutputData(MeshBlock *pmb) {
19  OutputData *pod;
20  auto phyd = pmb->phydro;
21  auto prad = pmb->pimpl->prad;
22 
23  // vapor
24  if (NVAPOR > 0) {
25  if (output_params.variable.compare("prim") == 0 ||
26  output_params.variable.compare("vapor") == 0) {
27  pod = new OutputData;
28  pod->type = "VECTORS";
29  pod->name = "vapor";
30  pod->data.InitWithShallowSlice(phyd->w, 4, 1, NVAPOR);
31  AppendOutputDataNode(pod);
32  num_vars_ += NVAPOR;
33  }
34 
35  if (output_params.variable.compare("cons") == 0) {
36  pod = new OutputData;
37  pod->type = "VECTORS";
38  pod->name = "vapor";
39  pod->data.InitWithShallowSlice(phyd->u, 4, 1, NVAPOR);
40  AppendOutputDataNode(pod);
41  num_vars_ += NVAPOR;
42  }
43  }
44 
45  // radiation
46  if (output_params.variable.compare("rad") == 0 ||
47  output_params.variable.compare("radtau") == 0) {
48  for (int b = 0; b < prad->GetNumBands(); ++b) {
49  auto pband = prad->GetBand(b);
50  // tau
51  pod = new OutputData;
52  pod->type = "SCALARS";
53  pod->name = pband->GetName() + "tau";
54  pod->data.InitWithShallowSlice(pband->btau, 4, 0, 1);
55  AppendOutputDataNode(pod);
56  num_vars_ += 1;
57  }
58  }
59 
60  if (output_params.variable.compare("rad") == 0 ||
61  output_params.variable.compare("radflux") == 0) {
62  // flux up and down
63  pod = new OutputData;
64  pod->type = "SCALARS";
65  pod->name = "flxup";
66  pod->data.InitWithShallowSlice(prad->flxup, 4, 0, 1);
67  AppendOutputDataNode(pod);
68  num_vars_ += 1;
69 
70  pod = new OutputData;
71  pod->type = "SCALARS";
72  pod->name = "flxdn";
73  pod->data.InitWithShallowSlice(prad->flxdn, 4, 0, 1);
74  AppendOutputDataNode(pod);
75  num_vars_ += 1;
76  }
77 
78  if (output_params.variable.compare("rad") == 0 ||
79  output_params.variable.compare("radtoa") == 0) {
80  if (prad->radiance.GetDim3() > 0) {
81  pod = new OutputData;
82  pod->type = "SCALARS";
83  pod->name = "radiance";
84  pod->data.InitWithShallowSlice(prad->radiance, 4, 0, 1);
85  AppendOutputDataNode(pod);
86  num_vars_ += 1;
87 
88  // for (auto p : prad->bands) p->writeBinRadiance(&output_params);
89  }
90  }
91 
92  /* mcmc inversion
93  if (output_params.variable.compare("mcmc")) {
94  pod = new OutputData;
95  AppendOutputDataNode(pod);
96  num_vars_ += 1;
97  }*/
98 
99  // fits output groups
100  for (auto &fits_out : pmb->pimpl->GetFITSOutputGroups()) {
101  if (fits_out.lock()->ShouldFITSOutput(output_params.variable))
102  fits_out.lock()->LoadFITSOutputData(this, &num_vars_);
103  }
104 
105  // mesh output groups
106  for (auto &mesh_out : pmb->pimpl->GetMeshOutputGroups()) {
107  if (mesh_out.lock()->ShouldMeshOutput(output_params.variable))
108  mesh_out.lock()->LoadMeshOutputData(this, &num_vars_);
109  }
110 }