First: A HUGE thanks to Cody for doing a lot of the C++ voodoo to make all of this work!

In the Past....

MOOSE has had support for default values for parameters for ages like so:

params.addParam<Real>("my_param", 4.0, "Some docu");

With the ability to override that default value in the input file like so:

    type = SomeKernel
    my_param = 6.4

However, "coupling" type parameters (for coupled variables, Postprocessors and Functions) have never had this kind of capability which led to "ternary operator hell" like so:

SomeKernel::SomeKernel(...) :
    _coupled_pp(isParamValid("pp") ? getPostprocessorValue("pp") : 0),
    _coupled_function(isParamValid("function") ? &getFunction("function"):NULL)

Plus all sorts of isParamValid() type action in the constructor and elsewhere to deal with the case where something wasn't provided. This is icky on multiple levels (I personally really hate the fact that you have to deal with the Function as a pointer so you can set it to NULL... and then you have to check for NULL all over the place) and so we wanted to do something better...

What have we done about it?

As of today we now support:

  1. Default values for coupled values, Postprocessors and Functions
  2. Input file overrides for all three of these.

So you can now do this in validParams():

params.addCoupledVar("coupled_var", 300, "Some variable");
params.addParam<PostprocessorName>("some_pp", 27.2, "Some Postprocessor");
params.addParam<FunctionName>("function", "45*x+sin(y)", "Some Function");

Enabling your constructor to look like this:

  : _coupled_var(coupledValue("coupled_var")),

Huge improvement! Also: check out the default for a Function: it's actually the ParsedFunction syntax!

Also, overriding any of these in the input file works as well:

    type = SomeKernel
    coupled_var = 350
    pp = 42
    function = '72*y+cos(z)'

YES you can actually pass ParsedFunction syntax to any parameter expecting a FunctionName!!

Now: stop and think about what this means for coupled variables... this means that you can easily decouple equations. In the past if you wanted to decouple equations you needed to create an AuxVariable with a value in it and then couple to that. Now you don't even have to do that! You can simply pass a constant value in to use as the coupled value! This will really help during times of debugging (and for creating tests).

We are really excited to unveil this capability... it is going to help out in SO many places. I'm going to be going through and trying to eradicate many of the ternary operators through all of the MOOSE-based code I have access to... if you have time you should to!

As always, let us know on the mailing list if something doesn't make sense!

Current rating: 5


Questions 3 years, 6 months ago

Seems we always need to get a pointer for
```_coupled_pp(isParamValid("pp") ? &getPostprocessorValue("pp") : NULL),```?

Link | Reply
Currently unrated

helper 6 months, 3 weeks ago

These will be welcome changes for me - thanks Andrew,
thanks again

Link | Reply
Currently unrated

online films 1 month ago

Terrarium tv offering lot of the movies to stream on Android,iOS mobiles.There are more Online class for Programing languages like c++ available on Terrarium tv downloader

Link | Reply
Currently unrated

Watch Movies 2 weeks, 2 days ago

Amazing! I tried terrarium tv on your recommendation and its awesome.

Link | Reply
Currently unrated

Showbox Apk 2 weeks, 2 days ago

How do you recommend Showbox? Is it better than terrarium tv app?

Link | Reply
Currently unrated

Happy New Year 2 weeks, 2 days ago

Thanks! I found my favorite movie on Terrarium TV...

Link | Reply
Currently unrated

terrarium tv apk 1 week, 5 days ago

Download terrarium tv apk for android & watch unlimited HD movies and tv shows for free.

Link | Reply
Currently unrated

Happy new year 2018 Wallpapers 1 week ago

Thanks for it

Link | Reply
Currently unrated

Happy New Year 2018 Quotes 2 days, 6 hours ago

Very informative. Thank you so much for this.

Link | Reply
Currently unrated

Happy new year 2018 wishes 2 days, 2 hours ago

very informative and cool thank you for all these information.

Link | Reply
Currently unrated

Happy new year 2018 1 day, 2 hours ago

What a wonderful article you've got right there. Thanks a bunch for sharing this informative post.

Link | Reply
Current rating: 5

New Comment


required (not published)


R&D 100

Recent Blog Posts

Using our new clang-format Style

8 months, 2 weeks ago

Steady State Algorithm Change

1 year, 5 months ago

Making an App inherit from an App

1 year, 5 months ago

Changing a published API (Deprecation)

1 year, 6 months ago

DiscreteMaterial Objects

1 year, 8 months ago

Recent Posts






RSS / Atom