updated params, added save vector to save_results

This commit is contained in:
Vasco C. B. Ferreira
2026-03-25 15:30:19 +01:00
parent f362a2bfa0
commit f2499fea2f
3 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ namespace Parameters
//spline options
constexpr int SPLINE_NX = 562;
constexpr double SPLINE_DX = LX/SPLINE_NX;
constexpr double SPLINE_DX = LX/(SPLINE_NX-1);
constexpr size_t SPLINE_ORDER = 4;
//Plotting options
+2
View File
@@ -23,4 +23,6 @@ void save_Efield(unsigned int n,
unsigned int Nx_out,
const std::string &filename);
void save_space_vector(const std::vector<double>& vals, const std::string& filename, size_t it);
#endif
+12
View File
@@ -102,3 +102,15 @@ void save_Efield(unsigned int n,
}
file.close();
}
void save_space_vector(const std::vector<double>& vals, const std::string& filename, size_t it)
{
std::ofstream file("results/" + filename + "_" + std::to_string(it) + ".dat");
if (!file) throw std::runtime_error("failed to start file in results/");
file << vals.size() << "\n";
file << Parameters::X_DOMAIN_LEFT << " " << Parameters::X_DOMAIN_RIGHT << "\n";
file << std::fixed << std::setprecision(8);
for (double val : vals) file << val << "\n";
}