treatment of handing nodes in the heat conduction problem

54 views
Skip to first unread message

Anton Ermakov

unread,
Mar 16, 2021, 5:12:16 AM3/16/21
to deal.II User Group
Dear All,

I am having a problem with modifying the Step-26 for the case when the original mesh is refined in a specific region.  I believe the problem lies in the way I create mass and Laplace matrices. The original Step-26 code creates mass and Laplace matrices using create_mass_matrix and create_laplace_matrix. However, these functions don't provide the flexibility I need, so I assemble those matrices manually. This causes the solution to misbehave at the boundary of the refined region, see attached screen-shot. So, I presume the hanging node constraints are not introduced correctly. 

I attach the minimally changed Step-26 code to illustrate the problem. It is different from the original step-26 in three important  places:

1) in the run function, the mesh is refined in a corner
2) in the setup_system the mass and Laplace matrices are manually created. 
3) Initial temperature field is set to 100 K and the boundary condition is temperature fixed at 50 K. No source term.

Thank you for any help.
Anton.


step-26_modified.cc
Screen Shot 2021-03-15 at 22.09.29.png

Wolfgang Bangerth

unread,
Mar 16, 2021, 10:22:54 AM3/16/21
to dea...@googlegroups.com
On 3/16/21 6:12 AM, Anton Ermakov wrote:
>
> I attach the minimally changed Step-26 code to illustrate the problem. It is
> different from the original step-26 in three important  places:
>
> 1) in the run function, the mesh is refined in a corner
> 2) in the setup_system the mass and Laplace matrices are manually created.
> 3) Initial temperature field is set to 100 K and the boundary condition is
> temperature fixed at 50 K. No source term.

I don't immediately see a problem. What happens if you use your matrices with
the exact set up of step-26? Simplify your problem: Make one change at a time,
not three.

If you do get different results, compare the matrix you compute with the one
computed by the MatrixTools functions. How are they different? And why?

Best
W.


--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

Anton Ermakov

unread,
Mar 17, 2021, 9:41:10 PM3/17/21
to deal.II User Group
Thanks for the reply. I think I got it. Basically, I had to manually place the local matrices into the global matrix, without taking into account the hanging node constraints, which are later taken care of by

constraints.condense(system_matrix, system_rhs);

In the case of the mass matrix, I had to use this:

for (unsigned int i = 0; i < dofs_per_cell; ++i)

for (unsigned int j = 0; j < dofs_per_cell; ++j)

mass_matrix.add(local_dof_indices[i], local_dof_indices[j], cell_matrix(i, j));

Instead of 

constraints.distribute_local_to_global(cell_matrix, local_dof_indices, mass_matrix);

Anton.


Wolfgang Bangerth

unread,
Mar 17, 2021, 10:13:17 PM3/17/21
to dea...@googlegroups.com
On 3/17/21 10:41 PM, Anton Ermakov wrote:
> Thanks for the reply. I think I got it. Basically, I had to manually place the
> local matrices into the global matrix, without taking into account the hanging
> node constraints, which are later taken care of by
>
> /constraints.condense(system_matrix, system_rhs);/
>
> In the case of the mass matrix, I had to use this:
>
> /for (unsigned int i = 0; i < dofs_per_cell; ++i)/
>
> /for (unsigned int j = 0; j < dofs_per_cell; ++j)/
>
> /mass_matrix.add(local_dof_indices[i], local_dof_indices[j], cell_matrix(i, j));/
>
> Instead of
>
> /constraints.distribute_local_to_global(cell_matrix, local_dof_indices,
> mass_matrix);/

Ah yes, that makes sense. So do I understand right that whatever you have now
actually works?

Anton Ermakov

unread,
Mar 21, 2021, 7:10:43 AM3/21/21
to deal.II User Group
Yes, that part now works. Thank you, Wolfgang.

Anton.

Reply all
Reply to author
Forward
0 new messages