Subtle issues in time-dependent Dirichlet boundary conditions

116 views
Skip to first unread message

Jie Cheng

unread,
Apr 1, 2018, 4:11:26 PM4/1/18
to deal.II User Group
Hi everyone

I am solving time-dependent Navier-Stokes equations with varying Dirichlet boundary conditions. Although I have read the "Constraints on degrees of freedom" for many times, I am still not sure what the best way to implement changing boundary conditions is. My time scheme is fully implicit, so there is an outer time loop, plus an inner Newton iteration, and I am solving for the newton_increment. My code works fine when the Dirichlet boundary conditions are not changing in time. The way I implemented it is that I have two ConstraintMatrix, one for nonzero_constraints and one for zero_constraints. At the first Newton iteration in the first time step, I apply nonzero_constraint in the assembly process using distribute_local_to_global and after solving it call distribute to recover the constrained values. At all the following iterations,  use zero_constraints to assemble. This gives me the correct solution because I start with v = 0, so the first newton iteration will correctly set the boundary values, and after that I do want the newton_increment at the Dirichlet boundary to be 0 since the boundary condition do not change in time.

My first question is, if the boundary conditions are time-dependent, then I would have to use nonzero constraints at the first Newton iteration in every time step, right? In addition, the value of those constraints should not be the fluid velocity that I want, instead, it should be the velocity delta between time steps, because the degrees of freedom to be solved are the velocity increment, not the velocity itself, right?

This issue gets more complicated when not only the constrained values change in time, but also the dofs to be constrained also change in time. This issue arises in my fluid-structure interaction application with immersed method: I need to force the fluid velocity in certain area to be the same as the solid velocity, and the solid location always changes. Therefore, I want to apply totally different Dirichlet boundary conditions at different time steps. This means I have to 1. recreate the ConstraintMatrix 2. recreate the sparsity pattern, which is related to the constraints, and reinitialize the system matrix, solution vectors etc. Is this reasonable?

Thank you!

Best
Jie


Wolfgang Bangerth

unread,
Apr 2, 2018, 4:19:15 PM4/2/18
to dea...@googlegroups.com

Jie,

> I am solving time-dependent Navier-Stokes equations with varying
> Dirichlet boundary conditions. Although I have read the "Constraints on
> degrees of freedom" for many times, I am still not sure what the best
> way to implement changing boundary conditions is. My time scheme is
> fully implicit, so there is an outer time loop, plus an inner Newton
> iteration, and I am solving for the* newton_increment*. My code works
> fine when the Dirichlet boundary conditions are not changing in time.
> The way I implemented it is that I have two ConstraintMatrix, one for
> nonzero_constraints and one for zero_constraints. At the *first* Newton
> iteration in the *first* time step, I apply nonzero_constraint in the
> assembly process using distribute_local_to_global and after solving it
> call distribute to recover the constrained values. At all the following
> iterations,  use zero_constraints to assemble. This gives me the correct
> solution because I start with v = 0, so the first newton iteration will
> correctly set the boundary values, and after that I do want the
> newton_increment at the Dirichlet boundary to be 0 since the boundary
> condition do not change in time.
>
> My first question is, if the boundary conditions are time-dependent,
> then I would have to use nonzero constraints at the *first* Newton
> iteration in *every* time step, right?

Correct.


> In addition, the value of those
> constraints should *not* be the fluid velocity that I want, instead, it
> should be the velocity *delta* between time steps, because the degrees
> of freedom to be solved are the velocity increment, not the velocity
> itself, right?

Yes, also correct. But you could always rewrite things in such a way
that in the first Newton iteration in each time step, you solve for the
velocity and not the increment. In that case, the boundary values are
the correct velocity at the boundary, not just the increment from the
previous time step.


> This issue gets more complicated when not only the constrained values
> change in time, but also the dofs to be constrained also change in time.
> This issue arises in my fluid-structure interaction application with
> immersed method: I need to force the fluid velocity in certain area to
> be the same as the solid velocity, and the solid location always
> changes. Therefore, I want to apply totally different Dirichlet boundary
> conditions at different time steps. This means I have to 1. recreate the
> ConstraintMatrix 2. recreate the sparsity pattern, which is related to
> the constraints, and reinitialize the system matrix, solution vectors
> etc. Is this reasonable?

Yes. But if you do not eliminate constrained degrees of freedom from the
sparsity pattern (there is a function argument to
make_sparsity_pattern()), then you also don't need to recreate the
sparsity pattern in each time step and don't need to reinitialize the
matrix -- you just need to set it to zero.

Best
W.

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

Jie Cheng

unread,
Apr 5, 2018, 10:42:55 AM4/5/18
to deal.II User Group
Dear Wolfgang

Problem solved, thank you! For other people's references, here is what I did: 1. when setting the nonzero_constraints, always query the current value first and then substract it from the target value so that the solution delta is constrained correctly. 2. Apply nonzero_constraints at the first Newton iteration in every time step. 3. By not eliminating constrained dofs from the sparsity pattern, no need to recreate it when the constraints change, thus no need to reinitialize the matrices and vectors.

Jie

llf m

unread,
May 16, 2019, 9:37:27 PM5/16/19
to deal.II User Group
Dear Jie,
     In your conclusion here the point 2 may be ambiguous,
>  Apply nonzero_constraints at the first Newton iteration in every time step.
Is that means:
    use nonzero_constraints to distribute newton update or solution or both?
In my thought, in moving nonzero constraints case:
    In the first Newton iteration in every time step:
        use zero_constraints to distribute newton update(increment)
        use nonzero_constraints to distribute solution after solution add the newton update
    In the follow Newton iteration in every time step:
        use zero_constraints to distribute newton update
        not need to use nonzero_constraints to distribute solution
Or, in the invariant nonzero_constraints case: 
    In the first Newton iteration in first time step:
        use zero_constraints to distribute newton update(increment)
        use nonzero_constraints to distribute solution after solution adding the newton update
    otherwise:
        use zero_constraints to distribute newton update(increment)
in that way, the solution will keep the correct nonzero value in boundary.

If use the nonzero_constraints to distribute the newton update in the first 
newton iteration in every timestep, then the solution (after adding the newton update) will has the
nonzero boundary value added again while your solution is not zero in boundary
(but in your case maybe any time step your start with a zero solution that wouldn't cause any error).

It's that right? 
    
在 2018年4月5日星期四 UTC+8下午10:42:55,Jie Cheng写道:
Reply all
Reply to author
Forward
0 new messages