# Role of "x" vector in member function PeriodicBC:apply(A,b,x)

Asked by arnaud lejeune

Dear all,

The idea is to define a new boundary condition "u_{master} - u_{slave} = \alpha" in linear or nonlinear cases.

As detailled in the PeriodicBC:apply(A,b,x) function, it has been chosen to account for the periodic boundary condition by
1) adding master and slave rows (matrix and right hand side) and putting in the mater row
2) putting (1,-1) in the slave row of the matrix
3) putting 0 in the slave row of the right hand side.
It works in linear case for a Periodic boundary condition u_{master} = u_{slave} and a change to u_{master} = u_{slave} +\alpha is quite easy.

The question concerns the meaning of the "x" vector. It is not so clear for me because (if I well unsterstand) if "b" and "x" exist, we will have:
tmp = x_{master}-x_{slave}
b_{slave} = tmp

Then on the slave row of the linear system, we will solve :
u_{master} - u_{slave} = x_{master}-x_{slave}

How, in nonlinear case, is defined this vector "x"? In which context ?
When is called, in nonlinear case, this "apply" function ?

I notice that a change for periodic condition is under development however we have some tests to realize.

Thanks for your answers

Arnaud

## Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Garth Wells
Solved:
Last query:
Last reply:
 Revision history for this message Mikael Mortensen (mikael-mortensen) said on 2012-12-14: #1

Hi,

Den Dec 12, 2012 kl. 11:45 AM skrev arnaud lejeune:

> New question #216584 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/216584
>
> Dear all,
>
> The idea is to define a new boundary condition "u_{master} - u_{slave} = \alpha" in linear or nonlinear cases.

First of all, why do you want to do this? Sounds like something that should and could be avoided? The solution is not periodic then.

>
> As detailled in the PeriodicBC:apply(A,b,x) function, it has been chosen to account for the periodic boundary condition by
> 1) adding master and slave rows (matrix and right hand side) and putting in the mater row
> 2) putting (1,-1) in the slave row of the matrix
> 3) putting 0 in the slave row of the right hand side.
> It works in linear case for a Periodic boundary condition u_{master} = u_{slave} and a change to u_{master} = u_{slave} +\alpha is quite easy.
>
> The question concerns the meaning of the "x" vector. It is not so clear for me because (if I well unsterstand) if "b" and "x" exist, we will have:
> tmp = x_{master}-x_{slave}
> b_{slave} = tmp
>
> Then on the slave row of the linear system, we will solve :
> u_{master} - u_{slave} = x_{master}-x_{slave}
>
> How, in nonlinear case, is defined this vector "x"? In which context ?
> When is called, in nonlinear case, this "apply" function ?

x is the solution vector. It is not entirely obvious to me why this modification is needed for the PeriodicBC where x_{master} = x_{slave} anyway as far as I can tell.

>
> I notice that a change for periodic condition is under development however we have some tests to realize.

The "boundary condition" u_{master} - u_{slave} = \alpha will not be possible even for the linear case when the periodic bc is moved to the dofmap (the slave dofs will be eliminated).

Mikael

>
> Thanks for your answers
>
> Arnaud
>
>
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.

 Revision history for this message Garth Wells (garth-wells) said on 2012-12-14: #2

On Fri, Dec 14, 2012 at 2:01 PM, Mikael Mortensen
<email address hidden> wrote:
> Question #216584 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/216584
>
> Status: Open => Answered
>
> Mikael Mortensen proposed the following answer:
> Hi,
>
> Den Dec 12, 2012 kl. 11:45 AM skrev arnaud lejeune:
>
>> New question #216584 on DOLFIN:
>> https://answers.launchpad.net/dolfin/+question/216584
>>
>> Dear all,
>>
>> The idea is to define a new boundary condition "u_{master} - u_{slave} = \alpha" in linear or nonlinear cases.
>
> First of all, why do you want to do this? Sounds like something that
> should and could be avoided? The solution is not periodic then.
>
>>
>> As detailled in the PeriodicBC:apply(A,b,x) function, it has been chosen to account for the periodic boundary condition by
>> 1) adding master and slave rows (matrix and right hand side) and putting in the mater row
>> 2) putting (1,-1) in the slave row of the matrix
>> 3) putting 0 in the slave row of the right hand side.
>> It works in linear case for a Periodic boundary condition u_{master} = u_{slave} and a change to u_{master} = u_{slave} +\alpha is quite easy.
>>
>> The question concerns the meaning of the "x" vector. It is not so clear for me because (if I well unsterstand) if "b" and "x" exist, we will have:
>> tmp = x_{master}-x_{slave}
>> b_{slave} = tmp
>>
>> Then on the slave row of the linear system, we will solve :
>> u_{master} - u_{slave} = x_{master}-x_{slave}
>>
>> How, in nonlinear case, is defined this vector "x"? In which context ?
>> When is called, in nonlinear case, this "apply" function ?
>
> x is the solution vector. It is not entirely obvious to me why this
> modification is needed for the PeriodicBC where x_{master} = x_{slave}
> anyway as far as I can tell.
>

In general, it's possible with an iterative solver that there may be
some difference between the master and the slave. The difference would
appear in the residual in a linear solver iteration.

>>
>> I notice that a change for periodic condition is under development however we have some tests to realize.
>
> The "boundary condition" u_{master} - u_{slave} = \alpha will not be
> possible even for the linear case when the periodic bc is moved to the
> dofmap (the slave dofs will be eliminated).
>

And in this case there will be no issue with iterative solvers and
differences between the master and slave dofs..

Garth

> Mikael
>
>
>>
>> Thanks for your answers
>>
>> Arnaud
>>
>>
>>
>> --
>> You received this question notification because you are a member of
>> DOLFIN Team, which is an answer contact for DOLFIN.
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.

 Revision history for this message arnaud lejeune (arnaud-lejeune) said on 2012-12-15: #3

Thanks Garth Wells, that solved my question.

 Revision history for this message arnaud lejeune (arnaud-lejeune) said on 2012-12-15: #4

Thakks Garth Wells and Mikael Mortensen for the anwsers.
Just to add a comment :
1) This kind of condition is classical in multiscale simulation ; perhaps it exists another way to account for the localization step ?

2) If I well understood, starting form an initial solution u_0 solution of the non linear problem (or not so far) such that
u(x+h)-u(x) =0
the problem could be solved wtih succeeding linear iteration and in some cases, we could have pertubed solution such that u(x+h)-u(x)=\epsilon
then a correction step should be applied ?

3) Mikael wrote: "The "boundary condition" u_{master} - u_{slave} = \alpha will not be possible even for the linear case when the periodic bc is moved to the dofmap (the slave dofs will be eliminated)."
From my point of view, as in some other FE framework, this kind of condition could be generalized as Cu=u_d containing Dirichlet and periodic boundary condition (with C a matrix and u_d a vector). Then could the condition "u(x+h)-u(x)=\alpha" be considered in a way quite similar to Dirchlet "u=u_d" condition ?

To post a message you must log in.