Boundary conditions for more than one variable

Asked by minak

Hi,

I would like to ask two questions on boundary conditions.

1. Is this possible to state boundary conditions for more than one variable? I mean we have
V = VectorFunctionSpace(mesh, "CG", 2)
U = VectorFunctionSpace(mesh, "CG", 2)
W = V*U

How to obtain conditition of a type u*v = 0 on boundary

DirichletBC( W.sub(0)*W.sub(1), Constant(0.0), on_boundary) ??? it works with plus + but I am not sure what is happening?

2. Imagine we have time dependent problem. How to use in boundary condition the solution from the previous time step
DirichletBC( W.sub(1), previous_solution????, on_boundary)

Thanks for any contribution,
minak

Question information

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

On Wed, Jun 27, 2012 at 04:50:57PM -0000, minak wrote:
> New question #201638 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/201638
>
> Hi,
>
> I would like to ask two questions on boundary conditions.
>
> 1. Is this possible to state boundary conditions for more than one variable? I mean we have
> V = VectorFunctionSpace(mesh, "CG", 2)
> U = VectorFunctionSpace(mesh, "CG", 2)
> W = V*U
>
> How to obtain conditition of a type u*v = 0 on boundary

That's not supported. You can set Dirichlet boundary conditions for
one variable at a time, but not in combination.

> DirichletBC( W.sub(0)*W.sub(1), Constant(0.0), on_boundary) ??? it works with plus + but I am not sure what is happening?
>
> 2. Imagine we have time dependent problem. How to use in boundary condition the solution from the previous time step
> DirichletBC( W.sub(1), previous_solution????, on_boundary)

Yes, that works fine, if previous_solution is your previous solution.

--
Anders

Revision history for this message
minak (piotrekminak) said :
#2

Thanks for the answer. Let me ask one additional question concerning point 2.

Is there a way to in the place of previous solutions put combination of previous solution current solution and so on.
e.g.
DirichletBC( W.sub(1), u_previous + dt*v_currnet, on_boundary)

and if it is not possible, I can have

DirichletBC( W.sub(1), u_previous + dt*v_previous, on_boundary)

where dt is scalar, timestep. Moreover it would be nice to change in time dt, as well.

minak

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

On 06/28/2012 12:25 PM, minak wrote:
> Question #201638 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/201638
>
> Status: Answered => Open
>
> minak is still having a problem: Thanks for the answer. Let me ask
> one additional question concerning point 2.
>
> Is there a way to in the place of previous solutions put combination
> of previous solution current solution and so on. e.g.

> DirichletBC(W.sub(1), u_previous + dt*v_currnet, on_boundary)
>
> and if it is not possible, I can have
>
> DirichletBC( W.sub(1), u_previous + dt*v_previous, on_boundary)
>
> where dt is scalar, timestep. Moreover it would be nice to change in
> time dt, as well.

You can do both. But if you are going to use the
NonlinearVariationalSolver it will be a bit tricky to implement. As in
the end what you send into DirichletBC needs to be a GenericFunction.

If you are implementing your own loop you can do:

   u_dir = Function(V)
   DirichletBC( W.sub(1), u_dir, on_boundary)

and for each timestep:

   u_dir.vector().assign(u_previous.vector())
   u_dir.vector().axpy(dt, v_currnet.vector())

If you are using the built in NewtonSolver you need to construct an
Expression that is passed to the DirichleBC, where you in the overloaded
eval method call and add the values of the two Functions.

Johan

Can you help with this problem?

Provide an answer of your own, or ask minak for more information if necessary.

To post a message you must log in.