Subject: [FFC-dev] mean() for vectors

From: "Johan Hoffman" <[email-masked]>
Date: Wed, 21 Dec 2005 13:28:46 +0100 (MET)

Anders,

Is the mean() function in FFC not supported for vector functions? Or am I
missing something?

/Johan

na41>ffc Poisson.form
This is FFC, the FEniCS Form Compiler, version 0.2.4.
For further information, go to http://www/fenics.org/ffc/.
Parsing Poisson.form
Output written to Poisson.py

Compiling form: (dXa0/dx0)(dXa1/dx0) | ((d/dXa0)vi0)*((d/dXa1)vi1)*dX +
(dXa0/dx 1)(dXa1/dx1) | ((d/dXa0)vi0)*((d/dXa1)vi1)*dX
Finite element of test space:  Lagrange finite element of degree 1 on a
Triangle  with 1 components
Finite element of trial space: Lagrange finite element of degree 1 on a
Triangle  with 1 components
Compiling tensor representation for interior
Hard signatures match for terms 0 and 1, factorizing
Computing reference tensor, this may take some time...
................................................................................
Reference tensor computed in 0.00739 seconds.
Compiling tensor representation for boundary
Hard signatures match for terms 0 and 1, factorizing

Compiling form: w0_a0 | vi0*va0*dX
Finite element of test space:  Lagrange finite element of degree 1 on a
Triangle  with 1 components
Finite elements for functions: [Lagrange finite element of degree 1 on a
Triangl e with 1 components]
Compiling tensor representation for interior
Computing reference tensor, this may take some time...
................................................................................
Reference tensor computed in 0.012 seconds.
Compiling tensor representation for boundary

Generating output for DOLFIN
Output written to Poisson.h
na41>cd
na41>cd local/dolfin/src/modules/navierstokes/dolfin/
na41>ffc NSEContinuity.form
This is FFC, the FEniCS Form Compiler, version 0.2.4.
For further information, go to http://www/fenics.org/ffc/.
Parsing NSEContinuity.form
Output written to NSEContinuity.py

*** Error at w0_a69 | va69[a7]
*** Mean values are only supported for Functions.

# Copyright (c) 2005 Johan Hoffman ([email-masked])
# Licensed under the GNU GPL Version 2
#
# The contiuity equation for the incompressible
# Navier-Stokes equations using cG(1)cG(1)
#
# Compile this form with FFC: ffc NSEContinuity.form.

name = "NSEContinuity"
#scalar = FiniteElement("Lagrange", "triangle", 1)
#vector = FiniteElement("Vector Lagrange", "triangle", 1)
#constant_scalar = FiniteElement("Discontinuous Lagrange", "triangle", 0)
#constant_vector = FiniteElement("Discontinuous vector Lagrange",
"triangle", 0)
scalar = FiniteElement("Lagrange", "tetrahedron", 1)
vector = FiniteElement("Vector Lagrange", "tetrahedron", 1)
#constant_vector = FiniteElement("Discontinuous vector Lagrange",
"tetrahedron", 0)
constant_scalar = FiniteElement("Discontinuous Lagrange", "tetrahedron", 0)

q            = BasisFunction(scalar)
p            = BasisFunction(scalar)
#um           = Function(constant_vector)
uc           = Function(vector)
f            = Function(vector)

delta1       = Function(constant_scalar)        # stabilization

i0 = Index()
i1 = Index()
i2 = Index()

a = delta1*dot(grad(q), grad(p))*dx;
L = delta1*dot(grad(q), f)*dx - q*uc[i0].dx(i0)*dx -
delta1*q.dx(i0)*mean(uc[i1])*uc[i0].dx(i1)*dx
#L = delta1*dot(grad(q), f)*dx - q*uc[i0].dx(i0)*dx -
delta1*q.dx(i0)*um[i1]*uc[i0].dx(i1)*dx

#a = delta1*q.dx(i0)*p.dx(i0)*dx
#L = delta1*q.dx(i0)*f[i0]*dx - delta1*q.dx(i0)*uc[i1]*uc[i0].dx(i1)*dx -
q*uc[i0].dx(i0)*dx

---

From: Anders Logg <[email-masked]>
Date: Wed, 21 Dec 2005 08:32:20 -0600

Yes, it should be supported for vector-valued Functions, but it's not
supported for general expressions:

	  mean(f)       # ok
	  mean(f + g)   # not ok
	  mean(grad(f)) # not ok	  

How have you used it in the form? If it's just mean(f) where f is a
vector-valued function, then it should work.

/Anders

On Wed, Dec 21, 2005 at 01:28:46PM +0100, Johan Hoffman wrote:
> _______________________________________________
> FFC-dev mailing list
> [email-masked]
> http://www.fenics.org/cgi-bin/mailman/listinfo/ffc-dev
> 

-- 
Anders Logg
Research Assistant Professor
Toyota Technological Institute at Chicago
http://www.tti-c.org/logg/

---

From: "Johan Hoffman" <[email-masked]>
Date: Wed, 21 Dec 2005 15:55:40 +0100 (MET)

I used it componentwise: mean(uc[i1])

Is that ok?

/Johan

-- 
Johan Hoffman, PhD
Assistant Professor
School of Computer Science and Communication
Royal Institute of Technology KTH
SE-100 44 Stockholm
Sweden

Email: [email-masked]
URL: www.nada.kth.se/~jhoffman

---

From: Anders Logg <[email-masked]>
Date: Wed, 21 Dec 2005 08:59:10 -0600

You need to do mean(uc)[i1] or better still something like

    ucbar = mean(uc)

and then use ucbar instead of uc.

This is because the mean is computed as a projection of the Function,
meaning that a new Function expanded in a new basis (piecewise
constants) is computed by a linear transformation of the coefficients
for the original Function, so you can't take the projection of
individual components (in general).

/Anders

---

From: "Johan Hoffman" <[email-masked]>
Date: Wed, 21 Dec 2005 16:05:58 +0100 (MET)

I see. Thanks!

/Johan

>> >> Is the mean() function in FFC not supported for vector functions? Or
>> am
>> >> I
>> >> missing something?
>> >>
>> >> /Johan
>> >>
>> >>
>> >>
>> >>
>> >> na41>ffc Poisson.form
>> >> #constant_scalar = FiniteElement("Discontinuous Lagrange",
>> "triangle",
>> >> 0)
>> >> constant_scalar = FiniteElement("Discontinuous Lagrange",
>> "tetrahedron",
>> >> 0)
>> >>
>> >> #L = delta1*q.dx(i0)*f[i0]*dx -
>> delta1*q.dx(i0)*uc[i1]*uc[i0].dx(i1)*dx
>> >> -
>> >> q*uc[i0].dx(i0)*dx
>> >>
>> >>
>> >>
>> >>
>> >>