Dear Prof. Bangerth,

Thanks very much for your quick answer!

> Constraints are funny and sometimes require deep thought about what 
exactly 
> they mean. What happens if you don't apply constraints to the 
> cell_volume_matrix and cell_gradient_matrix -- i.e., you copy the 
elements 1:1 
> into the matrix, without the 'constraints' object? (Like in step-4.) 
I rewrite my code as you say, and the results are:
Cycle 0:
   Number of active cells:       20
   Number of degrees of freedom: 89
 u square 0: 0.0305621  grad u square 0: 0.256542
Cycle 1:
   Number of active cells:       44
   Number of degrees of freedom: 209
 u square 1: 0.144303  grad u square 1: 0.49794
Cycle 2:
   Number of active cells:       92
   Number of degrees of freedom: 449
 u square 2: 0.101366  grad u square 2: 0.477137
Cycle 3:
   Number of active cells:       188
   Number of degrees of freedom: 881
 u square 3: 0.13305  grad u square 3: 0.529805
Cycle 4:
   Number of active cells:       368
   Number of degrees of freedom: 1737
 u square 4: 0.145489  grad u square 4: 0.565953
Cycle 5:
   Number of active cells:       737
   Number of degrees of freedom: 3409
 u square 5: 0.141771  grad u square 5: 0.574863
Cycle 6:
   Number of active cells:       1436
   Number of degrees of freedom: 6705
 u square 6: 0.171807  grad u square 6: 0.642486
Cycle 7:
   Number of active cells:       2729
   Number of degrees of freedom: 12521
 u square 7: 0.160819  grad u square 7: 0.625337

The attached is the code ,which doesn't use 
"constraints.distribute_local_to_global(...)" and 
"DoFTools::make_hanging_node_constraints (dof_handler,  constraints);"
if "DoFTools::make_hanging_node_constraints (dof_handler,  constraints);" 
remain, the results:
Cycle 0:
   Number of active cells:       20
   Number of degrees of freedom: 89
 u square 0: 0.0305621  grad u square 0: 0.256542
Cycle 1:
   Number of active cells:       44
   Number of degrees of freedom: 209
 u square 1: 0.0822159  grad u square 1: 2.97512
Cycle 2:
   Number of active cells:       92
   Number of degrees of freedom: 449
 u square 2: 0.000404454  grad u square 2: 0.0534184
Cycle 3:
   Number of active cells:       188
   Number of degrees of freedom: 937
 u square 3: 9.40228e-05  grad u square 3: 0.0378517
Cycle 4:
   Number of active cells:       368
   Number of degrees of freedom: 1793
 u square 4: 7.66868e-05  grad u square 4: 0.0403114
Cycle 5:
   Number of active cells:       704
   Number of degrees of freedom: 3321
 u square 5: 5.9193e-05  grad u square 5: 0.0366146
Cycle 6:
   Number of active cells:       1412
   Number of degrees of freedom: 6657
 u square 6: 6.47763e-05  grad u square 6: 0.0455655
Cycle 7:
   Number of active cells:       2696
   Number of degrees of freedom: 12477
 u square 7: 2.50787e-05  grad u square 7: 0.0320763



So I wander if it approximate the "grad u_exact square" and  "u_exact 
square" correctly?  
Because in my numerical experiments, the  "grad u_h square" and  "u_h 
square" of numerical solution u_h are what we take care of. 

So if the computions of "grad u_h square" and  "u_h square" are divided 
from other work like visualization, error estimation, are these results 
correct if change the using of constraints?
And without "constraints..distribute_local_to_global(...)", the information 
of boundary may not use correctly (for example, My boundary condition is 
periodic boundary condition).

Thank you very much!

Best,
Chucui

在 2019年2月12日星期二 UTC+8下午1:49:15,Wolfgang Bangerth写道:
>
> On 2/11/19 12:20 AM, chucu...@gmail.com <javascript:> wrote: 
> > Dear Prof. Bangerth: 
> > 
> > Thank you very much for your quick reply! 
> > 
> > When I apply hanging node constraints to my matrix, as the step-6 
> > says: https://www.dealii.org/developer/doxygen/deal.II/step_6.html 
> > I make 4 steps: 
> >      1.Create a Constraints Class: 
> > | 
> > ConstraintMatrix    constraints; 
> > | 
> > 
> >      2.Fill this object using the function 
> > DoFTools::make_hanging_node_constraints() to ensure continuity of the 
> elements 
> > of the finite element space. 
> > | 
> > DoFTools::make_hanging_node_constraints (dof_handler, 
> >                                             constraints); 
> > | 
> > 
> >      3.Copy the local contributions to the matrix and right hand side 
> into the 
> > global objects: 
> > | 
> >        constraints.distribute_local_to_global (cell_matrix, 
> >                                                cell_rhs, 
> >                                                local_dof_indices, 
> >                                                system_matrix, 
> >                                                system_rhs); 
> >        constraints.distribute_local_to_global (cell_volume_matrix, 
> >                                                local_dof_indices, 
> >                                                volume_matrix); 
> >        constraints.distribute_local_to_global (cell_gradient_matrix, 
> >                                                local_dof_indices, 
> >                                                gradient_matrix); 
> > | 
> > 
> > 
> >      4.Make sure that the degrees of "freedom" located on hanging nodes 
> get 
> > their correct (constrained) value: 
> > | 
> >   constraints.distribute (solution); 
> > | 
>
> Constraints are funny and sometimes require deep thought about what 
> exactly 
> they mean. What happens if you don't apply constraints to the 
> cell_volume_matrix and cell_gradient_matrix -- i.e., you copy the elements 
> 1:1 
> into the matrix, without the 'constraints' object? (Like in step-4.) 
>
> Alternatively, you could do as you show above and after calling 
> 'constraint.distribute(solution)' you manually set all constrained degrees 
> of 
> freedom in the solution vector to zero. That's not what you want to use 
> for 
> visualization, error estimation, ... but it might work for the operation 
> you're trying here. 
>
> I'm pretty sure that both of these solutions should work individually (but 
> not 
> in combination). But explaining why this is so would take a page or two, 
> I'm 
> afraid. 
>
> Best 
>   W. 
>
>
> -- 
> ------------------------------------------------------------------------ 
> Wolfgang Bangerth          email:                 bang...@colostate.edu 
> <javascript:> 
>                             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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to