1#ifndef SOLAR_VECTOR_VARIABLE_SPICE_H
2#define SOLAR_VECTOR_VARIABLE_SPICE_H
4#define SOLAR_VECTOR_VARIABLE_SPICE_VERSION "7"
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 <<
e.what() <<
'\n';
112 m_solar_vector.resize(3);
120 if (
param ==
"InitChain")
124 if (
param ==
"PreTimeStepChain")
126 return preTimeStep();
128 if (
param ==
"PostTimeStepChain")
130 return postTimeStep();
132 if (
param ==
"OutputChain")
143 this->m_et = this->m_start_time_et + this->sim->elapsed_time;
145 spkpos_c(this->m_target, this->m_et, this->m_rotating_frame_id.c_str(),
this->m_abcorr.c_str(),
146 this->m_observer_id.c_str(),
this->m_body_center_to_sun_vector_rotating,
147 &
this->m_light_time);
150 for (
int i{0};
i < 3;
i++)
152 (*this->module_field)[
i] = this->m_body_center_to_sun_vector_rotating[
i] * 1000;
159 calculateSolarVector();
167 if (this->sim->my_rank == 0)
169 std::cout <<
"[SolarVectorVariableSpice] Loading SPICE kernels.\n";
171 furnsh_c(this->ini_file_data.getStringParameters(
"spice_metakernel_path").c_str());
172 if (this->sim->my_rank == 0)
174 std::cout <<
"[SolarVectorVariableSpice] Done.\n";
178 this->m_start_time_utc = this->ini_file_data.getStringParameters(
"start_time_utc");
179 str2et_c(this->m_start_time_utc.c_str(), &
this->m_start_time_et);
181 this->m_observer_id = this->ini_file_data.getStringParameters(
"object_id");
182 this->m_reference_frame_id = this->ini_file_data.getStringParameters(
"reference_frame_id");
183 this->m_rotating_frame_id = this->ini_file_data.getStringParameters(
"rotating_frame_id");
184 this->m_abcorr = this->ini_file_data.getStringParameters(
"abcorr");
185 if (this->sim->my_rank == 0)
187 std::cout <<
"[SolarVectorVariableSpice] Loaded parameters.\n";
190 calculateSolarVector();
Concrete implementation of a matrix class representing a Compressed Sparse Rows (CSR) matrix....
Definition CsrMatrix.h:35
CsrSparseMatrix()
Constructor for an empty CsrSparseMatrix object. Leaves all storage arrays empty but sets the flag to...
Definition CsrMatrix.h:92
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