Re: [deal.II] Re: How to compute convergence rate of L2 norm of error without exact solution? And how to compute convergence rate of in different golobally refinement?
On 2/27/19 2:40 AM, chucui1...@gmail.com wrote: > > I have used SolutionTransfer as you say, but if I set a phi_0 fixed, then > project it into finite element space and get a vector phi_0_h, then I get > phi_0_h/2, phi_0_h/4, phi_0_h/8 by using SolutionTransfer, but the norm > of (phi_0_h- phi_0_h/2), (phi_0_h/2- phi_0_h/4), (phi_0_h/4- phi_0_h/8) are > so > big, and I cannot get exact value when I compute the convergence rate. So I > wander how to deal with it? > > And the attached is the test code, and the results is: > phi_0_norm_58: 0.335377 phi_0_norm_68: 0.317158 phi_0_norm_78: 0.277344 Chucui, have you solved this problem since? It's not quite clear to me what exactly you are doing here, i.e., which of the quantities you have above are *computed* on each mesh, and which ones are interpolated from the previous mesh. Best W. -- Wolfgang Bangerth email: bange...@colostate.edu www: http://www.math.colostate.edu/~bangerth/ -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[deal.II] Re: How to compute convergence rate of L2 norm of error without exact solution? And how to compute convergence rate of in different golobally refinement?
Dear Prof. Arndt, I have used SolutionTransfer as you say, but if I set a phi_0 fixed, then project it into finite element space and get a vector phi_0_h, then I get phi_0_h/2, phi_0_h/4, phi_0_h/8 by using SolutionTransfer, but the norm of (phi_0_h- phi_0_h/2), (phi_0_h/2- phi_0_h/4), (phi_0_h/4- phi_0_h/8) are so big, and I cannot get exact value when I compute the convergence rate. So I wander how to deal with it? And the attached is the test code, and the results is: phi_0_norm_58: 0.335377 phi_0_norm_68: 0.317158 phi_0_norm_78: 0.277344 Thank you very much! Best, Chucui -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // Then we need to include the header file for the sparse direct solver // UMFPACK: #include // This includes the library for the incomplete LU factorization that will be // used as a preconditioner in 3D: #include // This is C++: #include #include #include #include #include using namespace std; // As in all programs, the namespace dealii is included: namespace Step22 { using namespace dealii; template class StokesProblem { public: StokesProblem (const unsigned int phi_degree); void run (); private: void setup_dofs_pbc_rf (const int refine_number); void phi_0_trans (); double norm_compute_phi_0 (const Vector solu_1, const Vector solu_2); void create_mesh(); void refine_mesh (); const unsigned int degree; Triangulation triangulation_active; Triangulation triangulation; FE_Qfe_phi; DoFHandler dof_handler_phi; ConstraintMatrix constraints_phi; Vector phi_0, phi_0_5, phi_0_6, phi_0_7, phi_0_8, tmp_phi_0_5, tmp_phi_0_6, tmp_phi_0_7, tmp_phi_0_8; double time_step, time; const double A, B, sita_0, eps, m, eps_4, tau, k_0, C_L, D_u, L_1, L_2, L_0, T_M, C_0, C_1, eps_F, e_L_T_M;//, s; unsigned int timestep_number = 1; }; template StokesProblem::StokesProblem (const unsigned int phi_degree) : degree (phi_degree), fe_phi (degree), dof_handler_phi (triangulation), time_step (1e-4), timestep_number (1), A (100.0), B (1.0), sita_0 (1*numbers::PI/4), eps (0.01), m (4.0), eps_4 (1./15.0), tau (3.0), k_0 (0.0), C_L (0.6), D_u (0.0001), L_1 (0.0), L_2 (0.0), L_0 (0.5), T_M (1.0), C_0 (1.0), C_1 (1.0), eps_F (1.0), e_L_T_M (0.0) {} template class InitialValues_phi : public Function { public: InitialValues_phi () : Function() {} virtual double value (const Point , const unsigned int component = 0) const; }; template double InitialValues_phi::value (const Point , const unsigned int component) const { const double C_0 = 1.0, C_1 = 1.0, A = 100.0; const double delta = 0.1, r0 = std::sqrt(0.018); double phi_value = 0, e_value = 0, q_value = 0, s_value = 0, r = 0, T_value = 0; r = std::sqrt((p[0] - 0.28125) * (p[0] - 0.28125) + (p[1] - 0.28125) * (p[1] - 0.28125)) ; phi_value = -0.5 * std::tanh((r0-r)/delta) + 0.5; //phi_value = 0.5 * std::cos(p[0]) * std::cos(p[1]) +0.5; return phi_value; } template class InitialValuesConv : public Function { public: InitialValuesConv () : Function() {} virtual double value (const Point , const unsigned int component = 0) const; }; template double InitialValuesConv::value (const Point , const unsigned int component) const {
[deal.II] Re: How to compute convergence rate of L2 norm of error without exact solution? And how to compute convergence rate of in different golobally refinement?
Dear Prof. Arndt, I have used SolutionTransfer as you say, but if I set a phi_0 fixed, then project it into finite element space and get a vector phi_0_h, then I get phi_0_h/2, phi_0_h/4, phi_0_h/8 by using SolutionTransfer, but the norm of (phi_0_h- phi_0_h/2), (phi_0_h/2- phi_0_h/4), (phi_0_h/4- phi_0_h/8) are so big, and I cannot get exact value when I compute the convergence rate. So I wander how to deal with it? And the attached is the test code, and the results is: phi_0_norm_58: 0.335377 phi_0_norm_68: 0.317158 phi_0_norm_78: 0.277344 Thank you very much! Best, Chucui -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[deal.II] Re: How to compute convergence rate of L2 norm of error without exact solution? And how to compute convergence rate of in different golobally refinement?
Dear Prof.Arndt, Thank you very much! I understand what you say. It helps me a lot! Best, Chucui 在 2019年2月21日星期四 UTC+8下午7:31:20,Daniel Arndt写道: > > Chucui, > > > For Question 1, I write a code to compute the L2 norm of (solution_1 - >> solution_2): >> [...] >> >> Is that right? >> > You can just take the difference of the two variables and use > VectorTools::integrate_difference with a Functions::ZeroFunction as "exact > solution". > > > >> >> For question 2, as the 2 solution vectors have different sizes, we don't >> have the same cells, so the cell loop cannot compute altogether: >> typename DoFHandler::active_cell_iterator >> cell_1 = dof_handler_1.begin_active(), >> endc_1 = dof_handler_1.end(); >> typename DoFHandler::active_cell_iterator >> cell_2 = dof_handler_2.begin_active(); >> for (; cell_1!=endc_2; ++cell_1, ++cell_2) >> {} >> >> I wander how to solve this problem? >> > You need to interpolate the solution computed on the coarser mesh to the > finer mesh using SolutionTransfer( > https://www.dealii.org/current/doxygen/deal.II/classSolutionTransfer.html, > explained e.g. in > https://www.dealii.org/current/doxygen/deal.II/step_26.html). Then, you > can take the difference just as in your first question. > > Best, > Daniel > -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[deal.II] Re: How to compute convergence rate of L2 norm of error without exact solution? And how to compute convergence rate of in different golobally refinement?
Chucui, For Question 1, I write a code to compute the L2 norm of (solution_1 - > solution_2): > [...] > > Is that right? > You can just take the difference of the two variables and use VectorTools::integrate_difference with a Functions::ZeroFunction as "exact solution". > > For question 2, as the 2 solution vectors have different sizes, we don't > have the same cells, so the cell loop cannot compute altogether: > typename DoFHandler::active_cell_iterator > cell_1 = dof_handler_1.begin_active(), > endc_1 = dof_handler_1.end(); > typename DoFHandler::active_cell_iterator > cell_2 = dof_handler_2.begin_active(); > for (; cell_1!=endc_2; ++cell_1, ++cell_2) > {} > > I wander how to solve this problem? > You need to interpolate the solution computed on the coarser mesh to the finer mesh using SolutionTransfer(https://www.dealii.org/current/doxygen/deal.II/classSolutionTransfer.html, explained e.g. in https://www.dealii.org/current/doxygen/deal.II/step_26.html). Then, you can take the difference just as in your first question. Best, Daniel -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[deal.II] Re: How to compute convergence rate of L2 norm of error without exact solution? And how to compute convergence rate of in different golobally refinement?
Hi, all, If there is no function to compute convergence above, I need to write the code by myself. For Question 1, I write a code to compute the L2 norm of (solution_1 - solution_2): template double StokesProblem::norm_compute (const Vector solu_1, const Vector solu_2) { QGauss quadrature_formula(degree+2); FEValues fe_values (fe, quadrature_formula, update_values| update_quadrature_points | update_JxW_values | update_gradients); const unsigned int dofs_per_cell = fe.dofs_per_cell; const unsigned int n_q_points = quadrature_formula.size(); FullMatrix local_con_rate_matrix (dofs_per_cell, dofs_per_cell); std::vector local_dof_indices (dofs_per_cell); std::vector solu_1_values(n_q_points); std::vector solu_2_values(n_q_points); double norm_12 = 0, norm_24 = 1,norm_12_square = 0, norm_24_square = 1, rate_124 = 0, con_rate = 0; typename DoFHandler::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); for (; cell!=endc; ++cell) { fe_values.reinit (celli); fe_values.get_function_values (solu_1, solu_1_values); fe_values.get_function_values (solu_2, solu_2_values); for (unsigned int q=0; q::active_cell_iterator cell_1 = dof_handler_1.begin_active(), endc_1 = dof_handler_1.end(); typename DoFHandler::active_cell_iterator cell_2 = dof_handler_2.begin_active(); for (; cell_1!=endc_2; ++cell_1, ++cell_2) {} I wander how to solve this problem? Thanks in advance! Best, Chucui -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.