mirror of
https://codeberg.org/vcbferreira/NuFI_deal.ii
synced 2026-08-12 14:33:18 +02:00
corrected boundary conditions error, periodicity still not working as intended
This commit is contained in:
Binary file not shown.
+9
-7
@@ -15,10 +15,13 @@ namespace Parameters
|
|||||||
constexpr double V_DOMAIN_LEFT = -10.0;
|
constexpr double V_DOMAIN_LEFT = -10.0;
|
||||||
constexpr double V_DOMAIN_RIGHT = 10.0;
|
constexpr double V_DOMAIN_RIGHT = 10.0;
|
||||||
|
|
||||||
constexpr unsigned int NV = 1024;
|
constexpr unsigned int NV = 562;
|
||||||
|
|
||||||
constexpr unsigned int GLOBAL_REFINEMENT = 8;
|
// deal.ii options
|
||||||
constexpr unsigned int FE_DEGREE = 3;
|
constexpr unsigned int GLOBAL_REFINEMENT = 7;
|
||||||
|
constexpr unsigned int FE_DEGREE = 4;
|
||||||
|
constexpr unsigned int CONVERGENCE_ITERATIONS = 20000;
|
||||||
|
constexpr double CONVERGENCE_LIMIT = 1e-12;
|
||||||
|
|
||||||
constexpr double EPS = 0.01;
|
constexpr double EPS = 0.01;
|
||||||
constexpr double WAVE_NR = 0.5;
|
constexpr double WAVE_NR = 0.5;
|
||||||
@@ -26,16 +29,15 @@ namespace Parameters
|
|||||||
|
|
||||||
// NUFI options
|
// NUFI options
|
||||||
constexpr double DT=1./16.;
|
constexpr double DT=1./16.;
|
||||||
constexpr unsigned int TMAX = 10;
|
constexpr unsigned int TMAX = 20;
|
||||||
|
|
||||||
|
|
||||||
//spline options
|
//spline options
|
||||||
constexpr int SPLINE_NX = 1024;
|
constexpr int SPLINE_NX = 562;
|
||||||
constexpr double SPLINE_DX = LX/SPLINE_NX;
|
constexpr double SPLINE_DX = LX/SPLINE_NX;
|
||||||
constexpr size_t SPLINE_ORDER = 4;
|
constexpr size_t SPLINE_ORDER = 4;
|
||||||
|
|
||||||
//Plotting options
|
//Plotting options
|
||||||
constexpr int PLOT_FREQUENCY = 2;
|
constexpr int PLOT_FREQUENCY = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+32
-42
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <deal.II/base/quadrature_lib.h>
|
#include <deal.II/base/quadrature_lib.h>
|
||||||
#include <deal.II/base/logstream.h>
|
#include <deal.II/base/logstream.h>
|
||||||
|
#include <deal.II/base/template_constraints.h>
|
||||||
#include <deal.II/base/tensor.h>
|
#include <deal.II/base/tensor.h>
|
||||||
#include <deal.II/base/utilities.h>
|
#include <deal.II/base/utilities.h>
|
||||||
#include <deal.II/base/index_set.h>
|
#include <deal.II/base/index_set.h>
|
||||||
@@ -33,6 +34,7 @@
|
|||||||
#include <deal.II/numerics/matrix_tools.h>
|
#include <deal.II/numerics/matrix_tools.h>
|
||||||
#include <deal.II/numerics/fe_field_function.h>
|
#include <deal.II/numerics/fe_field_function.h>
|
||||||
|
|
||||||
|
#include <deal.II/numerics/vector_tools_interpolate.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -107,9 +109,6 @@ std::vector<double> PoissonProblem<dim>::sample_electric_field(
|
|||||||
double x_min,
|
double x_min,
|
||||||
double x_max)
|
double x_max)
|
||||||
{
|
{
|
||||||
// const auto &dof_handler = problem.get_dof_handler();
|
|
||||||
// const auto &solution = problem.get_solution();
|
|
||||||
|
|
||||||
this -> get_solution();
|
this -> get_solution();
|
||||||
this -> get_dof_handler();
|
this -> get_dof_handler();
|
||||||
|
|
||||||
@@ -146,23 +145,16 @@ void PoissonProblem<dim>::create_mesh()
|
|||||||
Parameters::X_DOMAIN_LEFT,
|
Parameters::X_DOMAIN_LEFT,
|
||||||
Parameters::X_DOMAIN_RIGHT);
|
Parameters::X_DOMAIN_RIGHT);
|
||||||
|
|
||||||
// TO CHECK:
|
|
||||||
//
|
std::vector<GridTools::PeriodicFacePair<
|
||||||
// Make x-dim boundaries periodic
|
typename Triangulation<dim>::cell_iterator>> periodic_faces;
|
||||||
// Tensor<1, dim> offset;
|
|
||||||
// std::vector<GridTools::PeriodicFacePair<
|
GridTools::collect_periodic_faces(triangulation,
|
||||||
// typename Triangulation<dim>::cell_iterator>> periodicity_vector;
|
0, 1, // boundary IDs
|
||||||
//
|
0,
|
||||||
// GridTools::collect_periodic_faces(triangulation,
|
periodic_faces);
|
||||||
// 0,
|
|
||||||
// 1,
|
triangulation.add_periodicity(periodic_faces);
|
||||||
// 0,
|
|
||||||
// periodicity_vector,
|
|
||||||
// offset);
|
|
||||||
//
|
|
||||||
// triangulation.add_periodicity(periodicity_vector);
|
|
||||||
//
|
|
||||||
// END CHECK
|
|
||||||
|
|
||||||
triangulation.refine_global(Parameters::GLOBAL_REFINEMENT);
|
triangulation.refine_global(Parameters::GLOBAL_REFINEMENT);
|
||||||
}
|
}
|
||||||
@@ -173,18 +165,16 @@ void PoissonProblem<dim>::setup_system()
|
|||||||
|
|
||||||
dof_handler.distribute_dofs(fe);
|
dof_handler.distribute_dofs(fe);
|
||||||
|
|
||||||
// TO CHECK:
|
constraints.clear();
|
||||||
//
|
|
||||||
// constraints.clear();
|
DoFTools::make_hanging_node_constraints(dof_handler, constraints);
|
||||||
// DoFTools::make_hanging_node_constraints(dof_handler, constraints);
|
|
||||||
//
|
DoFTools::make_periodicity_constraints(dof_handler,
|
||||||
// // 'boundary' condition phi(x_0) = 0
|
0, 1,
|
||||||
// constraints.add_line(0);
|
0,
|
||||||
// constraints.set_inhomogeneity(0, 0.0);
|
constraints);
|
||||||
//
|
|
||||||
// constraints.close();
|
constraints.close();
|
||||||
//
|
|
||||||
// END CHECK
|
|
||||||
|
|
||||||
DynamicSparsityPattern dsp(dof_handler.n_dofs());
|
DynamicSparsityPattern dsp(dof_handler.n_dofs());
|
||||||
DoFTools::make_sparsity_pattern(dof_handler, dsp, constraints);
|
DoFTools::make_sparsity_pattern(dof_handler, dsp, constraints);
|
||||||
@@ -241,11 +231,11 @@ void PoissonProblem<dim>::assemble_system()
|
|||||||
}
|
}
|
||||||
|
|
||||||
cell->get_dof_indices(local_dof_indices);
|
cell->get_dof_indices(local_dof_indices);
|
||||||
// constraints.distribute_local_to_global(cell_matrix,
|
constraints.distribute_local_to_global(cell_matrix,
|
||||||
// cell_rhs,
|
cell_rhs,
|
||||||
// local_dof_indices,
|
local_dof_indices,
|
||||||
// system_matrix,
|
system_matrix,
|
||||||
// system_rhs);
|
system_rhs);
|
||||||
for (const unsigned int i : fe_values.dof_indices())
|
for (const unsigned int i : fe_values.dof_indices())
|
||||||
for (const unsigned int j : fe_values.dof_indices())
|
for (const unsigned int j : fe_values.dof_indices())
|
||||||
system_matrix.add(local_dof_indices[i],
|
system_matrix.add(local_dof_indices[i],
|
||||||
@@ -257,10 +247,10 @@ void PoissonProblem<dim>::assemble_system()
|
|||||||
|
|
||||||
}
|
}
|
||||||
std::map<types::global_dof_index, double> boundary_values;
|
std::map<types::global_dof_index, double> boundary_values;
|
||||||
VectorTools::interpolate_boundary_values(dof_handler,
|
// VectorTools::interpolate_boundary_values(dof_handler,
|
||||||
types::boundary_id(0),
|
// types::boundary_id(0),
|
||||||
Functions::ZeroFunction<1>(),
|
// Functions::ZeroFunction<1>(),
|
||||||
boundary_values);
|
// boundary_values);
|
||||||
MatrixTools::apply_boundary_values(boundary_values,
|
MatrixTools::apply_boundary_values(boundary_values,
|
||||||
system_matrix,
|
system_matrix,
|
||||||
solution,
|
solution,
|
||||||
@@ -272,7 +262,7 @@ template <int dim>
|
|||||||
void PoissonProblem<dim>::solve()
|
void PoissonProblem<dim>::solve()
|
||||||
{
|
{
|
||||||
|
|
||||||
SolverControl solver_control(5000, 1e-12);
|
SolverControl solver_control(Parameters::CONVERGENCE_ITERATIONS, Parameters::CONVERGENCE_LIMIT);
|
||||||
SolverCG<Vector<double>> solver(solver_control);
|
SolverCG<Vector<double>> solver(solver_control);
|
||||||
|
|
||||||
// PreconditionSSOR<SparseMatrix<double>> preconditioner;
|
// PreconditionSSOR<SparseMatrix<double>> preconditioner;
|
||||||
|
|||||||
Reference in New Issue
Block a user