# user-defined vector valued function

Asked by Richard Norton on 2010-02-23

Given a function u (u=Function(V) where V = FunctionSpace(mesh, "CG", 1)) I want to define an operator/function that returns sigma(grad(u)) where sigma_1(a,b) = a and sigma_2(a,b) = 2(b^2-1)b.

I then want to include "sigma" in the following

## Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Garth Wells
Solved:
2010-03-04
Last query:
2010-03-04
2010-02-26
 Garth Wells (garth-wells) said on 2010-02-23: #1

Richard Norton wrote:
> New question #102159 on DOLFIN:
>
> Given a function u (u=Function(V) where V = FunctionSpace(mesh, "CG",
> 1)) I want to define an operator/function that returns sigma(grad(u))
> where sigma_1(a,b) = a and sigma_2(a,b) = 2(b^2-1)b.
>

I don't follow what you're after. What are (a,b)? What are sigma_1 and
sigma_2? Are they the components of sigma?

Garth

> I then want to include "sigma" in the following
>
>
>
>

 Richard Norton (norton) said on 2010-02-25: #2

Sorry... in mathematical terms, sigma is a vector field from R^2 to R^2. It maps (a,b) to (a,2(b^2-1)b) for real numbers a and b. So yes, sigma_1 and sigma_2 are the two components of sigma. I want to define an expression or function (called "sigma") so that the following code makes sense...

# Test and trial functions
v = TestFunction(V)
u = TrialFunction(V)
uold = Function(V)

????

# Variational problem

 Garth Wells (garth-wells) said on 2010-02-26: #3

On Thu, 2010-02-25 at 11:28 +0000, Richard Norton wrote:
> Question #102159 on DOLFIN changed:
>
>
> Richard Norton is still having a problem:
> Sorry... in mathematical terms, sigma is a vector field from R^2 to R^2.
> It maps (a,b) to (a,2(b^2-1)b) for real numbers a and b. So yes,
> sigma_1 and sigma_2 are the two components of sigma. I want to define
> an expression or function (called "sigma") so that the following code
> makes sense...
>

Try this:

# Test and trial functions
v = TestFunction(V)
u = TrialFunction(V)
uold = Function(V)

def sigma(u):
return as_vector( [u.dx(0), 2*(u.dx(1)**2 -1)*u.dx(1)] )

# Variational problem

Garth

>
>
>
> # Test and trial functions
> v = TestFunction(V)
> u = TrialFunction(V)
> uold = Function(V)
>
> ????
>
> # Variational problem