initial working 1x2v working, review and optimization needed

This commit is contained in:
Vasco C. B. Ferreira
2026-07-22 20:17:56 +02:00
parent 503a5a41c9
commit 649464e2fc
10 changed files with 84 additions and 91 deletions
+3 -14
View File
@@ -1,7 +1,7 @@
#ifndef FIELDS_H
#define FIELDS_H
#include "grids.h"
#include "nufi/grids.h"
#include "nufi/parameters.h"
#include "nufi/poisson_problem.h"
#include <cmath>
@@ -21,26 +21,15 @@ inline std::vector<double> make_x_eval(size_t Nx) {
for (unsigned int i = 0; i < Nx; ++i) {
x_eval_E.push_back(Parameters::X_DOMAIN_LEFT + (i + 0.5) * dx);
}
// std::vector<double> x_eval(Nx);
// const double dx = Parameters::LX / Nx;
// for (size_t i = 0; i < Nx; ++i)
// x_eval[i] = Parameters::X_DOMAIN_LEFT + i * dx;
return x_eval_E;
}
inline void reset_x_eval(std::vector<double> &x_vals) {
const size_t Nx = x_vals.size();
const double dx = Parameters::LX / Nx;
for (size_t i = 0; i < Nx; ++i)
x_vals[i] = Parameters::X_DOMAIN_LEFT + i * dx;
};
inline double f0(const double x, const double v,
inline double f0(const double x, const double v1, const double v2,
const double eps = Parameters::EPS,
const double k = Parameters::WAVE_NR) {
const double prefactor =
Parameters::F0_FACTOR * (1.0 + eps * std::cos(k * x));
const double gaussian = v * v * std::exp(-0.5 * v * v);
const double gaussian = v1 * v1 * std::exp(-0.5 * (v1 * v1 + v2 * v2));
return prefactor * gaussian;
}
+5 -4
View File
@@ -24,13 +24,14 @@ public:
eval_rho(unsigned int n, std::vector<double> &x,
const std::vector<GridStructure<1>> &grid_struct,
const std::vector<SolutionSnapshot<1>> &phi_history,
const unsigned int Nv = Parameters::NV) const;
const unsigned int Nv1 = Parameters::NV_1,
const unsigned int Nv2 = Parameters::NV_2) const;
std::vector<double>
eval_ftilda(unsigned int n, std::vector<double> x, double u,
eval_ftilda(unsigned int n, std::vector<double> x, double u1, double u2,
const std::vector<GridStructure<1>> &grid_struct,
const std::vector<SolutionSnapshot<1>> &phi_history) const;
std::vector<double>
eval_f(unsigned int n, std::vector<double> x, double u,
eval_f(unsigned int n, std::vector<double> x, double u1, double u2,
const std::vector<GridStructure<1>> &grid_struct,
const std::vector<SolutionSnapshot<1>> &phi_history) const;
@@ -38,7 +39,7 @@ public:
eval_rho_points(unsigned int n, const std::vector<Point<1>> &points,
const std::vector<GridStructure<1>> &grid_struct,
const std::vector<SolutionSnapshot<1>> &phi_history,
const unsigned int Nv) const;
const unsigned int Nv1, const unsigned int Nv2) const;
private:
unsigned int Nt = std::floor(Parameters::TMAX / Parameters::DT);
+10 -4
View File
@@ -16,12 +16,17 @@ constexpr double LX_INV = 1 / LX;
constexpr size_t CALC_NX = 256;
constexpr double CALC_DX = LX / CALC_NX;
constexpr double V_DOMAIN_LEFT = -10.;
constexpr double V_DOMAIN_RIGHT = 10.;
constexpr double V_DOMAIN_LEFT_1 = -10.;
constexpr double V_DOMAIN_RIGHT_1 = 10.;
constexpr unsigned int NV = 128;
constexpr double DV = std::abs(V_DOMAIN_RIGHT - V_DOMAIN_LEFT) / NV;
constexpr unsigned int NV_1 = 128;
constexpr double DV_1 = std::abs(V_DOMAIN_RIGHT_1 - V_DOMAIN_LEFT_1) / NV_1;
constexpr double V_DOMAIN_LEFT_2 = -10.;
constexpr double V_DOMAIN_RIGHT_2 = 10.;
constexpr unsigned int NV_2 = 128;
constexpr double DV_2 = std::abs(V_DOMAIN_RIGHT_2 - V_DOMAIN_LEFT_2) / NV_2;
// deal.ii options
constexpr unsigned int GLOBAL_REFINEMENT = 6;
constexpr unsigned int FE_DEGREE = 3;
@@ -45,6 +50,7 @@ constexpr unsigned int REFINE_FREQUENCY = 30;
constexpr int PLOT_FREQUENCY = 10;
constexpr size_t PLOT_NX = CALC_NX;
constexpr double PLOT_DX = LX / PLOT_NX;
constexpr double PLOT_FIXED_V2 = 0.;
const std::string PLOT_DIR = "results/";
} // namespace Parameters
+1 -2
View File
@@ -2,14 +2,13 @@
#define SAVE_RESULTS_H
#include "nufi/grids.h"
#include "nufi/poisson_problem.h"
#include <deal.II/lac/vector.h>
#include <string>
#include <vector>
class NuFISolver;
void save_f(const NuFISolver &solver, unsigned int n,
void save_f(const NuFISolver &solver, unsigned int n, const double v2_0,
std::vector<GridStructure<1>> &grid_struct,
std::vector<SolutionSnapshot<1>> &phi_history, unsigned int Nx_out,
unsigned int Nv_out, const std::string &filename);