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

Use of conditionals evaluated with the unknown variable.

0 votes

I'd like to create a Neumann boundary condition that is different depending on the magnitude of the unknown variable.

Now, if u is the unknown of the system, I want something like

Q   = FunctionSpace(mesh, 'CG', 1)
u   = TrialFunction(Q)
v   = TestFunction(Q)
u_m = interpolate(Expression("pow(x[0],2)"), Q)
g_b = conditional( lt(u, u_m), 200.0, 0.0)

F   = inner(grad(v), grad(u))*dx + g_b*v*ds

solve(lhs(F) == rhs(F))

Of course, when solving this, I get the error

raise ArityMismatch("Integrand arguments {0} differ from form arguments {1}.".format(args, arguments))

Is there some other _smart_ way of doing this (besides fixed-point iteration) that anyone knows about?

Thanks!

asked Oct 20, 2015 by pf4d FEniCS User (2,970 points)

1 Answer

0 votes
 
Best answer

Make u a Function instead of TrialFunction, and use solve(F == 0) to invoke the nonlinear Newton solver?

answered Oct 22, 2015 by martinal FEniCS User (2,800 points)
selected Dec 9, 2015 by pf4d

That might be a _naive_ way of doing this and not the smart way you're looking for.

Yeah, i just now noticed that you answered this question -- I had the same idea, and yeah, it'll work that way.

...