Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addCommandLineParam<MooseEnum> doesn't work as intended #26194

Closed
pak1sol opened this issue Nov 29, 2023 · 3 comments
Closed

addCommandLineParam<MooseEnum> doesn't work as intended #26194

pak1sol opened this issue Nov 29, 2023 · 3 comments
Labels
C: Framework P: normal A defect affecting operation with a low possibility of significantly affects. T: defect An anomaly, which is anything that deviates from expectations.

Comments

@pak1sol
Copy link

pak1sol commented Nov 29, 2023

Bug Description

When a MooseEnum type variable is used in params.addCommandLineParam<MooseEnum>, it seems that the command line argument cannot be properly recognized; always the default value is used no matter what value is typed in via the command line argument. Only params.addCommandLineParam<std::string> works as intended.

Steps to Reproduce

For a code snippet below,

params.addCommandLineParam<MooseEnum>("mooseenum_test", "--mooseenum-test", mooseenumTest(), "description");
...
MooseEnum test = getParam<MooseEnum>("mooseenum_test");

where

MooseEnum
mooseenumTest()
{
  return MooseEnum("a b c", "a");
}

Running below gives me a in the test variable. No matter what value is given in the command argument, always the default value is written to test.

xxx-opt --mooseenum-test b

The way to get it to work as intended is to accept the variable using the string as below.

params.addCommandLineParam<std::string>("mooseenum_test", "--mooseenum-test", mooseenumTest(), "description");
...
std::string test = getParam<std::string>("mooseenum_test");
@pak1sol pak1sol added P: normal A defect affecting operation with a low possibility of significantly affects. T: defect An anomaly, which is anything that deviates from expectations. labels Nov 29, 2023
@pak1sol
Copy link
Author

pak1sol commented Nov 29, 2023

@YaqiWang @permcody

@lindsayad
Copy link
Member

@pak1sol can you see whether #26764 takes care of your needs?

@pak1sol
Copy link
Author

pak1sol commented Feb 16, 2024

@pak1sol can you see whether #26764 takes care of your needs?

Yes, it does! Thank you!

@pak1sol pak1sol closed this as completed Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Framework P: normal A defect affecting operation with a low possibility of significantly affects. T: defect An anomaly, which is anything that deviates from expectations.
Projects
Development

No branches or pull requests

2 participants