boundaries in dealii

67 views
Skip to first unread message

Nikki Holtzer

unread,
Apr 18, 2021, 10:56:26 AM4/18/21
to deal.II User Group
I've recently implemented a 1d standard wave equation and have been messing around with different boundary conditions. For instance, I have run my code with 1 dirichlet and 1 neumann, 2 neumann, and 1 absorbing condition and 1 neumann (as in step-24). When I run step-23 from the examples, which utilizes Dirichlet conditions, you can easily see the expected behavior of a phase flip after interaction from the boundary, i.e. as the source approaches the boundary it looks like a cap and after the boundary interaction it looks like a cup. However, in all 3 cases that I have tried, listed above, I am not observing the phase flip. No matter what boundary I change the left one to (dirichlet, neumann, absorbing) it seems to be giving me the same neumann behavior. Do you have any idea why this might be?

I have attached my code. If you were to run the code currently, it would run with a dirichlet condition on the left and a neumann on the right. In order to run with the absorbing boundary matrix , I comment out lines 316-320 and line 611 as well as uncommenting the very end of lines 616 and 645 which adds the boundary matrix to the computation. 

Thank you!!

waveeqn_testboundarymat.cc

Wolfgang Bangerth

unread,
Apr 27, 2021, 11:59:14 PM4/27/21
to dea...@googlegroups.com

Nikki,
apologies for not getting to this any earlier!

> I've recently implemented a 1d standard wave equation and have been messing
> around with different boundary conditions. For instance, I have run my code
> with 1 dirichlet and 1 neumann, 2 neumann, and 1 absorbing condition and 1
> neumann (as in step-24). When I run step-23 from the examples, which utilizes
> Dirichlet conditions, you can easily see the expected behavior of a phase flip
> after interaction from the boundary, i.e. as the source approaches the
> boundary it looks like a cap and after the boundary interaction it looks like
> a cup. However, in all 3 cases that I have tried, listed above, I am not
> observing the phase flip. No matter what boundary I change the left one to
> (dirichlet, neumann, absorbing) it seems to be giving me the same neumann
> behavior. Do you have any idea why this might be?

I don't see any specific thing that looks wrong, but then it's an 800 line
code -- not easy to see anything without spending a couple of hours with it.

But here's where I would start: Look at the difference between Dirichlet and
Neumann cases. If I see this right, setting up Dirichlet conditions happens in
line 319 for boundary zero, which in line 162 you seem to think of as the
right boundary. So does the call to VectorTools::interpolate_boundary_values
actually do anything? If you comment it out, does it change anything?

I suspect no: You put the result into the 'boundary_value_map' variable, but
that's a local variable whose lifetime ends at the end of the function, and it
is never used after calling VectorTools::interpolate_boundary_values. So that
looks like a bug -- or at least a pointless piece of code.

Of course, you do the same again in line 573. There, you seem to set the
elements of the solution vector to the correct boundary values, but you do not
touch the matrix. But you need to adjust the matrix before you solve with it
if you want to apply the correct set of boundary values -- take a look at
step-3, step-4, step-26, for example. In particular the last one.


Best
W.

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

Nikki Holtzer

unread,
May 5, 2021, 8:57:14 AM5/5/21
to deal.II User Group
Hi,

Thank you for taking a look. You are correct in that if I comment out VectorTools::interpolate_boundary_values in line 320, the solution does not change. If I understand you correctly, you are saying that the function apply_boundary_values defined in line 553 and called in line 630 must take in the system_matrix and must modify system_matrix in the same way I do the solution vector? This also means that when I call apply_boundary_values, I must move the location of this call until say line 646 or after I define system_matrix but before I solve?

Thank you.
Reply all
Reply to author
Forward
0 new messages