Multiple Boundary conditions on one boundary

Asked by Mo

Hi folks,

My question is that how we can apply both Neumann and Dirichlet boundary conditions on one boundary. I am solving a second order one dimensional PDE with two Neumann boundary conditions (zero flux on boundaries). Since we do not have a Dirichlet boundary, the solution does not have a unique solution. To overcome this issue, I apply a Dirichlet boundary condition on one the boundaries. But I still need zero net flux on both boundaries. By applying Dirichlet boundary condition on one of the boundaries, automatically, the Neumann boundary condition cancels out and lead to an incorrect solution (no more zero slope on this boundary). How can I apply the Dirichlet boundary condition by not canceling out the Neumann boundary condition.

Any help is deeply appreciated.

Best,
Mohammad

Question information

Language:
English Edit question
Status:
Solved
For:
FEniCS Project Edit question
Assignee:
No assignee Edit question
Solved by:
Anders Logg
Solved:
Last query:
Last reply:
Revision history for this message
Anders Logg (logg) said :
#1

On Fri, Nov 18, 2011 at 09:15:42PM -0000, M Hadigol wrote:
> New question #179286 on FEniCS Project:
> https://answers.launchpad.net/fenics/+question/179286
>
> Hi folks,
>
> My question is that how we can apply both Neumann and Dirichlet boundary conditions on one boundary. I am solving a second order one dimensional PDE with two Neumann boundary conditions (zero flux on boundaries). Since we do not have a Dirichlet boundary, the solution does not have a unique solution. To overcome this issue, I apply a Dirichlet boundary condition on one the boundaries. But I still need zero net flux on both boundaries. By applying Dirichlet boundary condition on one of the boundaries, automatically, the Neumann boundary condition cancels out and lead to an incorrect solution (no more zero slope on this boundary). How can I apply the Dirichlet boundary condition by not canceling out the Neumann boundary condition.
>
> Any help is deeply appreciated.

Add the constraint \int u dx = 0 to your system using a Lagrange
multiplier. To see how this is done, take a look at the demo

  demo/undocumented/neumann-poisson/

in DOLFIN.

An easier but more dubious approach is to add a term

  eps*u*v*dx

to your bilinear form where eps is a small number (say 1e-7).

--
Anders

Revision history for this message
Mo (mo-h) said :
#2

Thank you Anders. Actually I was looking at this demo you added. The point is that my constraint is not \int u dx = 0, it is u = 0 at one arbitrary point in 1D domain. I did not get that how you ended up with the bilinear form in neumann-poisson. Would you please let me know how you derived that, so I can change the constraint you used to my desired one.

Another quick question: Can't we simply apply the additional constraint, i.e. u = 0 at the middle of the domain, similar to what we do for Dirichlet BC on boundaries?

Thank you so much for your time.

Revision history for this message
Best Anders Logg (logg) said :
#3

On Mon, Nov 21, 2011 at 10:20:46PM -0000, M Hadigol wrote:
> Question #179286 on FEniCS Project changed:
> https://answers.launchpad.net/fenics/+question/179286
>
> M Hadigol posted a new comment:
> Thank you Anders. Actually I was looking at this demo you added. The
> point is that my constraint is not \int u dx = 0, it is u = 0 at one
> arbitrary point in 1D domain. I did not get that how you ended up with
> the bilinear form in neumann-poisson. Would you please let me know how
> you derived that, so I can change the constraint you used to my desired
> one.

The point you should use the constraint \int u dx = 0 instead of u =
0 at a point (which will lead to problems).

If you insist on setting u = 0 at a point, then use the "pointwise"
flag to the DirichletBC class.

> Another quick question: Can't we simply apply the additional constraint,
> i.e. u = 0 at the middle of the domain, similar to what we do for
> Dirichlet BC on boundaries?

Yes.

--
Anders

Revision history for this message
Mo (mo-h) said :
#4

Thank you so much Anders. The "pointwise" flag solved my problem.

Mohammad

Revision history for this message
Mo (mo-h) said :
#5

Thanks Anders Logg, that solved my question.