From f8e86e9919efda8d1a4000fe93d4574c4265261d Mon Sep 17 00:00:00 2001 From: Patrik Rac <patrik_rac@gmx.de> Date: Tue, 8 Feb 2022 12:07:23 +0100 Subject: [PATCH] Evaluation point adjustment --- deal_main/source/evaluation.hpp | 5 +++++ deal_main/source/poisson_h.hpp | 13 ++++++------- deal_main/source/poisson_hp.hpp | 13 ++++++------- mfem_main/source/evaluation.hpp | 6 +++--- mfem_main/source/poisson.cpp | 13 ++++++++++--- mfem_main/source/poisson.hpp | 1 - ngsolve_main/ngsolve_main.py | 1 + 7 files changed, 31 insertions(+), 21 deletions(-) diff --git a/deal_main/source/evaluation.hpp b/deal_main/source/evaluation.hpp index bd98b19..43374c3 100644 --- a/deal_main/source/evaluation.hpp +++ b/deal_main/source/evaluation.hpp @@ -6,6 +6,11 @@ using namespace dealii; +//Initialisation of the evaluation points +const Point<3> p1(0.5, 0.125, 0.875); +const Point<3> p2(0.5, 0.25, 0.875); +const Point<3> p3(0.5, 0.5, 0.875); + //---------------------------------------------------------------- //Class used to evaluate the approx. solution at a given point (If node exists). //---------------------------------------------------------------- diff --git a/deal_main/source/poisson_h.hpp b/deal_main/source/poisson_h.hpp index 57e5d9d..1f069c4 100644 --- a/deal_main/source/poisson_h.hpp +++ b/deal_main/source/poisson_h.hpp @@ -110,7 +110,6 @@ namespace AspDEQuFEL //------------------------------ //Initialize the problem with first order finite elements //The dof_handler manages enumeration and indexing of all degrees of freedom (relating to the given triangulation) - //When changing the point of the postprocessor one has to also change it in the calculate_exact_error method //------------------------------ template <int dim> Poisson<dim>::Poisson(int order, int max_dof) : max_dofs(max_dof), @@ -121,9 +120,9 @@ namespace AspDEQuFEL pcout(std::cout, (this_mpi_process == 0)), fe(order), dof_handler(triangulation), - postprocessor1(Point<3>(0.5, 0.125, 0.875)), - postprocessor2(Point<3>(0.5, 0.25, 0.875)), - postprocessor3(Point<3>(0.5, 0.5, 0.875)) + postprocessor1(p1), + postprocessor2(p2), + postprocessor3(p3) { } @@ -554,9 +553,9 @@ namespace AspDEQuFEL const unsigned int n_active_cells = triangulation.n_global_active_cells(); const unsigned int n_dofs = dof_handler.n_dofs(); - double local_error_p1 = abs(postprocessor1(dof_handler, local_solution) - Solution<dim>().value(Point<dim>(0.5, 0.125, 0.875))); - double local_error_p2 = abs(postprocessor2(dof_handler, local_solution) - Solution<dim>().value(Point<dim>(0.5, 0.25, 0.875))); - double local_error_p3 = abs(postprocessor3(dof_handler, local_solution) - Solution<dim>().value(Point<dim>(0.5, 0.5, 0.875))); + double local_error_p1 = abs(postprocessor1(dof_handler, local_solution) - Solution<dim>().value(p1)); + double local_error_p2 = abs(postprocessor2(dof_handler, local_solution) - Solution<dim>().value(p2)); + double local_error_p3 = abs(postprocessor3(dof_handler, local_solution) - Solution<dim>().value(p3)); double error_p1 = Utilities::MPI::min(local_error_p1, mpi_communicator); double error_p2 = Utilities::MPI::min(local_error_p2, mpi_communicator); double error_p3 = Utilities::MPI::min(local_error_p3, mpi_communicator); diff --git a/deal_main/source/poisson_hp.hpp b/deal_main/source/poisson_hp.hpp index 8ac469f..bd45219 100644 --- a/deal_main/source/poisson_hp.hpp +++ b/deal_main/source/poisson_hp.hpp @@ -125,7 +125,6 @@ namespace AspDEQuFEL //------------------------------ //The dof_handler manages enumeration and indexing of all degrees of freedom (relating to the given triangulation). //Set an adequate maximum degree. - //When changing the point of the postprocessor one has to also change it in the calculate_exact_error method //------------------------------ template <int dim> PoissonHP<dim>::PoissonHP(int max_dof) : max_dofs(max_dof), @@ -136,9 +135,9 @@ namespace AspDEQuFEL pcout(std::cout, (this_mpi_process == 0)), dof_handler(triangulation), max_degree(dim <= 2 ? 7 : 5), - postprocessor1(Point<3>(0.5, 0.125, 0.875)), - postprocessor2(Point<3>(0.5, 0.25, 0.875)), - postprocessor3(Point<3>(0.5, 0.5, 0.875)) + postprocessor1(p1), + postprocessor2(p2), + postprocessor3(p3) { for (unsigned int degree = 2; degree <= max_degree; degree++) { @@ -610,9 +609,9 @@ namespace AspDEQuFEL const unsigned int n_active_cells = triangulation.n_global_active_cells(); const unsigned int n_dofs = dof_handler.n_dofs(); - double local_error_p1 = abs(postprocessor1(dof_handler, local_solution) - Solution<dim>().value(Point<dim>(0.5, 0.125, 0.875))); - double local_error_p2 = abs(postprocessor2(dof_handler, local_solution) - Solution<dim>().value(Point<dim>(0.5, 0.25, 0.875))); - double local_error_p3 = abs(postprocessor3(dof_handler, local_solution) - Solution<dim>().value(Point<dim>(0.5, 0.5, 0.875))); + double local_error_p1 = abs(postprocessor1(dof_handler, local_solution) - Solution<dim>().value(p1)); + double local_error_p2 = abs(postprocessor2(dof_handler, local_solution) - Solution<dim>().value(p2)); + double local_error_p3 = abs(postprocessor3(dof_handler, local_solution) - Solution<dim>().value(p3)); double error_p1 = Utilities::MPI::min(local_error_p1, mpi_communicator); double error_p2 = Utilities::MPI::min(local_error_p2, mpi_communicator); double error_p3 = Utilities::MPI::min(local_error_p3, mpi_communicator); diff --git a/mfem_main/source/evaluation.hpp b/mfem_main/source/evaluation.hpp index 86d0bb2..20b6efd 100644 --- a/mfem_main/source/evaluation.hpp +++ b/mfem_main/source/evaluation.hpp @@ -7,9 +7,9 @@ using namespace mfem; using namespace std; //Evaluation points for the point-wise error -double p1[] = {0.5, 0.125, 0.875}; -double p2[] = {0.5, 0.25, 0.875}; -double p3[] = {0.5, 0.5, 0.875}; +const vector<double> p1 = {0.5, 0.125, 0.875}; +const vector<double> p2 = {0.5, 0.25, 0.875}; +const vector<double> p3 = {0.5, 0.5, 0.875}; //-------------------------------------------------------------- //Class for evaluating the approximate solution at a given point. Only applicable if the point is a node of the grid. diff --git a/mfem_main/source/poisson.cpp b/mfem_main/source/poisson.cpp index 4ef82ec..1d33241 100644 --- a/mfem_main/source/poisson.cpp +++ b/mfem_main/source/poisson.cpp @@ -298,13 +298,20 @@ namespace AspDEQuFEL values.max_error = x.ComputeMaxError(u); values.l2_error = x.ComputeL2Error(u); - double local_error_p1 = abs(postprocessor1(x, *pmesh) - bdr_func(Vector(p1, 3))); + double p1_data[p1.size()]; + double p2_data[p2.size()]; + double p3_data[p3.size()]; + copy(p1.begin(), p1.end(), p1_data); + copy(p2.begin(), p2.end(), p2_data); + copy(p3.begin(), p3.end(), p3_data); + + double local_error_p1 = abs(postprocessor1(x, *pmesh) - bdr_func(Vector(p1_data, p1.size()))); MPI_Reduce(&local_error_p1, &values.error_p1, 1, MPI_DOUBLE, MPI_MIN, 0, MPI_COMM_WORLD); - double local_error_p2 = abs(postprocessor2(x, *pmesh) - bdr_func(Vector(p2, 3))); + double local_error_p2 = abs(postprocessor2(x, *pmesh) - bdr_func(Vector(p2_data, p2.size()))); MPI_Reduce(&local_error_p2, &values.error_p2, 1, MPI_DOUBLE, MPI_MIN, 0, MPI_COMM_WORLD); - double local_error_p3 = abs(postprocessor3(x, *pmesh) - bdr_func(Vector(p3, 3))); + double local_error_p3 = abs(postprocessor3(x, *pmesh) - bdr_func(Vector(p3_data, p3.size()))); MPI_Reduce(&local_error_p3, &values.error_p3, 1, MPI_DOUBLE, MPI_MIN, 0, MPI_COMM_WORLD); table_vector.push_back(values); diff --git a/mfem_main/source/poisson.hpp b/mfem_main/source/poisson.hpp index 78d51d2..41bed03 100644 --- a/mfem_main/source/poisson.hpp +++ b/mfem_main/source/poisson.hpp @@ -20,7 +20,6 @@ namespace AspDEQuFEL using namespace std; //---------------------------------------------------------------- //Class for the Poisson AMR solver - //When changing the point of the postprocessor one has to also change it in the calculate_exact_error method //---------------------------------------------------------------- class Poisson { diff --git a/ngsolve_main/ngsolve_main.py b/ngsolve_main/ngsolve_main.py index 44e1586..f707ed8 100644 --- a/ngsolve_main/ngsolve_main.py +++ b/ngsolve_main/ngsolve_main.py @@ -53,6 +53,7 @@ class Poisson: #User concfiguration (Problem definition) #============================================= #Define the general parameters and functions for the Problem + #The evaluation points have to be adjusted in the exact error method #Define the parameter alpha which is dependant on the used geometry self.alpha = 1.0/2.0 self.r = sqrt((x-0.5)*(x-0.5) + y*y) -- GitLab