# [deal.II] Re: increment Dirichlet boundary condition

```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,
and this procedures transform the global matrix so that the columns of
constrained nodes become zero columns with diagonal non-zero entries.
In a time loop I have to account boundary condition so the calling of
"hanging_node_constraints.distribute_local_to_global(cell_rhs,
local_dof_indices, system_rhs, cell_matrix)"
while looping over dirichlet constrained cells modify the system_rhs vector
by adding columns from constrained nodes,
which are actually zero in global matrix. However, I have to somehow
account boundary conditions. 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 the variable "boundary_values" to account boundary conditions in
"distribute_local_to_global"?```
```
Thanks a lot in advance. Sorry for my misundersting.

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:
>>
>>
>> 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?
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> 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
>>>
>>> see this
>>> discussion.
>>>
>>> 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