grinsfem / grins

Multiphysics Finite Element package built on libMesh
http://grinsfem.github.io
Other
47 stars 39 forks source link

Add assert for non-physical quantities #191

Open nicholasmalaya opened 9 years ago

nicholasmalaya commented 9 years ago

For some simulations I get non-physical quantities, typically, temperatures that are way below the lowest temperature b.c. in the simulation. This is likely due to undestabilization/under-resolution. Would be nice if we could tell the simulation to die if this was detected.

After talking with Paul, it seems that the best course might be to assert T < Tmin with Tmin defaulting to 0. Would only be enabled in dbg and devel that way. The downside is this could be triggered when we're close, due to numerical error, e.g. FD Jacobians so it's like -1.0e-7 or something.

Short term, this can be accomplished by adding a libmesh_assert_less_than( T, min_value ) in HeatTransfer.C::element_time_derivative

However, I wanted to document this here to start a discussion on possible approaches.

roystgnr commented 9 years ago

Let's default Tmin to numeric_limits::min(), so this is only on if requested?

Otherwise, yes, I don't see any better way to do it than an assert in dbg/devel mode.

pbauman commented 9 years ago

Other other thought I had was that we could define a different macro that got triggered by a configure time option. E.g. grins_assert_value_less_than(), etc. This way, we could also enable in opt mode as well.

The more I think about it, the more I like this option.

roystgnr commented 9 years ago

I don't like that macro name (the "assert" still suggests "not in opt mode" to me) but I do like the idea of potentially-in-opt-mode assertions as long as they're configured off-in-opt-mode by default.

pbauman commented 9 years ago

grins_value_less_than() etc.?