mirror of
https://codeberg.org/vcbferreira/NuFI_deal.ii
synced 2026-08-12 14:33:18 +02:00
adaptive refining online! it seems to use a single cpu at a time instead of all, need to check this
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
digraph G {
|
||||
graph [layout=dot rankdir=LR]
|
||||
|
||||
// This is just an example for you to use as a template.
|
||||
// Edit as you like. Whenever you save a legal graph
|
||||
// the layout in the graphviz window will be updated.
|
||||
|
||||
vim [href="http://www.vim.org/"]
|
||||
dot [href="http://www.graphviz.org/"]
|
||||
vimdot [href="file:///usr/bin/vimdot"]
|
||||
|
||||
{vim dot} -> vimdot
|
||||
}
|
||||
+13
-5
@@ -19,14 +19,18 @@ template <int dim> struct CellInfo {
|
||||
double h;
|
||||
};
|
||||
|
||||
template <int dim> struct CellLocation {
|
||||
const CellInfo<dim> *info;
|
||||
Point<dim> reference_point;
|
||||
};
|
||||
|
||||
template <int dim> class CellLocator {
|
||||
public:
|
||||
using CellIterator = typename DoFHandler<dim>::active_cell_iterator;
|
||||
|
||||
void rebuild(const DoFHandler<dim> &dof_handler,
|
||||
const Triangulation<dim> &triangulation);
|
||||
|
||||
CellIterator locate(const Point<dim> &p) const;
|
||||
CellLocation<dim> locate(const Point<dim> &p) const;
|
||||
|
||||
private:
|
||||
std::vector<CellInfo<dim>> cells;
|
||||
@@ -58,8 +62,7 @@ void CellLocator<dim>::rebuild(const DoFHandler<dim> &dof_handler,
|
||||
}
|
||||
|
||||
template <int dim>
|
||||
typename DoFHandler<dim>::active_cell_iterator
|
||||
CellLocator<dim>::locate(const Point<dim> &p) const {
|
||||
CellLocation<dim> CellLocator<dim>::locate(const Point<dim> &p) const {
|
||||
static_assert(dim == 1,
|
||||
"Current CellLocator implementation only supports 1D.");
|
||||
|
||||
@@ -82,7 +85,12 @@ CellLocator<dim>::locate(const Point<dim> &p) const {
|
||||
AssertThrow(x >= it->lower[0] - 1e-12 && x <= it->upper[0] + 1e-12,
|
||||
ExcMessage("CellLocator failed to find containing cell."));
|
||||
|
||||
return it->cell;
|
||||
CellLocation<dim> location;
|
||||
|
||||
location.info = &(*it);
|
||||
location.reference_point[0] = (p[0] - it->lower[0]) / it->h;
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
#endif // !CELLS_H
|
||||
|
||||
+4
-4
@@ -24,8 +24,8 @@ constexpr double DV = std::abs(V_DOMAIN_RIGHT - V_DOMAIN_LEFT) / NV;
|
||||
|
||||
// deal.ii options
|
||||
constexpr unsigned int GLOBAL_REFINEMENT = 6;
|
||||
constexpr unsigned int FE_DEGREE = 2;
|
||||
constexpr unsigned int CONVERGENCE_ITERATIONS = 15000;
|
||||
constexpr unsigned int FE_DEGREE = 3;
|
||||
constexpr unsigned int CONVERGENCE_ITERATIONS = 5000;
|
||||
constexpr double CONVERGENCE_LIMIT = 1e-8;
|
||||
|
||||
constexpr double EPS = 0.01;
|
||||
@@ -35,10 +35,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 = 5;
|
||||
constexpr unsigned int REFINE_FREQUENCY = 10;
|
||||
|
||||
// Plotting options
|
||||
constexpr int PLOT_FREQUENCY = 5;
|
||||
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/";
|
||||
|
||||
@@ -132,7 +132,7 @@ void PoissonProblem<dim>::set_rhs_function(
|
||||
template <int dim>
|
||||
PoissonProblem<dim>::PoissonProblem(unsigned int degree)
|
||||
: triangulation(Triangulation<dim>::limit_level_difference_at_vertices),
|
||||
fe(degree), dof_handler(triangulation), mapping(degree) {}
|
||||
dof_handler(triangulation), fe(degree), mapping(degree) {}
|
||||
|
||||
template <int dim>
|
||||
std::vector<double>
|
||||
@@ -208,12 +208,14 @@ std::vector<double> PoissonProblem<dim>::eval_vector_grad(
|
||||
|
||||
for (unsigned int p = 0; p < points.size(); ++p) {
|
||||
|
||||
const auto cell = cell_locator.locate(points[p]);
|
||||
const auto cell_location = cell_locator.locate(points[p]);
|
||||
|
||||
cell->get_dof_values(solution, local_solution_buffer.begin(),
|
||||
local_solution_buffer.end());
|
||||
cell_location.info->cell->get_dof_values(
|
||||
solution, local_solution_buffer.begin(), local_solution_buffer.end());
|
||||
|
||||
evaluator->reinit(cell, ArrayView<const Point<dim>>(&points[p], 1));
|
||||
evaluator->reinit(
|
||||
cell_location.info->cell,
|
||||
ArrayView<const Point<dim>>(&cell_location.reference_point, 1));
|
||||
evaluator->evaluate(local_solution_buffer, EvaluationFlags::gradients);
|
||||
|
||||
values[p] = evaluator->get_gradient(0)[0];
|
||||
|
||||
+12
-12
@@ -206,17 +206,17 @@ void NuFISolver::run() {
|
||||
<< std::endl;
|
||||
|
||||
// START: diagnostics
|
||||
std::cout << "cells = " << poisson.triangulation.n_active_cells()
|
||||
<< " dofs = " << poisson.dof_handler.n_dofs() << std::endl;
|
||||
double min_h = 1e100;
|
||||
double max_h = 0;
|
||||
|
||||
for (auto cell : poisson.triangulation.active_cell_iterators()) {
|
||||
min_h = std::min(min_h, cell->diameter());
|
||||
max_h = std::max(max_h, cell->diameter());
|
||||
}
|
||||
|
||||
std::cout << "h ratio = " << max_h / min_h << std::endl;
|
||||
std::cout << "cells = " << poisson.triangulation.n_active_cells() << "\n"
|
||||
<< " dofs = " << poisson.dof_handler.n_dofs() << "\n";
|
||||
// double min_h = 1e100;
|
||||
// double max_h = 0;
|
||||
//
|
||||
// for (auto cell : poisson.triangulation.active_cell_iterators()) {
|
||||
// min_h = std::min(min_h, cell->diameter());
|
||||
// max_h = std::max(max_h, cell->diameter());
|
||||
// }
|
||||
//
|
||||
// std::cout << "h ratio = " << max_h / min_h << std::endl;
|
||||
|
||||
// END: diagnostics
|
||||
|
||||
@@ -248,7 +248,7 @@ void NuFISolver::run() {
|
||||
poisson.coarse_and_refine_grid(it, phi_history);
|
||||
refine_time = timer.elapsed() - refine_start;
|
||||
std::cout << "Refinement step done in "
|
||||
<< std::to_string(std::floor(refine_time)) << "[s]";
|
||||
<< std::to_string(std::floor(refine_time)) << "[s]" << "\n";
|
||||
}
|
||||
|
||||
double timer_elapsed = timer.elapsed();
|
||||
|
||||
Reference in New Issue
Block a user