# [deal.II] Re: Constrain specific dofs to given value

```Pai,

This is not my area of expertise but the way I understand it to add a
constraint into the constraint matrix, you first need to add a line in the
constraint matrix and then add an entry in the constraint matrix. What you
have done is adding empty lines to the constraint matrix and therefore, you
haven't added any constraint. I think you should use this function too
https://dealii.org/9.0.0/doxygen/deal.II/classConstraintMatrix.html#a4cd323a407cb379510a68c26e842304e```
```
Best,

Bruno

On Thursday, May 17, 2018 at 2:04:43 AM UTC-4, Pai Liu wrote:
>
> Hi all,
>
> I want to solve a 2D linear elastic problem with a Dirichlet boundary
> condition that keeps only one node fixed. And I encountered convergence
> problem by modifying codes in step-8 as following:
>
> In the setup_system() function, I used the "add_line" functions to
> contrain dof 0 and dof 1 to zero:
>
> ----------------------------------------------
> hanging_node_constraints.clear();
> DoFTools::make_hanging_node_constraints(dof_handler,
> hanging_node_constraints);
> hanging_node_constraints.close();
> ----------------------------------------------
>
> In my case there is actually no hanging nodes (I used a 4*4 mesh without
> refinement in this test).
> And I commented the codes in assemble_system() that applies Dirichlet b.c.
> (I just want to fix one node) as:
> ----------------------------------------------
> // std::map<types::global_dof_index, double> boundary_values;
> // VectorTools::interpolate_boundary_values(dof_handler, 0,
> ZeroFunction<dim>(dim), boundary_values);
> // MatrixTools::apply_boundary_values(boundary_values, system_matrix,
> solution, system_rhs);
> ----------------------------------------------
>
> By modifying with above codes, the cg solver does not converge. I guess
> this may be caused by the way the constraints are applied.
> *Actually I just want to apply the Dirichlet b.c. on one node with the
> same commend as "VectorTools::interpolate_boundary_values(dof_handler, 0,
> ZeroFunction<dim>(dim), boundary_values);", but this **function only
> supports interpolation on basis of boundary id instead of specific dofs or
> nodes.*
> *So is there a way to apply Dirichlet b.c. on one node (I mean in form of
> natural boundary condition instead of constrains)?*
>
>
> Best,
> Pai
>
>

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see