diff --git a/Makefile b/Makefile index 38f5543..adbe8ea 100644 --- a/Makefile +++ b/Makefile @@ -1,36 +1,45 @@ # CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.31 +# Generated by "Unix Makefiles" Generator, CMake Version 3.18 # Default target executed when no arguments are given to make. default_target: all + .PHONY : default_target # Allow only one "make -f Makefile2" at a time, but pass parallelism. .NOTPARALLEL: + #============================================================================= # Special targets provided by cmake. # Disable implicit rules so canonical targets will work. .SUFFIXES: + # Disable VCS-based implicit rules. % : %,v + # Disable VCS-based implicit rules. % : RCS/% + # Disable VCS-based implicit rules. % : RCS/%,v + # Disable VCS-based implicit rules. % : SCCS/s.% + # Disable VCS-based implicit rules. % : s.% + .SUFFIXES: .hpux_make_needs_suffix_list + # Command-line flag to silence nested $(MAKE). $(VERBOSE)MAKESILENT = -s @@ -39,6 +48,7 @@ $(VERBOSE).SILENT: # A target that is always out of date. cmake_force: + .PHONY : cmake_force #============================================================================= @@ -48,10 +58,10 @@ cmake_force: SHELL = /bin/sh # The CMake executable. -CMAKE_COMMAND = /usr/bin/cmake +CMAKE_COMMAND = /usr/local/bin/cmake # The command to remove a file. -RM = /usr/bin/cmake -E rm -f +RM = /usr/local/bin/cmake -E rm -f # Escaping for special characters. EQUALS = = @@ -65,26 +75,28 @@ CMAKE_BINARY_DIR = /home/vf/Thesis/dealII_NuFI/1x1v #============================================================================= # Targets provided globally by CMake. +# Special rule for the target rebuild_cache +rebuild_cache: + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." + /usr/local/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) +.PHONY : rebuild_cache + +# Special rule for the target rebuild_cache +rebuild_cache/fast: rebuild_cache + +.PHONY : rebuild_cache/fast + # Special rule for the target edit_cache edit_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake cache editor..." + @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." /usr/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) .PHONY : edit_cache # Special rule for the target edit_cache edit_cache/fast: edit_cache + .PHONY : edit_cache/fast -# Special rule for the target rebuild_cache -rebuild_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake to regenerate build system..." - /usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : rebuild_cache - -# Special rule for the target rebuild_cache -rebuild_cache/fast: rebuild_cache -.PHONY : rebuild_cache/fast - # The main all target all: cmake_check_build_system $(CMAKE_COMMAND) -E cmake_progress_start /home/vf/Thesis/dealII_NuFI/1x1v/CMakeFiles /home/vf/Thesis/dealII_NuFI/1x1v//CMakeFiles/progress.marks @@ -99,6 +111,7 @@ clean: # The main clean target clean/fast: clean + .PHONY : clean/fast # Prepare targets for installation. @@ -116,19 +129,6 @@ depend: $(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 .PHONY : depend -#============================================================================= -# Target rules for targets named nufi_lib - -# Build rule for target. -nufi_lib: cmake_check_build_system - $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 nufi_lib -.PHONY : nufi_lib - -# fast build rule for target. -nufi_lib/fast: - $(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_lib.dir/build.make CMakeFiles/nufi_lib.dir/build -.PHONY : nufi_lib/fast - #============================================================================= # Target rules for targets named nufi_poisson @@ -142,7 +142,21 @@ nufi_poisson/fast: $(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_poisson.dir/build.make CMakeFiles/nufi_poisson.dir/build .PHONY : nufi_poisson/fast +#============================================================================= +# Target rules for targets named nufi_lib + +# Build rule for target. +nufi_lib: cmake_check_build_system + $(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 nufi_lib +.PHONY : nufi_lib + +# fast build rule for target. +nufi_lib/fast: + $(MAKE) $(MAKESILENT) -f CMakeFiles/nufi_lib.dir/build.make CMakeFiles/nufi_lib.dir/build +.PHONY : nufi_lib/fast + src/main.o: src/main.cc.o + .PHONY : src/main.o # target to build an object file @@ -151,6 +165,7 @@ src/main.cc.o: .PHONY : src/main.cc.o src/main.i: src/main.cc.i + .PHONY : src/main.i # target to preprocess a source file @@ -159,6 +174,7 @@ src/main.cc.i: .PHONY : src/main.cc.i src/main.s: src/main.cc.s + .PHONY : src/main.s # target to generate assembly for a file @@ -167,6 +183,7 @@ src/main.cc.s: .PHONY : src/main.cc.s src/nufi_solver.o: src/nufi_solver.cc.o + .PHONY : src/nufi_solver.o # target to build an object file @@ -175,6 +192,7 @@ src/nufi_solver.cc.o: .PHONY : src/nufi_solver.cc.o src/nufi_solver.i: src/nufi_solver.cc.i + .PHONY : src/nufi_solver.i # target to preprocess a source file @@ -183,6 +201,7 @@ src/nufi_solver.cc.i: .PHONY : src/nufi_solver.cc.i src/nufi_solver.s: src/nufi_solver.cc.s + .PHONY : src/nufi_solver.s # target to generate assembly for a file @@ -191,6 +210,7 @@ src/nufi_solver.cc.s: .PHONY : src/nufi_solver.cc.s src/save_results.o: src/save_results.cc.o + .PHONY : src/save_results.o # target to build an object file @@ -199,6 +219,7 @@ src/save_results.cc.o: .PHONY : src/save_results.cc.o src/save_results.i: src/save_results.cc.i + .PHONY : src/save_results.i # target to preprocess a source file @@ -207,6 +228,7 @@ src/save_results.cc.i: .PHONY : src/save_results.cc.i src/save_results.s: src/save_results.cc.s + .PHONY : src/save_results.s # target to generate assembly for a file diff --git a/README.md b/README.md index 8cc1b1c..309d4a1 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,6 @@ This simulation of the Vlasov-Poisson system in 1x1v dimensions uses --- status: -Fail - --------------------------------------------------------- +Refinement working: +- grid versions saved on a vector +- solutions point to a version of the grid diff --git a/cmake_install.cmake b/cmake_install.cmake index fd9fade..ad9d58c 100644 --- a/cmake_install.cmake +++ b/cmake_install.cmake @@ -37,30 +37,18 @@ if(NOT DEFINED CMAKE_CROSSCOMPILING) set(CMAKE_CROSSCOMPILING "FALSE") endif() -# Set path to fallback-tool for dependency-resolution. +# Set default install directory permissions. if(NOT DEFINED CMAKE_OBJDUMP) set(CMAKE_OBJDUMP "/usr/bin/objdump") endif() -string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT - "${CMAKE_INSTALL_MANIFEST_FILES}") -if(CMAKE_INSTALL_LOCAL_ONLY) - file(WRITE "/home/vf/Thesis/dealII_NuFI/1x1v/install_local_manifest.txt" - "${CMAKE_INSTALL_MANIFEST_CONTENT}") -endif() if(CMAKE_INSTALL_COMPONENT) - if(CMAKE_INSTALL_COMPONENT MATCHES "^[a-zA-Z0-9_.+-]+$") - set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") - else() - string(MD5 CMAKE_INST_COMP_HASH "${CMAKE_INSTALL_COMPONENT}") - set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INST_COMP_HASH}.txt") - unset(CMAKE_INST_COMP_HASH) - endif() + set(CMAKE_INSTALL_MANIFEST "install_manifest_${CMAKE_INSTALL_COMPONENT}.txt") else() set(CMAKE_INSTALL_MANIFEST "install_manifest.txt") endif() -if(NOT CMAKE_INSTALL_LOCAL_ONLY) - file(WRITE "/home/vf/Thesis/dealII_NuFI/1x1v/${CMAKE_INSTALL_MANIFEST}" +string(REPLACE ";" "\n" CMAKE_INSTALL_MANIFEST_CONTENT + "${CMAKE_INSTALL_MANIFEST_FILES}") +file(WRITE "/home/vf/Thesis/dealII_NuFI/1x1v/${CMAKE_INSTALL_MANIFEST}" "${CMAKE_INSTALL_MANIFEST_CONTENT}") -endif() diff --git a/libnufi_lib.a b/libnufi_lib.a index 8cf9535..b9e417c 100644 Binary files a/libnufi_lib.a and b/libnufi_lib.a differ diff --git a/nufi/grids.h b/nufi/grids.h index be7f960..d65fc90 100644 --- a/nufi/grids.h +++ b/nufi/grids.h @@ -48,6 +48,8 @@ template struct GridStructure { std::vector values(points.size()); + // Uses point_gradient + // #pragma omp parallel for // for (unsigned int p = 0; p < points.size(); ++p) { // @@ -60,6 +62,7 @@ template struct GridStructure { // return values; // } + // Uses cell locator #pragma omp parallel { std::vector local_solution_buffer(fe->n_dofs_per_cell()); @@ -82,9 +85,6 @@ template struct GridStructure { values[p] = evaluator.get_gradient(0)[0]; } } - // AssertThrow(dof_handler->n_dofs() == solution.size(), - // ExcMessage("Solution vector size does not match - // DoFHandler.)"); return values; } }; @@ -102,21 +102,11 @@ GridStructure make_grid_snapshot(PoissonProblem &poisson) { grid.fe = std::make_unique>(poisson.get_fe()); grid.dof_handler = std::make_unique>(*grid.triangulation); - grid.dof_handler->distribute_dofs(*grid.fe); grid.mapping = std::make_unique>(poisson.get_mapping()); - grid.constraints = - std::make_unique>(poisson.get_constraints()); - grid.locator = std::make_unique>(); - - // START: transfer poisson.solution to saved grid dofs - SolutionTransfer solution_transfer(*grid.dof_handler); - const Vector coarse_solution = poisson.solution; - solution_transfer.prepare_for_coarsening_and_refinement(coarse_solution); - // START: setup_system(); - grid.constraints->clear(); + grid.constraints = std::make_unique>(); DoFTools::make_hanging_node_constraints(*grid.dof_handler, *grid.constraints); DoFTools::make_periodicity_constraints(*grid.dof_handler, 0, 1, 0, @@ -147,21 +137,10 @@ GridStructure make_grid_snapshot(PoissonProblem &poisson) { grid.constraints->add_line(gauge_dof); grid.constraints->set_inhomogeneity(gauge_dof, 0.0); - grid.constraints->close(); - DynamicSparsityPattern dsp(grid.dof_handler->n_dofs()); - DoFTools::make_sparsity_pattern(*grid.dof_handler, dsp, *grid.constraints); - poisson.sparsity_pattern.copy_from(dsp); - poisson.system_matrix.reinit(poisson.sparsity_pattern); - poisson.solution.reinit(grid.dof_handler->n_dofs()); - poisson.system_rhs.reinit(grid.dof_handler->n_dofs()); - + grid.locator = std::make_unique>(); grid.locator->rebuild(*grid.dof_handler, *grid.triangulation); - // END - - solution_transfer.interpolate(coarse_solution, poisson.solution); - // END // START: diagnostics AssertThrow( @@ -169,32 +148,18 @@ GridStructure make_grid_snapshot(PoissonProblem &poisson) { grid.constraints->n_constraints(), ExcMessage( "PoissonProblem constraints doesn't match Snapshot constraints")); - for (auto c1 = poisson.get_dof_handler().begin_active(), - c2 = grid.dof_handler->begin_active(); - c1 != poisson.get_dof_handler().end(); ++c1, ++c2) { - std::vector d1(c1->get_fe().dofs_per_cell); - std::vector d2(c2->get_fe().dofs_per_cell); - - c1->get_dof_indices(d1); - c2->get_dof_indices(d2); - - AssertThrow(d1 == d2, ExcInternalError()); - } + // for (auto c1 = poisson.get_dof_handler().begin_active(), + // c2 = grid.dof_handler->begin_active(); + // c1 != poisson.get_dof_handler().end(); ++c1, ++c2) { + // std::vector d1(c1->get_fe().dofs_per_cell); + // std::vector d2(c2->get_fe().dofs_per_cell); // - // auto support_points = - // DoFTools::map_dofs_to_support_points(*grid.mapping, *grid.dof_handler); + // c1->get_dof_indices(d1); + // c2->get_dof_indices(d2); // - // std::cout << "COPY\n"; - // - // for (const auto &[dof, point] : support_points) { - // std::cout << dof << " : " << point[0] << "\n"; + // AssertThrow(d1 == d2, ExcInternalError()); // } - // for (auto cell : grid.dof_handler->active_cell_iterators()) { - // std::cout << "@ GridStructure: " << cell->id() << " " << - // cell->center()[0] - // << '\n'; - // } - // END + // END: diagnostics return grid; } diff --git a/nufi/nufi_solver.h b/nufi/nufi_solver.h index 32de460..8aa75fc 100644 --- a/nufi/nufi_solver.h +++ b/nufi/nufi_solver.h @@ -26,11 +26,11 @@ public: const std::vector> &phi_history, const unsigned int Nv = Parameters::NV) const; std::vector - eval_ftilda(unsigned int, std::vector &x, double u, + eval_ftilda(unsigned int n, std::vector x, double u, const std::vector> &grid_struct, const std::vector> &phi_history) const; std::vector - eval_f(unsigned int n, std::vector &x, double u, + eval_f(unsigned int n, std::vector x, double u, const std::vector> &grid_struct, const std::vector> &phi_history) const; diff --git a/nufi/parameters.h b/nufi/parameters.h index 675ec72..0f8926a 100644 --- a/nufi/parameters.h +++ b/nufi/parameters.h @@ -23,7 +23,7 @@ constexpr unsigned int NV = 128; constexpr double DV = std::abs(V_DOMAIN_RIGHT - V_DOMAIN_LEFT) / NV; // deal.ii options -constexpr unsigned int GLOBAL_REFINEMENT = 8; +constexpr unsigned int GLOBAL_REFINEMENT = 6; constexpr unsigned int FE_DEGREE = 3; constexpr unsigned int CONVERGENCE_ITERATIONS = 5000; constexpr double CONVERGENCE_LIMIT = 1e-8; @@ -39,10 +39,10 @@ constexpr double F0_FACTOR = 0.39894228040143267793994; // 1/sqrt(2pi) // NUFI options constexpr double DT = 1. / 10.; constexpr unsigned int TMAX = 100; -constexpr unsigned int REFINE_FREQUENCY = 3; +constexpr unsigned int REFINE_FREQUENCY = 30; // Plotting options -constexpr int PLOT_FREQUENCY = 1; +constexpr int PLOT_FREQUENCY = 10; constexpr size_t PLOT_NX = CALC_NX; constexpr double PLOT_DX = LX / PLOT_NX; const std::string PLOT_DIR = "results/"; diff --git a/nufi/poisson_problem.h b/nufi/poisson_problem.h index 3f3dbc9..ac1e8b2 100644 --- a/nufi/poisson_problem.h +++ b/nufi/poisson_problem.h @@ -103,43 +103,27 @@ public: void save_grid_to_file(std::string &filename) const; - Triangulation triangulation; - DoFHandler dof_handler; - CellLocator cell_locator; - - Vector solution; // phi - SparsityPattern sparsity_pattern; - SparseMatrix system_matrix; - Vector system_rhs; - private: void create_mesh(); void setup_system(); void assemble_system(); void solve(size_t it); - // Triangulation triangulation; - FE_Q fe; - // DoFHandler dof_handler; - - AffineConstraints constraints; - - // SparsityPattern sparsity_pattern; - // SparseMatrix system_matrix; - - // Vector solution; // phi - // Vector system_rhs; - std::function(const std::vector> &)> rhs_function; - // Vector rhs; MappingQ mapping; + FE_Q fe; + AffineConstraints constraints; + Triangulation triangulation; + DoFHandler dof_handler; + CellLocator cell_locator; + Vector solution; // phi + SparsityPattern sparsity_pattern; + SparseMatrix system_matrix; + Vector system_rhs; const bool PRINT_GAUGE_DOF_POSITION = true; - - // mutable std::vector local_solution_buffer; - // mutable std::unique_ptr> evaluator; }; //====//====// @@ -164,10 +148,10 @@ void PoissonProblem::set_rhs_function( template PoissonProblem::PoissonProblem(unsigned int degree) - : // triangulation(Triangulation::limit_level_difference_at_vertices), - triangulation(), dof_handler(triangulation), fe(degree), mapping(degree) { + : mapping(degree), fe(degree), triangulation(), dof_handler(triangulation) { } +// Uses FEPointEvaluation template std::vector PoissonProblem::sample_electric_field(double x_min, double x_max, @@ -180,32 +164,27 @@ PoissonProblem::sample_electric_field(double x_min, double x_max, const double x = x_min + i * dx; const Point point(x); - // 1. Find the active cell containing x const auto cell_point_pair = GridTools::find_active_cell_around_point(mapping, dof_handler, point); const auto cell = cell_point_pair.first; const Point &unit_point = cell_point_pair.second; - // 2. FEPointEvaluation expects an ArrayView of points std::vector> points(1, unit_point); ArrayView> point_view(points); FEPointEvaluation<1, dim> evaluator(mapping, dof_handler.get_fe(), update_gradients); - // reinit with ArrayView of points evaluator.reinit(cell, point_view); Vector local_dofs(dof_handler.get_fe().dofs_per_cell); cell->get_dof_values(solution, local_dofs); - // 3. Evaluate gradient at this point evaluator.evaluate(local_dofs, EvaluationFlags::gradients); const Tensor<1, dim> grad_phi = evaluator.get_gradient(0); - // 4. Compute E = -grad(phi) E_values[i] = -grad_phi[0]; } @@ -471,6 +450,8 @@ template void PoissonProblem::coarse_and_refine_grid(size_t it) { template void PoissonProblem::solve(size_t it) { + std::cout << "Calling PoissonProblem::solve for time-step " << it << "\n"; + SolverControl solver_control(Parameters::CONVERGENCE_ITERATIONS, Parameters::CONVERGENCE_LIMIT * system_rhs.l2_norm()); @@ -479,26 +460,26 @@ template void PoissonProblem::solve(size_t it) { solver.solve(system_matrix, solution, system_rhs, PreconditionIdentity()); constraints.distribute(solution); - std::ofstream out("results/phi_after_solve_" + std::to_string(it) + ".dat"); - std::vector> data; - - const auto support = - DoFTools::map_dofs_to_support_points(mapping, dof_handler); - - for (const auto &[dof, p] : support) { - data.emplace_back(p[0], solution[dof]); - } - - std::sort(data.begin(), data.end()); - - for (const auto &[x, value] : data) { - out << x << " " << value << "\n"; - } - - std::vector E_x = - sample_electric_field(Parameters::X_DOMAIN_LEFT, - Parameters::X_DOMAIN_RIGHT, Parameters::PLOT_NX); - save_space_vector(E_x, "E_x_after_solve", it); + // std::ofstream out("results/phi_after_solve_" + std::to_string(it) + + // ".dat"); std::vector> data; + // + // const auto support = + // DoFTools::map_dofs_to_support_points(mapping, dof_handler); + // + // for (const auto &[dof, p] : support) { + // data.emplace_back(p[0], solution[dof]); + // } + // + // std::sort(data.begin(), data.end()); + // + // for (const auto &[x, value] : data) { + // out << x << " " << value << "\n"; + // } + // + // std::vector E_x = + // sample_electric_field(Parameters::X_DOMAIN_LEFT, + // Parameters::X_DOMAIN_RIGHT, Parameters::PLOT_NX); + // save_space_vector(E_x, "E_x_after_solve", it); } template void PoissonProblem::initialize() { @@ -512,13 +493,10 @@ void PoissonProblem::solve_step( if (refining) { coarse_and_refine_grid(it); setup_system(); + update_grid_versions(grid_versions, *this); } - assemble_system(); solve(it); - - if (refining) - update_grid_versions(grid_versions, *this); } // NuFI doesnt use this, kept only for testing PoissonProblem diff --git a/nufi/save_results.h b/nufi/save_results.h index 227d351..c5f18fa 100644 --- a/nufi/save_results.h +++ b/nufi/save_results.h @@ -19,14 +19,9 @@ void save_rho(const NuFISolver &solver, unsigned int n, std::vector> &phi_history, unsigned int Nx_out, const std::string &filename); -void save_Efield(unsigned int n, GridStructure<1> &grid_struct, +void save_Efield(unsigned int it, std::vector> &grid_versions, std::vector> &phi_history, - unsigned int Nx_out, const std::string &filename); - -void save_Efield_new(unsigned int it, - std::vector> &grid_versions, - std::vector> &phi_history, - unsigned int Nx_out = Parameters::PLOT_NX); + unsigned int Nx_out = Parameters::PLOT_NX); void save_space_vector(const std::vector &vals, const std::string &filename, size_t it); diff --git a/src/nufi_solver.cc b/src/nufi_solver.cc index 3c57079..88733fd 100644 --- a/src/nufi_solver.cc +++ b/src/nufi_solver.cc @@ -27,7 +27,7 @@ using namespace dealii; std::vector NuFISolver::eval_ftilda( - unsigned int n, std::vector &X, double u, + unsigned int n, std::vector X, double u, const std::vector> &grid_struct, const std::vector> &phi_history) const { @@ -38,7 +38,7 @@ std::vector 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 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 -NuFISolver::eval_f(unsigned int n, std::vector &X, double u, +NuFISolver::eval_f(unsigned int n, std::vector X, double u, const std::vector> &grid_struct, const std::vector> &phi_history) const { @@ -102,7 +102,7 @@ NuFISolver::eval_f(unsigned int n, std::vector &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 &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 x_eval_Ex = make_x_eval(Parameters::PLOT_NX); - // std::vector 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 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], diff --git a/src/save_results.cc b/src/save_results.cc index 431d0cb..09ca5ca 100644 --- a/src/save_results.cc +++ b/src/save_results.cc @@ -72,10 +72,9 @@ void save_rho(const NuFISolver &solver, unsigned int n, file.close(); } -void save_Efield_new(unsigned int it, - std::vector> &grid_versions, - std::vector> &phi_history, - unsigned int Nx_out) { +void save_Efield(unsigned int it, std::vector> &grid_versions, + std::vector> &phi_history, + unsigned int Nx_out) { std::vector 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> &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 x_eval = make_x_eval(Nx_out); - - // select from E_coeffs - - file << Nx_out << "\n"; - file << xmin << " " << xmax << "\n"; - - std::vector 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 &vals, const std::string &filename, size_t it) { std::ofstream file("results/" + filename + "_" + std::to_string(it) + ".dat");