← Back to team overview

dolfin team mailing list archive

[Question #102925]: operator that depends on the gradient of a function

 

New question #102925 on DOLFIN:
https://answers.launchpad.net/dolfin/+question/102925

I cannot figure out how to fix the following problem...  In the following code I would like to modify sigma so that it defines an operator from u to a vector in R^2 in the following way...

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

so that sigma returns something different if the gradient of u in the y direction has magnitude less than 1 (at each point in the domain).  I suspect there is a problem with "abs(u.dx(1)) < 1"

---------------------------------------
mesh = UnitSquare(n, n)
V = FunctionSpace(mesh, "CG", 1)

...

# 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
a = dot(grad(u), grad(v))*dx
L = dot(sigma(uold),grad(v))*dx


-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.



Follow ups