PlasmaSimUQ / cerberus

MIT License
4 stars 5 forks source link

graceful error/warning when plot variable name is undefined #3

Open bezmi opened 2 years ago

bezmi commented 2 years ago

I've noticed some weirdness when defining plot['variables'] in an inputs file:

plot={
    variables={
        'charge-electron',
        'blah',
    },
    functions={},
}

We ask for a variable 'blah' that doesn't exist. Note that it is not in the {variable}-{state_name} syntax. In this case, MFP::getPlotData() will create an empty box in dat_arrays for this variable name and pass it to all of the states with the State::get_state_values() function.

None of the states will touch this box, as its name does not contain any state names. The empty box gets passed to amrex when writing the plotfile, which tries to calculate the minimum and maximum values in the box. Since the values in the box are all undefined, this function will crash randomly.

I think that we should rework how we handle the parsing of the plot variables. MFP_global should parse the variable names and store them linked to their respective states via an index. This will also allow graceful errors/warning messages when a non-existent variable is requested for plotting.

darylbond commented 2 years ago

this fix sounds good to me!