mirror of
https://codeberg.org/vcbferreira/NuFI_deal.ii
synced 2026-08-12 22:43:17 +02:00
refinment working with history of grids
This commit is contained in:
+9
-18
@@ -27,7 +27,7 @@
|
||||
using namespace dealii;
|
||||
|
||||
std::vector<double> NuFISolver::eval_ftilda(
|
||||
unsigned int n, std::vector<double> &X, double u,
|
||||
unsigned int n, std::vector<double> X, double u,
|
||||
const std::vector<GridStructure<1>> &grid_struct,
|
||||
const std::vector<SolutionSnapshot<1>> &phi_history) const {
|
||||
|
||||
@@ -38,7 +38,7 @@ std::vector<double> NuFISolver::eval_ftilda(
|
||||
if (n == 0) {
|
||||
for (size_t i = 0; i < x_size; ++i)
|
||||
results[i] = f0(X[i], U[i]);
|
||||
reset_x_eval(X);
|
||||
// reset_x_eval(X);
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -86,12 +86,12 @@ std::vector<double> NuFISolver::eval_ftilda(
|
||||
}
|
||||
for (size_t i = 0; i < x_size; ++i)
|
||||
results[i] = f0(X[i], U[i]);
|
||||
reset_x_eval(X);
|
||||
// reset_x_eval(X);
|
||||
return results;
|
||||
}
|
||||
|
||||
std::vector<double>
|
||||
NuFISolver::eval_f(unsigned int n, std::vector<double> &X, double u,
|
||||
NuFISolver::eval_f(unsigned int n, std::vector<double> X, double u,
|
||||
const std::vector<GridStructure<1>> &grid_struct,
|
||||
const std::vector<SolutionSnapshot<1>> &phi_history) const {
|
||||
|
||||
@@ -102,7 +102,7 @@ NuFISolver::eval_f(unsigned int n, std::vector<double> &X, double u,
|
||||
if (n == 0) {
|
||||
for (size_t i = 0; i < x_size; ++i)
|
||||
results[i] = f0(X[i], U[i]);
|
||||
reset_x_eval(X);
|
||||
// reset_x_eval(X);
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ NuFISolver::eval_f(unsigned int n, std::vector<double> &X, double u,
|
||||
|
||||
for (size_t i = 0; i < x_size; ++i)
|
||||
results[i] = f0(X[i], U[i]);
|
||||
reset_x_eval(X);
|
||||
// reset_x_eval(X);
|
||||
return results;
|
||||
}
|
||||
|
||||
@@ -243,8 +243,8 @@ void NuFISolver::run() {
|
||||
<< std::endl;
|
||||
|
||||
// START: diagnostics
|
||||
std::cout << "cells = " << poisson.triangulation.n_active_cells() << "\n"
|
||||
<< " dofs = " << poisson.dof_handler.n_dofs() << "\n";
|
||||
// std::cout << "cells = " << poisson.triangulation.n_active_cells() << "\n"
|
||||
// << " dofs = " << poisson.dof_handler.n_dofs() << "\n";
|
||||
// double min_h = 1e100;
|
||||
// double max_h = 0;
|
||||
//
|
||||
@@ -311,16 +311,7 @@ void NuFISolver::run() {
|
||||
save_rho(*this, it, grid_versions, phi_history, Parameters::PLOT_NX,
|
||||
"results/rho_" + std::to_string(it) + ".dat");
|
||||
|
||||
// std::vector<double> x_eval_Ex = make_x_eval(Parameters::PLOT_NX);
|
||||
// std::vector<double> tmp_Ex(x_eval_Ex.size());
|
||||
// tmp_Ex = eval(x_eval_Ex, grid_versions[phi_history[it].grid_version],
|
||||
// phi_history[it].solution);
|
||||
//
|
||||
// std::vector<double> E_x(Parameters::PLOT_NX);
|
||||
// for (size_t i = 0; i < Parameters::PLOT_NX; ++i)
|
||||
// E_x[i] = -tmp_Ex[i];
|
||||
// save_space_vector(E_x, "field", it);
|
||||
save_Efield_new(it, grid_versions, phi_history);
|
||||
save_Efield(it, grid_versions, phi_history);
|
||||
|
||||
double int_val = 0.5 * integral_space_vector_squared(
|
||||
grid_versions[phi_history[it].grid_version],
|
||||
|
||||
+4
-28
@@ -72,10 +72,9 @@ void save_rho(const NuFISolver &solver, unsigned int n,
|
||||
file.close();
|
||||
}
|
||||
|
||||
void save_Efield_new(unsigned int it,
|
||||
std::vector<GridStructure<1>> &grid_versions,
|
||||
std::vector<SolutionSnapshot<1>> &phi_history,
|
||||
unsigned int Nx_out) {
|
||||
void save_Efield(unsigned int it, std::vector<GridStructure<1>> &grid_versions,
|
||||
std::vector<SolutionSnapshot<1>> &phi_history,
|
||||
unsigned int Nx_out) {
|
||||
std::vector<double> x_eval_E = make_x_eval(Nx_out);
|
||||
|
||||
auto grad_phi = eval(x_eval_E, grid_versions[phi_history[it].grid_version],
|
||||
@@ -96,34 +95,11 @@ void save_Efield_new(unsigned int it,
|
||||
E_file << x << " " << E << "\n";
|
||||
|
||||
std::cout << "Saving iteration " << it << " using grid version "
|
||||
<< phi_history[it].grid_version << "\n";
|
||||
<< phi_history[it].grid_version << "\n\n";
|
||||
|
||||
E_file.close();
|
||||
}
|
||||
|
||||
void save_Efield([[maybe_unused]] unsigned int n, GridStructure<1> &grid_struct,
|
||||
std::vector<SolutionSnapshot<1>> &phi_history,
|
||||
unsigned int Nx_out, const std::string &filename) {
|
||||
std::ofstream file(filename);
|
||||
|
||||
double xmin = Parameters::X_DOMAIN_LEFT;
|
||||
double xmax = Parameters::X_DOMAIN_RIGHT;
|
||||
|
||||
std::vector<double> x_eval = make_x_eval(Nx_out);
|
||||
|
||||
// select from E_coeffs
|
||||
|
||||
file << Nx_out << "\n";
|
||||
file << xmin << " " << xmax << "\n";
|
||||
|
||||
std::vector<double> tmp = eval(x_eval, grid_struct, phi_history[n].solution);
|
||||
for (size_t i = 0; i < Nx_out; ++i) {
|
||||
file << -tmp[i];
|
||||
file << "\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");
|
||||
|
||||
Reference in New Issue
Block a user