(1 comment)

MooseObject Constructor Change

We are updating the constructors in MOOSE, which may be the largest change to MOOSE that we have attempted. We will do our best to keep the transition seamless, but unforeseen problems are likely, so please be patient as we make these changes.

What is Changing?

The old constructors took two arguments:

MyObject(const std::string & name, InputParameters parameters);

This will be changing to:

MyObject(const InputParameters & parameters);

Notice, that the object now accepts a const reference to an InputParameters object. The InputParameter objects are now being stored in a single location and the object are provided a reference.

Why is this Changing?

There are a number of reasons this change is being made:

  1. The "name" variable is not needed, this already is stored as a parameter
  2. The InputParameters object was copied throughout the object inheritance and in some cases a single object would have multiple copies of the InputParameters.
  3. The MOOSE team is developing a "control logic" system to allow for changing parameters on the fly during a simulation. So, with this changes the parameters may be modified by the control logic system without having to access the MooseObject iteself.

How will the changes be implemented?

  1. The MOOSE framework will be updated with a second constructor and new methods for registration, the old constructors in the application objects will continue to operate but produce a warning that you are using deprecated constructors.
  2. The code in moose/test and moose/modules will be migrated to the new constructors, again two sets of constructors will exists to maintain legacy behavior.
  3. Each of the applications will be updated to utilize the new constructors and the old constructors will be removed.
  4. Upon completion of updating the applications the deprecated constructors will be removed from MOOSE and the modules.

How can I update my application?

To update your application the following steps should be followed.

1. Redefine MOOSE registration macros

Until the deprecated, two argument constructors are removed from MOOSE it is required that you update three macros within your application in order to update to the new, single argument constructors.

Note, these macro changes are temporary. When all applications are updated these macros will be able to be removed.

For example, if your application is named DungBeetle, make the following changes in your DungBeetleApp.C file located in /src/base directory.

#undef  registerApp
#define registerApp(name) AppFactory::instance().reg<name>(#name)
#undef  registerApp
#define registerApp(name) AppFactory::instance().regLegacy<name>(#name)
DungBeetleApp::registerObjects(Factory & factory)
#undef registerObject
#define registerObject(name) factory.reg<name>(stringifyName(name))

  registerDiracKernel ...

#undef registerObject
#define registerObject(name) factory.regLegacy<name>(stringifyName(name))
DungBeetleApp::associateSyntax(Syntax & syntax, ActionFactory & action_factory)

#undef registerAction
#define registerAction(tplt, action) action_factory.reg<tplt>(stringifyName(tplt), action)

  registerAction ...

#undef registerAction
#define registerAction(tplt, action) action_factory.regLegacy<tplt>(stringifyName(tplt), action)

2. Update your object constructors

After updating the macros, you now need to update the C++ constructors. To assist in this process a script is provided in the moose/scripts directory. Run the following commands to execute the script.

cd ~/projects/DungBeetle

Hopefully, this will make all the necessary changes to your application. However, it is impossible to account for all situations in a script so chances are you will need to manually fix some of your code.

Currently unrated


lw4992 1 year, 11 months ago

I like it!

Link | Reply
Currently unrated

New Comment


required (not published)


R&D 100

Recent Blog Posts

Using our new clang-format Style

3 months, 2 weeks ago

Steady State Algorithm Change

1 year ago

Making an App inherit from an App

1 year ago

Changing a published API (Deprecation)

1 year, 1 month ago

DiscreteMaterial Objects

1 year, 3 months ago

Recent Posts






RSS / Atom