Canoe
Comprehensive Atmosphere N' Ocean Engine
absorber.cpp
Go to the documentation of this file.
1 // C/C++
2 #include <string>
3 
4 // application
5 #include <application/application.hpp>
6 #include <application/exceptions.hpp>
7 
8 // opacity
9 #include "absorber.hpp"
10 
11 Absorber::Absorber(std::string name) : NamedGroup(name), opacity_filename_("") {
12  Application::Logger app("opacity");
13  app->Log("Create Absorber " + name);
14 }
15 
17  Application::Logger app("opacity");
18  app->Log("Destroy Absorber " + GetName());
19 }
20 
21 void Absorber::LoadOpacityFromFile(std::string filename) {
22  SetOpacityFile(filename);
23  LoadOpacity();
24 }
25 
26 void Absorber::SetOpacityFile(std::string filename) {
27  opacity_filename_ = filename;
28 }
29 
31  auto app = Application::GetInstance();
32  auto log = app->GetMonitor("opacity");
33 
34  if (opacity_filename_.empty()) return;
35 
36  try {
37  std::string full_path = app->FindInputFile(opacity_filename_);
38  log->Log("Load opacity from " + full_path);
39  LoadCoefficient(full_path, 0);
40  } catch (NotFoundError const& e) {
41  std::stringstream ss;
42  ss << e.what() << std::endl;
43  log->Warn(ss.str());
44  }
45 }
void LoadOpacity()
Load opacity from internal variable.
Definition: absorber.cpp:30
std::string opacity_filename_
opacity filename
Definition: absorber.hpp:67
Absorber(std::string name)
Definition: absorber.cpp:11
virtual void LoadCoefficient(std::string fname, size_t bid)
Load absorption coefficient from file.
Definition: absorber.hpp:44
virtual ~Absorber()
Definition: absorber.cpp:16
void SetOpacityFile(std::string filename)
Set opacity filename to internal variable, does not load opacity.
Definition: absorber.cpp:26
void LoadOpacityFromFile(std::string filename)
Combines SetOpacityFile() and LoadOpacity()
Definition: absorber.cpp:21
std::string GetName() const