1#ifndef SOLAR_VECTOR_VARIABLE_SPICE_H
2#define SOLAR_VECTOR_VARIABLE_SPICE_H
4#define SOLAR_VECTOR_VARIABLE_SPICE_VERSION "8"
18#include "../../src/GenericSubmodule.h"
19#include "../../src/ModuleFactory.h"
44 static bool m_registered;
45 std::string m_ini_filepath{
"solar_vector/SolarVectorVariableSpice.ini"};
46 std::valarray<T> m_solar_vector;
63 bool exec(std::string_view
param)
override;
66 bool preTimeStep()
override;
67 bool postTimeStep()
override {
return true; };
68 bool output()
override {
return true; };
70 void calculateSolarVector();
72 void setFieldPtr(std::shared_ptr<std::valarray<T>>
field_ptr)
override
79 return std::make_shared<SolarVectorVariableSpice<T>>(sim);
81 static std::string getName() {
return "SolarVectorVariableSpice"; }
82 std::string_view getNameLocal()
const override {
return "SolarVectorVariableSpice"; };
83 std::vector<std::string> getDependencies()
const override
85 return this->ini_file_data.getStringVectorParameters(
"dependencies");
98 this->sim->m_simulation_config.getStringParameters(
"ini_folder_path")};
100 this->m_generic_submodules = this->ini_file_data.getStringVectorParameters(
"submodules");
104 std::cerr <<
"[SolarVectorVariableSpice]: " <<
e.what() <<
'\n';
105 throw BadInput(
static_cast<std::string
>(
"[SolarVectorVariableSpice]: ")
106 +
static_cast<std::string
>(
e.what()));
114 m_solar_vector.resize(3);
122 if (
param ==
"InitChain")
126 if (
param ==
"PreTimeStepChain")
128 return preTimeStep();
130 if (
param ==
"PostTimeStepChain")
132 return postTimeStep();
134 if (
param ==
"OutputChain")
145 this->m_et = this->m_start_time_et + this->sim->elapsed_time;
147 spkpos_c(this->m_target, this->m_et, this->m_rotating_frame_id.c_str(),
this->m_abcorr.c_str(),
148 this->m_observer_id.c_str(),
this->m_body_center_to_sun_vector_rotating,
149 &
this->m_light_time);
152 for (
int i{0};
i < 3;
i++)
154 (*this->module_field)[
i] = this->m_body_center_to_sun_vector_rotating[
i] * 1000;
161 calculateSolarVector();
169 if (this->sim->my_rank == 0)
171 std::cout <<
"[SolarVectorVariableSpice]: Loading SPICE kernels.\n";
175 furnsh_c(this->ini_file_data.getStringParameters(
"spice_metakernel_path").c_str());
179 std::cerr <<
"[SolarVectorVariableSpice]: " <<
e.what() <<
'\n';
180 throw BadInput(
static_cast<std::string
>(
"[SolarVectorVariableSpice]: ")
181 +
static_cast<std::string
>(
e.what()));
183 if (this->sim->my_rank == 0)
185 std::cout <<
"[SolarVectorVariableSpice]: Done.\n";
191 this->m_start_time_utc = this->ini_file_data.getStringParameters(
"start_time_utc");
192 str2et_c(this->m_start_time_utc.c_str(), &
this->m_start_time_et);
194 this->m_observer_id = this->ini_file_data.getStringParameters(
"object_id");
195 this->m_reference_frame_id = this->ini_file_data.getStringParameters(
"reference_frame_id");
196 this->m_rotating_frame_id = this->ini_file_data.getStringParameters(
"rotating_frame_id");
197 this->m_abcorr = this->ini_file_data.getStringParameters(
"abcorr");
201 std::cerr <<
"[SolarVectorVariableSpice]: " <<
e.what() <<
'\n';
202 throw BadInput(
static_cast<std::string
>(
"[SolarVectorVariableSpice]: ")
203 +
static_cast<std::string
>(
e.what()));
205 if (this->sim->my_rank == 0)
207 std::cout <<
"[SolarVectorVariableSpice]: Loaded parameters.\n";
210 calculateSolarVector();
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:37
CsrSparseMatrix()
Constructor for an empty CsrSparseMatrix object. Leaves all storage arrays empty but sets the flag to...
Definition CsrMatrix.h:94
Abstract base class for the submodules. Submodules are below managing modules and will only be run by...
Definition GenericSubmodule.h:25
static constexpr bool registerModule(std::string name, creation_method module) noexcept
Function that adds a module to the module registry map.
Definition ModuleFactory.h:75