Using solution to define dirichlet BC

Asked by Praveen C

Hello

I solve a Stokes problem and get velocity (u) and pressure (p). Now using this (u,p) I want to define DirichletBC for a new Stokes problem

n = FacetNormal(mesh)
g = p*n - grad(u)*n

but I am not able to use "g" in a DirichletBC. Is there a solution to this ?

praveen

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
Johan Hake (johan-hake) said :
#1

On Mar 19, 2012 3:45 PM, "Praveen C" <email address hidden>
wrote:
>
> New question #191109 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/191109
>
> Hello
>
> I solve a Stokes problem and get velocity (u) and pressure (p). Now using
this (u,p) I want to define DirichletBC for a new Stokes problem
>
> n = FacetNormal(mesh)
> g = p*n - grad(u)*n

try:

g=project( p*n - grad(u)*n)

johan

> but I am not able to use "g" in a DirichletBC. Is there a solution to
this ?
>
> praveen
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.

Revision history for this message
Praveen C (cpraveen) said :
#2

I tried project but it gives me errors. I have made a simple case of my problem below. If I do not involve the FacetNormal in the definition of "lam" then it works. How does the projection work when FacetNormal is involved ?

praveen

from dolfin import *

K = Constant(1.0)
alpha = 1.0

# Create mesh and define function space.
mesh = UnitSquare(10,10)
V = VectorFunctionSpace(mesh,"CG", 2)
Q = FunctionSpace(mesh,"CG", 1)
W = V * Q
n = FacetNormal(mesh)

# Boundaries
def bdry(x, on_boundary): return on_boundary

# Boundary condition for velocity
noslip = Constant((0,0))
bcs = DirichletBC(W.sub(0), noslip, bdry)

# Define Variational Problem
(u, p) = TrialFunctions(W)
(v, q) = TestFunctions(W)
test = Function(W)

F = Constant((0.0,0.0))
a = pow(alpha, 2.0)* inner(grad(u), grad(v))*dx \
   + div(v)*p*dx + q*div(u)*dx \
   + 1e-10*p*q*dx
L = inner(F, v)*dx

solve(a==L, test, bcs)
(ue, pe) = test.split(True)
#plot(ue)
#plot(pe)
#interactive()

lam = pe*n - pow(alpha,2.0)*grad(ue)*n
gmod = (1.0/K) * lam
g = project(gmod, V)

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

Facet normals can only be used in facet integrals. ffc lack a proper
error message for that. A bug is filed:

   https://bugs.launchpad.net/ffc/+bug/960000

Johan

On 03/20/2012 05:50 AM, Praveen C wrote:
> Question #191109 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/191109
>
> Status: Answered => Open
>
> Praveen C is still having a problem: I tried project but it gives me
> errors. I have made a simple case of my problem below. If I do not
> involve the FacetNormal in the definition of "lam" then it works. How
> does the projection work when FacetNormal is involved ?
>
> praveen
>
> from dolfin import *
>
> K = Constant(1.0) alpha = 1.0
>
> # Create mesh and define function space. mesh = UnitSquare(10,10) V =
> VectorFunctionSpace(mesh,"CG", 2) Q = FunctionSpace(mesh,"CG", 1) W =
> V * Q n = FacetNormal(mesh)
>
> # Boundaries def bdry(x, on_boundary): return on_boundary
>
> # Boundary condition for velocity noslip = Constant((0,0)) bcs =
> DirichletBC(W.sub(0), noslip, bdry)
>
> # Define Variational Problem (u, p) = TrialFunctions(W) (v, q) =
> TestFunctions(W) test = Function(W)
>
> F = Constant((0.0,0.0)) a = pow(alpha, 2.0)* inner(grad(u),
> grad(v))*dx \ + div(v)*p*dx + q*div(u)*dx \ + 1e-10*p*q*dx L =
> inner(F, v)*dx
>
> solve(a==L, test, bcs) (ue, pe) = test.split(True) #plot(ue)
> #plot(pe) #interactive()
>
> lam = pe*n - pow(alpha,2.0)*grad(ue)*n gmod = (1.0/K) * lam g =
> project(gmod, V)
>

Can you help with this problem?

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

To post a message you must log in.