← Back to team overview

dolfin team mailing list archive

Re: unit vectors in FFC?

 

Thanks,
we actually figured this out eventually... FacetNormal was what I was looking for (I just was confused about the python vs c++ interface).

in the end

n = FacetNormal("triangle",mesh)
L = f*v.dx(1)*dx -  f*v*n[1]*ds

works perfectly in python...

cheers
marc



On Jun 12, 2008, at 3:48 PM, Anders Logg wrote:

On Thu, Jun 12, 2008 at 02:42:12PM -0500, Matthew Knepley wrote:
On Thu, Jun 12, 2008 at 2:37 PM, Anders Logg <logg@xxxxxxxxx> wrote:
On Wed, Jun 11, 2008 at 08:11:56AM -0400, mspieg wrote:
Hi all,
is there a simple way to implement a known constant vector (e.g. the unit
vector jhat = [ 0 1]') into a FFC form?

my specific  issue is that the right hand side of my PDE looks like

-\Div f\jhat = - df/dy

where f(x,y) is a user defined scalar function (and df/dy is not easily
evaluated)

Given a test function v, the weak form (in pseudo-latex) is

\int dv/dy f dx - \int v f \jhat\dot ds

The question is how to evaluate the 2nd term in the FFC form language (the
volume integral works fine as  v.dx(1)*f*dx)

ideally something like

jhat=??
L = v.dx(1)*f*dx) - v*f*jhat*ds

(or more generally for a known unit vector k L=dot(grad(v),k) *f*dx - v*f*k*ds
)

would be nice (in the same way as simple known constants can be built in
directly)

But I'm flexible...all help greatly appreciated
marc

It looks like you expect ds to be a vector. It's not. It's a scalar.

But you can get the surface normal as a vector, right? I think that
is what Marc wants.

   Matt

Yes, just do

  n = FacetNormal(shape)

So I guess what you want to do is

  v*f*dot([0, 1], n)*ds

?

--
Anders
_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev

----------------------------------------------------
Marc Spiegelman
Lamont-Doherty Earth Observatory
Dept. of Applied Physics/Applied Math
Columbia University
http://www.ldeo.columbia.edu/~mspieg
tel: 845 704 2323 (SkypeIn)
----------------------------------------------------



References