This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Derivative of trial function 2D scalar problem

+2 votes

Hello,

I am working on a 2D scalar field problem (like temperature) and I was wondering if there was a way to take the derivative of the trial function for only one direction. For my problem, when converting the strong form into the weak (variational) form, one of the terms is an integral of the form

∫<!-- ∫ --> ∂<!-- ∂ --> T ∂<!-- ∂ --> z d s

I've come up with a work around but I was wondering if there was a more straightforward or preferred method. The way I have it now is to define a vector function space, create a variable n that is only equal to one in one direction and perform the dot product of n with grad(T)

W = VectorFunctionSpace(mesh, "P", 2)
n = Function(W)
n.assign(Constant((0, 1)))
b = dot(grad(T), n) * ds(1)

Also, ds is only in the z direction.

asked Feb 22, 2017 by dbfox FEniCS Novice (240 points)

1 Answer

+1 vote
 
Best answer

Consider:

grad(T)[1]

or

Dx(T, 1)

or

T.dx(1)
answered Feb 23, 2017 by nate FEniCS Expert (17,050 points)
selected Feb 23, 2017 by dbfox

Thanks, all these methods worked!

...