Canoe
Comprehensive Atmosphere N' Ocean Engine
radiation_band.hpp
Go to the documentation of this file.
1 #ifndef SRC_HARP_RADIATION_BAND_HPP_
2 #define SRC_HARP_RADIATION_BAND_HPP_
3 
4 // C/C++ headers
5 #include <map>
6 #include <memory>
7 #include <string>
8 #include <vector>
9 
10 // external
11 #include <yaml-cpp/yaml.h>
12 
13 // athena
14 #include <athena/athena.hpp> // Real
15 
16 // canoe
17 #include <air_parcel.hpp>
18 #include <common.hpp>
19 #include <virtual_groups.hpp>
20 
21 // harp
22 #include "spectral_grid.hpp"
23 
24 // exchanger
26 
27 class OutputParameters;
28 class Absorber;
29 class SpectralGridBase;
30 struct Direction;
31 
32 class RadiationBand : public NamedGroup,
33  public FlagGroup,
34  public ParameterGroup,
35  public ASCIIOutputGroup,
36  public LinearExchanger<RadiationBand> {
37  public: // public access data
38  // implementation of RT Solver
39  class RTSolver;
40  class RTSolverLambert;
41  class RTSolverDisort;
42 
45 
48 
51 
54 
57 
62 
63  public: // constructor and destructor
64  RadiationBand(std::string name, YAML::Node const &rad);
65  virtual ~RadiationBand();
66 
67  public: // member functions
69  void Resize(int nc1, int nc2 = 1, int nc3 = 1, int nstr = 8);
70 
72  void ResizeSolver(int nlyr, int nstr = 8, int nuphi = 1, int numu = 1);
73 
77  std::shared_ptr<RTSolver> CreateRTSolverFrom(std::string const &name,
78  YAML::Node const &rad);
79 
81  size_t GetNumSpecGrids() const { return pgrid_->spec.size(); }
82 
84  size_t GetNumAbsorbers() const { return absorbers_.size(); }
85 
87  size_t GetNumPhaseMoments() const { return pmom_.GetDim1() - 1; }
88 
90  size_t GetNumLayers() const { return tem_.size() - 2 * NGHOST; }
91 
93  std::pair<Real, Real> GetRange() const { return wrange_; }
94 
96  std::shared_ptr<Absorber> GetAbsorber(int i) { return absorbers_[i]; }
97 
99  std::shared_ptr<Absorber> GetAbsorberByName(std::string const &name);
100 
102  size_t GetNumOutgoingRays() { return rayOutput_.size(); }
103 
105  Real GetCosinePolarAngle(int n) const { return rayOutput_[n].mu; }
106 
108  Real GetAzimuthalAngle(int n) const { return rayOutput_[n].phi; }
109 
110  public: // inbound functions
118  void SetSpectralProperties(AirColumn &air, Coordinates const *pcoord,
119  Real grav, int k, int j);
120 
122  void CalBandFlux(MeshBlock const *pmb, int k, int j, int il, int iu);
123 
125  void CalBandRadiance(MeshBlock const *pmb, int k, int j);
126 
130  void SetOutgoingRays(std::vector<Direction> const &ray) { rayOutput_ = ray; }
131 
132  public: // ASCIIOutputGroup functions
133  void WriteAsciiHeader(OutputParameters const *) const override;
134  void WriteAsciiData(OutputParameters const *) const override;
135 
136  public: // Exchanger functions
138  void PackTemperature();
139 
141  bool UnpackTemperature(void *arg);
142 
146  void PackSpectralGrid(int b);
147 
149  bool UnpackSpectralGrid(void *arg);
150 
151  void Transfer(MeshBlock const *pmb, int n) override;
152 
153  protected:
155  std::shared_ptr<RTSolver> psolver_;
156 
158  std::shared_ptr<SpectralGridBase> pgrid_;
159 
161  std::pair<Real, Real> wrange_;
162 
164  std::vector<std::shared_ptr<Absorber>> absorbers_;
165 
167  std::vector<Direction> rayOutput_;
168 
175 
182 
189 
196 
203 
210 
212  std::vector<Real> tem_;
213 
215  std::vector<Real> temf_;
216 };
217 
218 using RadiationBandPtr = std::shared_ptr<RadiationBand>;
219 using RadiationBandContainer = std::vector<RadiationBandPtr>;
220 
222  public:
223  static RadiationBandContainer CreateFrom(ParameterInput *pin,
224  std::string key);
225  static RadiationBandContainer CreateFrom(std::string filename);
226 };
227 
228 #endif // SRC_HARP_RADIATION_BAND_HPP_
std::vector< AirParcel > AirColumn
Definition: air_parcel.hpp:121
base class of all absorbers
Definition: absorber.hpp:25
bool UnpackTemperature(void *arg)
Unpack temperature at cell face from receive buffer 0.
void PackSpectralGrid(int b)
Pack data in spectral grid b into send buffer 1.
void CalBandFlux(MeshBlock const *pmb, int k, int j, int il, int iu)
Calculate band radiative fluxes.
std::shared_ptr< Absorber > GetAbsorberByName(std::string const &name)
Get an individual absorber by name.
Real GetAzimuthalAngle(int n) const
Get azimuthal angle of the outgoing ray.
bool UnpackSpectralGrid(void *arg)
Unpack data from receive buffer 1 into spectral grid b.
std::shared_ptr< Absorber > GetAbsorber(int i)
Get an individual absorber.
std::pair< Real, Real > GetRange() const
Get range of wavenumbers.
AthenaArray< Real > flxdn_
spectral bin downward flux
std::vector< Real > temf_
temperature at cell boundary (face)
std::pair< Real, Real > wrange_
identify wave- number (wavelength, frequency) range
AthenaArray< Real > bpmom
band phase function moments
void ResizeSolver(int nlyr, int nstr=8, int nuphi=1, int numu=1)
Allocate memory for radiation solver.
Real GetCosinePolarAngle(int n) const
Get cosine polar angle of the outgoing ray.
std::shared_ptr< RTSolver > psolver_
radiative transfer solver
AthenaArray< Real > pmom_
spectral bin phase function moments
void SetOutgoingRays(std::vector< Direction > const &ray)
Set outgoing ray directions.
size_t GetNumOutgoingRays()
Get number of outgoing rays.
std::shared_ptr< SpectralGridBase > pgrid_
spectral grid
AthenaArray< Real > toa_
spectral bin top-of-the-atmosphere radiance
void CalBandRadiance(MeshBlock const *pmb, int k, int j)
Calculate band radiances.
AthenaArray< Real > flxup_
spectral bin upward flux
AthenaArray< Real > btau
band optical depth
std::shared_ptr< RTSolver > CreateRTSolverFrom(std::string const &name, YAML::Node const &rad)
Create radiative transfer solver from YAML node.
AthenaArray< Real > bflxup
band upward flux
void Transfer(MeshBlock const *pmb, int n) override
AthenaArray< Real > ssa_
spectral bin single scattering albedo
void PackTemperature()
Pack temperature at cell face into send buffer 0.
AthenaArray< Real > btoa
band top-of-the-atmosphere radiance
size_t GetNumLayers() const
Get number of phase function moments.
std::vector< Real > tem_
temperature at cell center
RadiationBand(std::string name, YAML::Node const &rad)
size_t GetNumAbsorbers() const
Get number of absorbers.
void WriteAsciiData(OutputParameters const *) const override
std::vector< std::shared_ptr< Absorber > > absorbers_
all absorbers
void SetSpectralProperties(AirColumn &air, Coordinates const *pcoord, Real grav, int k, int j)
Set spectral properties for an air column.
void Resize(int nc1, int nc2=1, int nc3=1, int nstr=8)
Allocate memory for radiation band.
AthenaArray< Real > tau_
spectral bin optical depth
size_t GetNumPhaseMoments() const
Get number of phase function moments.
size_t GetNumSpecGrids() const
Get number of spectral grids.
AthenaArray< Real > bflxdn
band downward flux
void WriteAsciiHeader(OutputParameters const *) const override
std::vector< Direction > rayOutput_
outgoing rays
AthenaArray< Real > bssa
band single scattering albedo
virtual ~RadiationBand()
static RadiationBandContainer CreateFrom(ParameterInput *pin, std::string key)
Base class for a collection of spectral grids.
std::shared_ptr< RadiationBand > RadiationBandPtr
std::vector< RadiationBandPtr > RadiationBandContainer