Doc: AMREX_ENUM Functions#4764
Merged
WeiqunZhang merged 2 commits intoAMReX-Codes:developmentfrom Nov 7, 2025
Merged
Conversation
WeiqunZhang
requested changes
Nov 7, 2025
| * nonlinear | ||
| * ); | ||
| * pp_element.queryAdd("model", model_str); | ||
| * Model const model = amrex::getEnum<Model>(model_str); |
Member
There was a problem hiding this comment.
Let's avoid using ParmParse in the example, because ParmParse can read amrex_enum directly without using a string.
Member
There was a problem hiding this comment.
Or we could keep the example, but mention this is equivalent to
pp_element.queryAdd("model", model);
Member
There was a problem hiding this comment.
using namespace amrex;
AMREX_ENUM(Model, linear, nonlinear);
int main(int argc, char* argv[])
{
amrex::Initialize(argc,argv);
{
auto model = Model::linear;
ParmParse pp;
pp.queryAdd("model", model);
amrex::Print() << " model is " << amrex::getEnumNameString(model) << "\n";
model = Model::linear;
amrex::Print() << " model is " << amrex::getEnumNameString(model) << "\n";
pp.queryAdd("model", model);
amrex::Print() << " model is " << amrex::getEnumNameString(model) << "\n";
}
amrex::Finalize();
}
gives as expected when running with model="nonlinear"
model is nonlinear
model is linear
model is nonlinear
Member
There was a problem hiding this comment.
If I change the code to
{
auto model = Model::linear;
ParmParse pp;
pp.queryAdd("model", model);
amrex::Print() << " model is " << amrex::getEnumNameString(model) << "\n";
model = Model::nonlinear;
amrex::Print() << " model is " << amrex::getEnumNameString(model) << "\n";
pp.queryAdd("model", model);
amrex::Print() << " model is " << amrex::getEnumNameString(model) << "\n";
}
and run without any parameters, I get this as expected
model is linear
model is nonlinear
model is linear
ax3l
commented
Nov 7, 2025
Doxygen strings and examples :)
WeiqunZhang
reviewed
Nov 7, 2025
WeiqunZhang
approved these changes
Nov 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enum Doxygen strings and examples :)
Additional background
Checklist
The proposed changes: