MOOSE now supports range checked parameters. We use the builtin fparser from libMesh so that we can handle very simple to very complex expressions. A full HTML reference of the syntax can be found here.


// Required parameter
params.addRequiredRangeCheckedParam<int>("required_val", "required_val>10", 

"Required value greater than 10");

// Optional parameter with no default

"some_percent>=0 & some_percent<=100", 

"The percentage of some parameter");

// Optional parameter with default
params.addRangeCheckedParam<unsigned int>("pos_value", 5, "pos_value>0", 

"Some positive value (Default: 5)");
  • The name of the parameter is used in the Boolean expression.

  • The most common ranges will be some combination of a lower and/or and upper bound. The example above illustrates that case using the proper AND operator. Note the slight difference from C++ syntax in the expression. The logical operators (&, |, !) use only a single character instead of two.

  • All parameters are currently checked during the parsing phase

Currently unrated


Questions 3 years, 4 months ago

Two questions:

1. Can I check one parameter is always greater than another parameter? Both parameters are the valid parameters of the same class.

2. Can I check when a userobject or an aux kernel is executed? For example, I may need a userobject to be executed only on residual.

This functionality is very useful.

Link | Reply
Currently unrated

Cody Permann 3 years, 4 months ago

1. Currently no, but this is not very far away from the current implementation. I'll add a ticket and finish this up in the near future.

2. Checking for values in enumerations isn't a goal of the range checker. The best way to handle this case is to restrict the values in your MooseEnum to begin with. Then they'll be checked automatically.

Link | Reply
Currently unrated

New Comment


required (not published)


R&D 100

Recent Blog Posts

Using our new clang-format Style

5 months, 1 week ago

Steady State Algorithm Change

1 year, 2 months ago

Making an App inherit from an App

1 year, 2 months ago

Changing a published API (Deprecation)

1 year, 2 months ago

DiscreteMaterial Objects

1 year, 5 months ago

Recent Posts






RSS / Atom