On 22 Sep 2015, at 20:07, Justin Chang <jychang48@gmail.com> wrote:

Oh okay I did not realize there was a TensorFunctionSpace(). Though if this is the way to go:

eps = 0.001
D = TensorFunctionSpace(mesh,"CG",1)
D.interpolate(Expression(("x[1]*x[1]+eps*x[0]*x[0]","-(1-eps)*x[0]*x[1]","-(1-eps)*x[0]*x[1]",""x[0]*x[0]+eps*x[1]*x[1]",eps=eps)))

I get an error saying TensorFunctionSpace object has no attribute interpolate


You'll need to build a Function on D and interpolate onto that. 

diffusivity = Function(D)
diffusivity.interpolate(...)


The other thing you can do is:

eps = Constant(val)
coords = mesh.coordinates
x = coords[0]
y = coords[1]

D = as_tensor([[y**2 + eps*x**2, -(1-eps)*x*y],
                -(1-eps)*x*y, eps*y**2 + x**2]])

Now you can use D in your variation all form as a 2x2 tensor. 

Note that this may blow up the estimated quadratic equation degree a bit too much as opposed to Andrew's solution. 

Lawrence
On Tue, Sep 22, 2015 at 12:55 PM, Andrew McRae <A.T.T.McRae@bath.ac.uk> wrote:
5) For an anisotropic diffusion problem, I would like to use this diffusivity tensor:

D(x) = [y^2+eps*x^2, -(1-eps)*x*y; 
            -(1-eps)*x*y, eps*y^2+x^2]

where eps is a user-defined scalar, and x and y correspond to the x and y coordinates of the cell. How would I express that?

How does this behave within a cell?  Is it constant on each cell?  Should it vary linearly/quadratically/...?

Presumably just make a TensorFunctionSpace of the right type, and interpolate an Expression in the usual way.  I *think* you need an Expression of length 4, as if the tensor was flattened.
 

Thanks,
Justin

On Tue, Sep 22, 2015 at 12:18 PM, Andrew McRae <A.T.T.McRae@bath.ac.uk> wrote:
4) Do you guys support Hexahedron elements? When I look through the documentation for UnitCubeMesh and BoxMesh, I see no option for non-tetrahedron elements.

We support semi-structured hexahedral meshes, though not *fully* unstructured.  One has to go via the ExtrudedMesh functionality to get these.

For example, to quote Henrik in a different mailing list thread,

meshbase = RectangleMesh(Nx, Ny, Lx, Ly, quadrilateral=True)
mesh = ExtrudedMesh(meshbase, Nz, Delta_z)


Or you can supply your own base quadrilateral mesh:
m = Mesh("quadmesh.msh")
mesh = ExtrudedMesh(m, ...)

For element families supported, see http://femtable.org/ to start with.

If your cells aren't perfect cuboids then some approximations are made in the quadrature calculations; if this seems to be hurting you badly then I can give further instructions.

_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake




_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake


_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake