MOOSE News (April 2019)

MooseIndex type

Have you ever written a for loop like this?

for (unsigned int i = 0; i < vector.size(); ++i)

If so, you may have inadvertently created a bug as we continue to scale MOOSE up! Some of our bigger simulations are routinely reaching well into the millions of elements and tens of millions of DOFs. While you may never loop over every single element or DOF directly, there are still cases where you are processing information that exceeds the storage capacity of unsigned int. For a long time, we've tried to make it easier to deal with all of the different integer types that you may encounter in a for loop and we've decided to make it foolproof for you.

We now have MooseIndex, which is always the right type (sign and size) to use it, simply pass the instance you are looping to as an argument and it'll return the right type. Note that you should only be using index based counters where range-based counters won't met your needs.

for (MooseIndex(some_vector) i = 0; i < some_vector.size(); ++i)

for (MooseIndex(num_values) i = 1; i < num_values; ++i)

Additionally a new "enumerate" function was added to MOOSE that is forwards compatible with C++17 structured binding. You may use this method if you need both the index and the value in a loop.

#include "Enumerate.h"

for (auto it : Moose::enumerate(values))
  _console << it.index() << ": " << it.value() << '\n';

Miscellaneous enhancements and bug fixes

  • There is now an automatic differentiation version of the incompressible Navier Stokes equations

  • The documentation for Postprocessors was improved: Postprocessor System.

  • Scalar Variable values can now be read as an initial condition from an exodus file.

  • Better formatting of solver norms when using ReferenceResidualProblem.

  • Several GCC 8 fixes and LLVM 6 fixes in preparation for the next compiler package.

  • Improved Code Coverage reporting (Headers now included)

  • Header symlinking can be turned off by exporting MOOSE_HEADER_SYMLINKS=false in your environment