Canoe
Comprehensive Atmosphere N' Ocean Engine
inversion_tasks.cpp
Go to the documentation of this file.
1 // C/C++
2 #include <iostream>
3 #include <sstream>
4 #include <stdexcept>
5 
6 // athena
7 #include <athena/athena.hpp>
8 #include <athena/mesh/mesh.hpp>
9 #include <athena/parameter_input.hpp>
10 
11 // canoe
12 #include <impl.hpp>
13 
14 // inversion
15 #include <inversion/inversion.hpp>
16 
17 // tasklist
18 #include "extra_tasks.hpp"
19 
20 using namespace InversionTaskNames;
21 
22 InversionTasks::InversionTasks(ParameterInput *pin, Mesh *pm) {
23  nstages = 1;
24  std::string task = pin->GetString("inversion", "task");
25 
26  // Now assemble list of tasks for each step of inversion task
27 
28  if (task == "atm_profile") {
29  AddTask(SAMPLE, NONE);
30  } else {
31  std::stringstream msg;
32  msg << "### FATAL ERROR in InversionTasks::InversionTasks" << std::endl
33  << "Unrecognized inversion task";
34  ATHENA_ERROR(msg);
35  // AddTask(CALC_GRAD,NONE);
36  // AddTask(OPTIMIZE,CALC_GRAD);
37  }
38 }
39 
40 void InversionTasks::AddTask(const TaskID &id, const TaskID &dep) {
41  task_list_[ntasks].task_id = id;
42  task_list_[ntasks].dependency = dep;
43 
44  if (id == CALC_GRAD) {
45  task_list_[ntasks].TaskFunc =
46  static_cast<enum TaskStatus (TaskList::*)(MeshBlock *, int)>(
48  } else if (id == OPTIMIZE) {
49  task_list_[ntasks].TaskFunc =
50  static_cast<enum TaskStatus (TaskList::*)(MeshBlock *, int)>(
52  } else if (id == SAMPLE) {
53  task_list_[ntasks].TaskFunc =
54  static_cast<enum TaskStatus (TaskList::*)(MeshBlock *, int)>(
56  } else {
57  std::stringstream msg;
58  msg << "### FATAL ERROR in InversionTasks::AddTask" << std::endl
59  << "Invalid Task is specified" << std::endl;
60  ATHENA_ERROR(msg);
61  }
62  ntasks++;
63  return;
64 }
65 
66 void InversionTasks::StartupTaskList(MeshBlock *pmb, int stage) {}
67 
68 TaskStatus InversionTasks::CalculateGradient(MeshBlock *pmb, int step) {
69  // std::cout << "Calculate gradient" << std::endl;
70  return TaskStatus::success;
71 }
72 
73 TaskStatus InversionTasks::Optimize(MeshBlock *pmb, int step) {
74  // std::cout << "Optimize" << std::endl;
75  return TaskStatus::success;
76 }
77 
78 TaskStatus InversionTasks::Sample(MeshBlock *pmb, int step) {
79  // pmb->pimpl->fitq.front()->MCMCMove(pmb->pimpl->prad.get(), pmb->phydro);
80  // std::cout << "Sample" << std::endl;
81  return TaskStatus::success;
82 }
void StartupTaskList(MeshBlock *pmb, int stage) override
TaskStatus Optimize(MeshBlock *pmb, int step)
void AddTask(const TaskID &id, const TaskID &dep) override
InversionTasks(ParameterInput *pin, Mesh *pm)
TaskStatus CalculateGradient(MeshBlock *pmb, int step)
TaskStatus Sample(MeshBlock *pmb, int step)
const TaskID SAMPLE(3)
const TaskID NONE(0)
const TaskID CALC_GRAD(1)
const TaskID OPTIMIZE(2)