[deal.II] Re: ABOUT ASSEMBLING RIGHT HAND SIDE
For correction, the right code for the second method is for (; cell != endc; ++cell) { local_rhs = 0; fe_values.reinit(cell); fe_values.get_function_values(old_solution, old_sol_values); for (unsigned int q = 0; q < n_q_points; ++q ){ for (unsigned int i = 0; i < dofs_per_cell; ++i) { const double phi_i = fe_values.shape_value(i, q); local_rhs(i) += old_sol_values[q] * phi_i * fe_values.JxW(q); } } cell->get_dof_indices(local_dof_indices); for (unsigned int i = 0; i < dofs_per_cell; ++i) { system_rhs(local_dof_indices[i]) += local_rhs(i); } } On Saturday, April 4, 2020 at 11:18:12 PM UTC-7, Xiang Sun wrote: > > Hi, I am implementing the backward Euler method to solve a time-dependent > problem like u(n+1)= h*f(n+1)+u(n). n is the nth time step. h is the time > step length. f is a function of time. I tried two ways to assemble the > system right-hand side(rhs). > > One is to form a mass matrix first, then time the old value of u at the > node. This way is similar to Step-26. The code is like > mass_matrix.vmult(system_rhs, old_solution); > > The other way is to get the value of u at quadrature points by > interpolation, then do the integral in cells to get the local rhs, finally > assemble the system rhs by the local rhs. This method is from Step-31 and > shown in the following code. > > for (; cell != endc; ++cell) { > local_rhs = 0; > fe_values.reinit(cell); > fe_values.get_function_values(old_solution, old_sol_values); > for (unsigned int q = 0; q < n_q_points; ++q ){ > for (unsigned int i = 0; i < dofs_per_cell; ++i) { > const double phi_i = fe_values.shape_value(i, q); > local_rhs(i) += old_sol_values[q] * phi_i * fe_values.JxW(q); > } > > } > cell->get_dof_indices(local_dof_indices); > for (unsigned int i = 0; i < dofs_per_cell; ++i) { > system_rhs(local_dof_indices[i]) += local_rhs(i)*0; > } > } > > I thought these two methods should give the same answer, but they can't. I > don't know where I made a mistake. Thank you very much. > > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/25bcc8e2-effb-40c6-9410-a91a0a088c3f%40googlegroups.com.
[deal.II] ABOUT ASSEMBLING RIGHT HAND SIDE
Hi, I am implementing the backward Euler method to solve a time-dependent problem like u(n+1)= h*f(n+1)+u(n). n is the nth time step. h is the time step length. f is a function of time. I tried two ways to assemble the system right-hand side(rhs). One is to form a mass matrix first, then time the old value of u at the node. This way is similar to Step-26. The code is like mass_matrix.vmult(system_rhs, old_solution); The other way is to get the value of u at quadrature points by interpolation, then do the integral in cells to get the local rhs, finally assemble the system rhs by the local rhs. This method is from Step-31 and shown in the following code. for (; cell != endc; ++cell) { local_rhs = 0; fe_values.reinit(cell); fe_values.get_function_values(old_solution, old_sol_values); for (unsigned int q = 0; q < n_q_points; ++q ){ for (unsigned int i = 0; i < dofs_per_cell; ++i) { const double phi_i = fe_values.shape_value(i, q); local_rhs(i) += old_sol_values[q] * phi_i * fe_values.JxW(q); } } cell->get_dof_indices(local_dof_indices); for (unsigned int i = 0; i < dofs_per_cell; ++i) { system_rhs(local_dof_indices[i]) += local_rhs(i)*0; } } I thought these two methods should give the same answer, but they can't. I don't know where I made a mistake. Thank you very much. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/6887c68e-64c3-4e74-a53f-64775f467a3b%40googlegroups.com.
Re: [deal.II] ABOUT THE DEFINITION OF RESIDUAL IN STEP-31
Thank you very much. Best, Xiang On Wed, Oct 23, 2019 at 4:42 PM Wolfgang Bangerth wrote: > > > Thank you for your reply. I will try it. The equations are: > [...] > > Both step 31 and 32 will be good starting points. The only difference is > that you have Darcy flow instead of Stokes flow, but that should be easy > to incorporate into these programs. > > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/dealii/bc318048-3b31-b19f-a103-9962e0fa108a%40colostate.edu > . > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CAHVCzt6CSOFJwDZ7M2tt%3DRL1B6p-APe6dJHLZho8j%2B49HGyH2Q%40mail.gmail.com.
Re: [deal.II] ABOUT THE DEFINITION OF RESIDUAL IN STEP-31
Hi, Wolfgang, Thank you for your reply. I will try it. The equations are: [image: image.png] [image: image.png] where T is temperature, p is pressure, u is flow rate. K is hydraulic conductivity which is constant, κ and λ are the coefficients of heat transfer. T1 means the temperature at boundary 1. Tw and T0 are constant. The model is a column with a hole. Boundary 1 is the surface of the hole. Boundary 2 is the outer surface of the column. Best, Xiang On Wed, Oct 23, 2019 at 6:45 AM Wolfgang Bangerth wrote: > On 10/22/19 10:57 PM, Xiang Sun wrote: > > > > Thank you for your reply. I am learning dealii to build up a geothermal > model, > > which includes a Laplace equation and a heat transfer considering both > > convection and diffusion. The Laplace equation describes a pressure > > distibution in a site with several wellbores. The heat transfer equation > > describes the site temperature change with the change in the wellbore > > temperature. I think the model can be established by combining Step-4 > and > > Step-31. Do you think these two example code is good for our model? > Thank you > > very much. > > This sounds about right, but without knowing what the exact equations are, > it's hard to tell. > > That said, there are certainly several tutorial programs that already > implement pieces of what you want to do. You have probably noticed already > that step-32 is a more capable version of step-31. > > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/dealii/cccffed9-f913-8b5b-c0a8-d15fc66cca2e%40colostate.edu > . > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/CAHVCzt4vKYLNDX0hUnpJjNcmxnwAeYK_rgQ%2BqK_kxJ0nfKJgEg%40mail.gmail.com.
Re: [deal.II] ABOUT THE DEFINITION OF RESIDUAL IN STEP-31
Hi, Wolfgang, Thank you for your reply. I am learning dealii to build up a geothermal model, which includes a Laplace equation and a heat transfer considering both convection and diffusion. The Laplace equation describes a pressure distibution in a site with several wellbores. The heat transfer equation describes the site temperature change with the change in the wellbore temperature. I think the model can be established by combining Step-4 and Step-31. Do you think these two example code is good for our model? Thank you very much. Best, Xiang On Tuesday, October 22, 2019 at 9:02:48 PM UTC-7, Wolfgang Bangerth wrote: > > On 10/22/19 10:41 AM, Xiang Sun wrote: > > > > In step-31, why did you define the residual by multiplying T^(a-1)? What > does > > "a" mean? Thank you very much. > > I assume you mean here? > > https://dealii.org/developer/doxygen/deal.II/step_31.html#Stabilizationweakformandspacediscretizationforthetemperatureequation > > > To understand the form stated there, you have to go back to the paper by > Guermond and Popov. In essence, this goes back to some deep theory about > hyperbolic equations that says that a weak solution is a physical solution > only if it satisfies an entropy inequality. There are many ways to define > an > entropy pair (a pair of functions), and one of these is to choose E=T^a. > The > differential inequality E then has to satisfy is obtained by multiplying > the > equation for T by T^{a-1}. > > The theory is not particularly simple, and requires substantial background > of > hyperbolic equations. Going to the papers by Guermond and coauthors will > give > you the necessary insight. > > Best > W. > > -- > > Wolfgang Bangerth email: bang...@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. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/3281a95a-9d53-4456-adc8-3d92d512023f%40googlegroups.com.
[deal.II] ABOUT THE DEFINITION OF RESIDUAL IN STEP-31
Hi, In step-31, why did you define the residual by multiplying T^(a-1)? What does "a" mean? Thank you very much. Best, Xiang -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/1e79fa5e-eb21-487e-bc09-de3b209e9526%40googlegroups.com.