Imposing Dirichlet-type conditions via AffineConstraints: Expected behavior or bug?

51 views
Skip to first unread message

Ahmad Shahba

unread,
Mar 17, 2020, 10:34:16 AM3/17/20
to deal.II User Group
Hi all,

I am re-posting this here and delete the previous one since the images in my original post do not load properly. So here it is!

I am seeing a rather strange behavior from AffineConstraints when dealing with inhomogenous Dirichlet-type conditions in an MPI context. To explain this behavior, I set up a small problem which involves solving a system of linear equations. The coefficient matrix is an 8x8 identity matrix (i.e. all entries on diagonal are 1 and all other components are zero). The solution to the system of equations is subject to the following constraints

  1. u_0 = u_4
  2. u_1 = u_5
  3. u_2 = 0
  4. u_3 = 0
  5. u_4 = 0.05
  6. u_6 = 0
  7. u_7 = 0

Clearly DOF 5 is the only true unknown while the rest are known. All components of the force vector corresponding to this system is zero except for
  • F_5 = 1
Note that the force vector entries corresponding to all constrained DOFs are zero (since AffineConstraints will take care of imposing the correct values later) and the only non-zero entry corresponds to the true unknown DOF 5. 

This system is distributed between 2 processes such that
  • Process 0: handles DOFs 0 to 3
  • Process 1: handles DOFs 4 to 7
Due to this partitioning, the affine constraint set up by process 0 takes care of constraints 1 to 4 (given above) and process 1 takes care of constraints 5 to 7.

My expectation
I expected when I solve the system and then call distribute method of AffineConstraints, the solution should come out as

  • u_0 = 0.05
  • u_1 = 1
  • u_2 = 0
  • u_3 = 0
  • u_4 = 0.05
  • u_5 = 1
  • u_6 = 0
  • u_7 = 0

My observation
I observe that after calling the distribute method, solution is
  • u_0 = 0
  • u_1 = 1
  • u_2 = 0
  • u_3 = 0
  • u_4 = 0.05
  • u_5 = 1
  • u_6 = 0
  • u_7 = 0
That is, the AffineConstraints object correctly imposed all constraints except for constraint 1 on DOF 0. I noticed that if I invoke distribute method twice, I will get the correct result though.

My question:
Is this behavior expected? Or am I doing something wrong or perhaps my understanding of this subject is flawed?

I prepared a small code to demonstrate this behavior. Thanks in advance for your help and sorry for this long description of the problem.

Regards,
Ahmad   
     

ut_smallTest.cpp

Wolfgang Bangerth

unread,
Mar 20, 2020, 7:59:30 PM3/20/20
to dea...@googlegroups.com
On 3/17/20 8:34 AM, Ahmad Shahba wrote:
>
> *_My question:_*
> Is this behavior expected? Or am I doing something wrong or perhaps my
> understanding of this subject is flawed?
>
> I prepared a small code to demonstrate this behavior. Thanks in advance for
> your help and sorry for this long description of the problem.

The AffineConstraints class needs to know about constraints on all *locally
relevant* DoFs, not just the locally owned ones. So I would suspect (without
having tried) that when you do

dealii::AffineConstraints<double> constraints(locallyRelevantIndices);


if (idProcess == 0) {
constraints.add_lines(std::set<unsigned>({0, 1, 2, 3}));
constraints.add_entry(0, 4, 1.0);
constraints.add_entry(1, 5, 1.0);
} else {
constraints.add_lines(std::set<unsigned>({4, 6, 7}));
constraints.set_inhomogeneity(4, 0.05);
}

That this is not enough -- you need to also add the constraints for the other
unknowns among the locally relevant ones.

Best
W.

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

Ahmad Shahba

unread,
Mar 25, 2020, 8:35:05 AM3/25/20
to dea...@googlegroups.com
Thanks Wolfgang for your help! I tried it out and it worked.

Regards,
Ahmad 

--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/3357f013-3dcf-2efe-329a-86cd002888e3%40colostate.edu.
Reply all
Reply to author
Forward
0 new messages