Rearrange a pointer check to satisfy coverity.
Rearrange a pointer check to satisfy coverity.

Coverity (the static analysis program) raises an issue with the way we
check the result of a dynamic_cast. This commit rearranges things so
that we cannot enter the relevant block unless dynamic_cast succeeds,
regardless of the assertion.

naliboff/dealii,naliboff/dealii,naliboff/dealii,naliboff/dealii,naliboff/dealii,naliboff/dealii,naliboff/dealii