2
$\begingroup$

Given a Dolfin Function u on a mesh, I'd like to check if it is greater than 0 throughout the mesh. I noticed that the expression

u > 0

is an object of the type

GT(Coefficient(FiniteElement('Lagrange', Domain(Cell('triangle', 2), 'triangle_multiverse', 2, 2), 2, None), 0), Zero((), (), {}))

How can I evaluate that thing?

$\endgroup$
3
$\begingroup$

If the function is piecewise linear, an easy check would be the following:

print u.vector().min()

This would also work as a good approximation for other spaces.

$\endgroup$
5
$\begingroup$

Looks like you're using the Python interface, in which case u is both a DOLFIN Function object and a UFL object (it inherits from both). The type information you're seeing is related to UFL.

You can evaluate the function u at an arbitrary point:

f = u((0.5, 0.5, 0.5))

if DOLFIN is configured with CGAL.

I don't know how you could check that the solution is strictly positive everywhere for arbitrary element type, but you could do a pretty good check integrating a UFL conditional,

c = conditional(lt(u, 0), 1, 0)

# This should be zero if u > 0
print assemble(c*dx)   

Conditional UFL statements are presented in http://arxiv.org/abs/1211.4047.

$\endgroup$
  • 1
    $\begingroup$ Last line should be assemble(c*dx). $\endgroup$ – Anders Logg May 9 '13 at 19:44
  • $\begingroup$ Are you shure that quadrature rule will sample every possible negative region for arbitrary element supported in FEniCS? $\endgroup$ – Jan Blechta May 12 '13 at 0:06

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.