6
$\begingroup$

I need to solve the following equation in FEniCS: $$ \boldsymbol{\nabla} \cdot \begin{pmatrix} f(y)\frac{\partial u}{\partial x} - g(x,y)\frac{\partial u}{\partial y} \\ - g(x,y)\frac{\partial u}{\partial x}+f(x)\frac{\partial u}{\partial y} \end{pmatrix}=0. $$ As far as I understand, the weak form will look like: $$ \int_{\Omega} \begin{pmatrix} f(y)\frac{\partial u}{\partial x} - g(x,y)\frac{\partial u}{\partial y} \\ - g(x,y)\frac{\partial u}{\partial x}+f(x)\frac{\partial u}{\partial y} \end{pmatrix} \cdot \nabla v \, \mathrm{d}x = 0 \quad \forall v \in V. $$ I have problems expressing this equation in FEniCS. I figured I need something like this:

u = TrialFunction(V)
v = TestFunction(V)
g = as_vector((u.dx(0), u.dx(1))) # <-- modify here?
a = dot(g, grad(v))*dx
u = Function(V)
solve(a == Constant(0) * v * dx, u, bc)

How to add something that depends on coordinates $x$, $y$ to the variable g above?

Also do I have to write Constant(0) * v * dx as the right part? Can it be just 0?

$\endgroup$
8
$\begingroup$
x = V.cell().x

then use x[0] and x[1] as $x$ and $y$ respectively.

Right-hand side of LinearVariationalProblem needs to be rank 1 form - this is expressed by dependendnce on TestFunction and independence on TrialFunction.

$\endgroup$
  • $\begingroup$ This doesn't work anymore in the new FEniCS. $\endgroup$ – facetus Nov 1 '18 at 17:53
  • $\begingroup$ @facetus since this is related to the working of a library, it is best to ask this question on the fenics forum or google group. $\endgroup$ – cpraveen Nov 3 '18 at 4:36
  • $\begingroup$ I know. But other people who can try to look here for an answer don't. $\endgroup$ – facetus Nov 3 '18 at 4:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.