mirror of
https://codeberg.org/vcbferreira/NuFI_deal.ii
synced 2026-08-12 14:33:18 +02:00
sim working correctly fully in fem
This commit is contained in:
Binary file not shown.
+2
-2
@@ -76,8 +76,8 @@ inline double eval(double x, const PoissonProblem<1> &poisson,
|
|||||||
|
|
||||||
x = x - Parameters::LX * std::floor(x * Parameters::LX_INV); // in domain
|
x = x - Parameters::LX * std::floor(x * Parameters::LX_INV); // in domain
|
||||||
|
|
||||||
return eval_point<1>(poisson.get_mapping(), poisson.get_dof_handler(),
|
return eval_point_grad<1>(poisson.get_mapping(), poisson.get_dof_handler(),
|
||||||
solution, Point<1>(x));
|
solution, Point<1>(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double integral_space_vector(const PoissonProblem<1> &poisson,
|
inline double integral_space_vector(const PoissonProblem<1> &poisson,
|
||||||
|
|||||||
+1
-1
@@ -36,7 +36,7 @@ constexpr double DT = 1. / 8.;
|
|||||||
constexpr unsigned int TMAX = 100;
|
constexpr unsigned int TMAX = 100;
|
||||||
|
|
||||||
// Plotting options
|
// Plotting options
|
||||||
constexpr int PLOT_FREQUENCY = 10;
|
constexpr int PLOT_FREQUENCY = 4;
|
||||||
constexpr size_t PLOT_NX = CALC_NX;
|
constexpr size_t PLOT_NX = CALC_NX;
|
||||||
constexpr double PLOT_DX = LX / PLOT_NX;
|
constexpr double PLOT_DX = LX / PLOT_NX;
|
||||||
} // namespace Parameters
|
} // namespace Parameters
|
||||||
|
|||||||
+20
-5
@@ -33,11 +33,14 @@
|
|||||||
#include <deal.II/fe/fe_values.h>
|
#include <deal.II/fe/fe_values.h>
|
||||||
|
|
||||||
#include <deal.II/numerics/data_out.h>
|
#include <deal.II/numerics/data_out.h>
|
||||||
|
#include <deal.II/numerics/fe_field_function.h>
|
||||||
#include <deal.II/numerics/matrix_tools.h>
|
#include <deal.II/numerics/matrix_tools.h>
|
||||||
#include <deal.II/numerics/vector_tools.h>
|
#include <deal.II/numerics/vector_tools.h>
|
||||||
|
|
||||||
#include <deal.II/numerics/vector_tools_evaluate.h>
|
#include <deal.II/numerics/vector_tools_evaluate.h>
|
||||||
#include <deal.II/numerics/vector_tools_interpolate.h>
|
#include <deal.II/numerics/vector_tools_interpolate.h>
|
||||||
|
#include <deal.II/numerics/vector_tools_point_gradient.h>
|
||||||
|
#include <deal.II/numerics/vector_tools_point_value.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -170,14 +173,26 @@ PoissonProblem<dim>::sample_electric_potential(double x_min, double x_max,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <int dim>
|
template <int dim>
|
||||||
double eval_point(const Mapping<dim> &mapping,
|
double
|
||||||
const DoFHandler<dim> &dof_handler,
|
eval_point_grad(const Mapping<dim> &mapping, const DoFHandler<dim> &dof_handler,
|
||||||
const Vector<double> &solution, const Point<dim> &point) {
|
const Vector<double> &solution, const Point<dim> &point) {
|
||||||
return VectorTools::point_value<dim>(mapping, dof_handler, solution, point);
|
|
||||||
|
Tensor<1, dim> grad =
|
||||||
|
VectorTools::point_gradient<dim>(mapping, dof_handler, solution, point);
|
||||||
|
double Ex = grad[0];
|
||||||
|
|
||||||
|
return Ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dealii Poisson
|
template <int dim>
|
||||||
|
double eval_point_value(const Mapping<dim> &mapping,
|
||||||
|
const DoFHandler<dim> &dof_handler,
|
||||||
|
const Vector<double> &solution,
|
||||||
|
const Point<dim> &point) {
|
||||||
|
|
||||||
|
return VectorTools::point_value<dim>(mapping, dof_handler, solution, point);
|
||||||
|
}
|
||||||
|
// dealii Poisson
|
||||||
template <int dim> void PoissonProblem<dim>::create_mesh() {
|
template <int dim> void PoissonProblem<dim>::create_mesh() {
|
||||||
|
|
||||||
GridGenerator::hyper_cube(triangulation, Parameters::X_DOMAIN_LEFT,
|
GridGenerator::hyper_cube(triangulation, Parameters::X_DOMAIN_LEFT,
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <nufi/nufi_solver.h>
|
#include <nufi/nufi_solver.h>
|
||||||
|
#include <omp.h>
|
||||||
|
|
||||||
void clear_results_directory(const std::string &dir) {
|
void clear_results_directory(const std::string &dir) {
|
||||||
if (!std::filesystem::exists(dir) || !std::filesystem::is_directory(dir))
|
if (!std::filesystem::exists(dir) || !std::filesystem::is_directory(dir))
|
||||||
@@ -16,13 +16,13 @@ void clear_results_directory(const std::string &dir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
#include <omp.h>
|
|
||||||
std::cout << "Threads: " << omp_get_max_threads() << "\n";
|
std::cout << "Threads: " << omp_get_max_threads() << "\n";
|
||||||
try {
|
try {
|
||||||
clear_results_directory("results");
|
clear_results_directory("results");
|
||||||
|
|
||||||
NuFISolver solver;
|
NuFISolver solver;
|
||||||
solver.run();
|
solver.run();
|
||||||
|
|
||||||
} catch (const std::exception &exc) {
|
} catch (const std::exception &exc) {
|
||||||
std::cerr << "\nException:\n" << exc.what() << "\n";
|
std::cerr << "\nException:\n" << exc.what() << "\n";
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
+5
-3
@@ -80,7 +80,7 @@ double NuFISolver::eval_rho(unsigned int n, const double x,
|
|||||||
const unsigned int Nv) const {
|
const unsigned int Nv) const {
|
||||||
const double dv =
|
const double dv =
|
||||||
(Parameters::V_DOMAIN_RIGHT - Parameters::V_DOMAIN_LEFT) / Nv;
|
(Parameters::V_DOMAIN_RIGHT - Parameters::V_DOMAIN_LEFT) / Nv;
|
||||||
const double v_min = Parameters::V_DOMAIN_LEFT;
|
const double v_min = Parameters::V_DOMAIN_LEFT + 0.5 * dv;
|
||||||
|
|
||||||
double integral = 0.0;
|
double integral = 0.0;
|
||||||
|
|
||||||
@@ -146,14 +146,16 @@ void NuFISolver::run() {
|
|||||||
|
|
||||||
phi_history.push_back(poisson.get_solution());
|
phi_history.push_back(poisson.get_solution());
|
||||||
|
|
||||||
std::vector<double> sampled_potential =
|
// std::vector<double> sampled_potential =
|
||||||
poisson.sample_electric_potential(x_min, x_max, Nx); // Solution of FE
|
// poisson.sample_electric_potential(x_min, x_max, Nx); // Solution of
|
||||||
|
// FE
|
||||||
|
|
||||||
double timer_elapsed = timer.elapsed();
|
double timer_elapsed = timer.elapsed();
|
||||||
double step_time = timer_elapsed - time_elapsed_before;
|
double step_time = timer_elapsed - time_elapsed_before;
|
||||||
total_time += timer_elapsed;
|
total_time += timer_elapsed;
|
||||||
|
|
||||||
time_file << it << " " << step_time << " " << total_time << "\n";
|
time_file << it << " " << step_time << " " << total_time << "\n";
|
||||||
|
time_file.flush();
|
||||||
|
|
||||||
std::cout << "step made in " << step_time << " seconds\n\n";
|
std::cout << "step made in " << step_time << " seconds\n\n";
|
||||||
if (it % Parameters::PLOT_FREQUENCY == 0) {
|
if (it % Parameters::PLOT_FREQUENCY == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user