Denis, thanks a lot for the answer! I think that on the first step I can use usual "interpolate_boundary_values + apply_boundary_values" functions, that transform the global matrix: columns of the constrained nodes become zero columns with diagonal non-zero entries.

In a time loop I have to account boundary condition without modifing global matrix. While looping over dirichlet constrained cells I call the function "hanging_node_constraints.distribute_local_to_global(cell_rhs, local_dof_indices, system_rhs, cell_matrix)" which modifies the system_rhs vector by adding columns from constrained nodes, which are actually zero in global matrix. Also I need to add components to rhs vector from the force boundary conditions. However, I have to somehow account Dirichlet boundary conditions as in previous step I didn't use any boundary values. The function "interpolate_boundary_values(dof_handler, boundary_id, DirichletHandler, boundary_values)" gives me "boundary_values" variables that maps node numbers to dirichle boundary. But I don't know how should I use it. What should I do with that variable to account boundary conditions together with "distribute_local_to_global"? Thanks a lot in advance. Sorry for my misunderstanding. On Thursday, February 22, 2018 at 1:14:41 AM UTC+3, Denis Davydov wrote: > > Hi Iliya, > > there are numerous things that are wrong > > On Wednesday, February 21, 2018 at 5:32:55 PM UTC+1, Bryukhanov Ilya wrote: >> >> Denis, thanks a lot for your answer and links that you provided. >> >> However, my solution becomes in a way that the displacement values on >> that boundary abnormally grow >> even without assigning new boundary condition in a time loop. I attach >> figures on the zero step (correct) and on the first step (wrong). >> >> I do the following these things on each iteration: >> 1) recompute rhs vector - system_rhs (which is zero for my problem), >> 2) compute matrix terms that are on the dirichlet boundary: >> for (auto cell = dof_handler.begin_active(); cell!=dof_handler.end(); >> ++cell) { >> cell_matrix = 0; cell_rhs = 0; fe_values.reinit(cell); >> for (unsigned int face_number=0; >> face_number<GeometryInfo<dim>::faces_per_cell; ++face_number) { >> if (cell->face(face_number)->at_boundary()) { >> // boundary index >> int id = cell->face(face_number)->boundary_id(); >> if (boundary_displacement.find(id) != >> boundary_displacement.end()) { >> //compute cell_matrix >> >> Then call function >> hanging_node_constraints.distribute_local_to_global(cell_matrix, >> cell_rhs, local_dof_indices, system_matrix, system_rhs); >> > > ^^ that should be hanging_node_constraints + Dirichlet > >> >> 3) Then apply functions to account Dirichlet boundary condition: >> VectorTools::interpolate_boundary_values(dof_handler, boundary_id, >> DirichletHandler, boundary_values); >> > ^^ that you would use during your setup > > >> MatrixTools::apply_boundary_values (boundary_values, >> system_matrix, >> solution, >> system_rhs); >> > > ^^ this is already what constraints.distribute_local_to_global() does, so > no need to do that. > > Regards > Denis. > > >> >> >> Can you give some advice how to make it correct? >> >> >> <https://lh3.googleusercontent.com/-O_1geVdTAOc/Wo2eOCPcdWI/AAAAAAAAA44/s_OauNpGhwcv2d4h3nmBinL40UhP7-S7ACLcBGAs/s1600/iter0.jpg> >> >> <https://lh3.googleusercontent.com/-wHZAFJbU0bI/Wo2egOHamAI/AAAAAAAAA5A/6QJqcgEqD8MiPR5DNLF34OWMF3qX9QZvQCLcBGAs/s1600/iter1.jpg> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> On Tuesday, February 20, 2018 at 10:51:17 PM UTC+3, Denis Davydov wrote: >>> >>> Hi Ilya, >>> >>> I am not away of principally simple solution, the RHS simply contains >>> your bilinear form times interpolated values at constrained DoFs. >>> What you can do is to loop over a subset of cells (those which are at >>> the boundary), still assemble the local matrix and do >>> constraints.distribute_local_to_global() which takes global matrix and >>> RHS. >>> >>> Or you can use constrained_linear_operator >>> <https://www.dealii.org/developer/doxygen/deal.II/group__constraints.html#ga59c2f70370213d436cb9fade9d813478>, >>> >>> see this >>> <https://groups.google.com/d/msg/dealii/A8dQs5i2n8A/YotvqvGwEgAJ> forum >>> discussion. >>> >>> Please also study this >>> <https://groups.google.com/d/msg/dealii/xo3Fa_olNwM/ObOuJPP2JT0J> >>> thread, which covers similar question. >>> >>> Regards, >>> Denis. >>> >>> On Tuesday, February 20, 2018 at 4:46:19 PM UTC+1, Bryukhanov Ilya wrote: >>>> >>>> Hi, >>>> >>>> I consider elastic problem and forces and displacements on boundaries >>>> are changing with time. I don't want to compute FEM matrix >>>> on each step. How to correctly simulate the task? I know that there is >>>> a simple solution, but my solution is incorrect :) >>>> I have two variables for the system_matrix and rhs_vector. I try to >>>> recompute rhs_vector on each step and dirichlet condition >>>> is accounted by calling "intepolate_boundary values + >>>> apply_boundary_values" on each step with system_matrix and rhs_vector >>>> variables inside. >>>> I think that I should use initial matrix and the matrix which is >>>> modified by Dirichlet procedure and assign latter to the initial matrix on >>>> each step? >>>> Am I corrent or there is some other solution? >>>> >>>> >>>> >>>> >>>> >>>> >>>> -- 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.