Dirichlet b.c. applied to components

Asked by Joe Morris

What is the preferred means for applying a Dirichlet b.c. to the components of a vector unknown (in order to implement free-slip or "roller" b.c.s).

E.g.:

u[0]=0 on x=0, but u[1], u[2] are free...

Doing a search, I've seen discussion of free-slip b.c.s in the context of Unicorn. Separately, there are discussions of attempts to legislate u.n=0 in the form itself. Is there a means to do it with native dolfin using one of the BC classes? I "only" want to deal with the simple case I describe above, not the more general u.n=0 case.

Thanks,

Joe.

Question information

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

On Tue, Sep 14, 2010 at 08:01:18PM -0000, Joe Morris wrote:
> New question #125426 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/125426
>
> What is the preferred means for applying a Dirichlet b.c. to the components of a vector unknown (in order to implement free-slip or "roller" b.c.s).
>
> E.g.:
>
> u[0]=0 on x=0, but u[1], u[2] are free...
>
> Doing a search, I've seen discussion of free-slip b.c.s in the context of Unicorn. Separately, there are discussions of attempts to legislate u.n=0 in the form itself. Is there a means to do it with native dolfin using one of the BC classes? I "only" want to deal with the simple case I describe above, not the more general u.n=0 case.
>
> Thanks,

Just do

  bc = DirichletBC(V.sub(0), 0, "x[0] == 0.0")

This will set the x-component to zero at x = 0.

--
Anders

Revision history for this message
Joe Morris (x-launchpad-the-morris-net) said :
#2

Excellent. In c++ I tried achieving this with:

    SubSpace V0(*V,0);
    DirichletBC bcLeftRightFixedU(V0, leftRightFixedU, onLeftRightBoundary);
    bcs.push_back(&bcLeftRightFixedU);

But at runtime I get the complaint that:

Error: Unable to create boundary condition. Reason: Illegal value 1 for value rank, should be 0.

Revision history for this message
Johan Hake (johan-hake) said :
#3

On Tuesday September 14 2010 13:52:06 Joe Morris wrote:
> Question #125426 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/125426
>
> Status: Answered => Open
>
> Joe Morris is still having a problem:
> Excellent. In c++ I tried achieving this with:
>
> SubSpace V0(*V,0);
> DirichletBC bcLeftRightFixedU(V0, leftRightFixedU,
> onLeftRightBoundary); bcs.push_back(&bcLeftRightFixedU);
>
> But at runtime I get the complaint that:
>
> Error: Unable to create boundary condition. Reason: Illegal value 1 for
> value rank, should be 0.

It looks like you passed a vector constant as leftRightFixedU.

It should be:

  Constant leftRightFixedU(0.);

Johan

Revision history for this message
Joe Morris (x-launchpad-the-morris-net) said :
#4

Thanks Johan: I'm still finding the error messages confusing. In retrospect, the error message makes perfect sense and I can't believe I missed the correct interpretation.

Regards,

Joe.

Revision history for this message
Joe Morris (x-launchpad-the-morris-net) said :
#5

Thanks Anders Logg, that solved my question.

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

On Wed, Sep 15, 2010 at 12:36:36AM -0000, Joe Morris wrote:
> Question #125426 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/125426
>
> Status: Answered => Solved
>
> Joe Morris confirmed that the question is solved:
> Thanks Johan: I'm still finding the error messages confusing. In
> retrospect, the error message makes perfect sense and I can't believe I
> missed the correct interpretation.

It makes sense but it might be hard to interpret. I've added a more
user-friendly error message now. In the above case, you should now see
this message:

 Unable to create to create boundary condition.
 Reason: Expecting a scalar boundary value but given function is
 vector-valued.

--
Anders