(2 comments)

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.

Examples:

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

"Required value greater than 10");

// Optional parameter with no default
params.addRangeCheckedParam<Real>("some_percent", 

"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

Comments

Questions 3 years 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 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

required (not published)

optional

R&D 100

Recent Blog Posts

Using our new clang-format Style

1 month, 2 weeks ago

Steady State Algorithm Change

10 months, 3 weeks ago

Making an App inherit from an App

11 months ago

Changing a published API (Deprecation)

11 months, 1 week ago

DiscreteMaterial Objects

1 year, 1 month ago

Recent Posts

Archive

2017
2016
2015
2014

Tags

Authors

Feeds

RSS / Atom