pecos / tps

Torch Plasma Simulator
BSD 3-Clause "New" or "Revised" License
8 stars 2 forks source link

Change of solution variables for restart file (and paraview) #84

Open dreamer2368 opened 2 years ago

dreamer2368 commented 2 years ago

Currently, void M2ulPhyS::initSolutionAndVisualizationVectors() is saving primitive variables (rho, u, v, w, p) in restart file and visualization. As a result, reading a restart file requires conversion from primitive to conserved variables in void M2ulPhyS::restart_files_hdf5(string mode) and void M2ulPhyS::read_restart_files(). Can we just store conserved (or solution) variables, since this conversion will change as we add more physics into it. Adding multiple species changes pressure evaluation. Adding two temperature will also change it again. And we will have to fix this part every time we need to add physics. Keeping this will be inefficient not only for computation but also for code development.

If primitive variables are something useful to see, It would be good to include them as additional variables for visualization, but not solution variables.

marc-85 commented 2 years ago

Primitive variables are definitely useful variables since we understand flow in terms of pressure, velocity and density. They are also quantities that people doing experiments usually measure. So I have a strong preference for them to stay in the output.

I do agree, however, that restart is going to be more challenging in future models so maybe we can also output primitive variables.

koomie commented 2 years ago

I agree with @marc-85. We almost certainly need to continue to maintain a way to visualize/interrogate primitive variables for validation efforts. If we were to only dump conserved quantities, we would then have to move that conversion to a separate post-processing step which is probably not what want to have to do (and then introduces an additional place to have model mismatch). You could dump both sets of quantities, but that inflates the size of the restart files and doesn't reduce the need to convert to primitive variables.

Nonetheless, we will need/want a much more generic routine that can convert between primitive/state variables and this should be managed by a forthcoming general gas mixture class which knows the underlying modeling being used (ideal gas, 2T, etc).

dreamer2368 commented 2 years ago

I agree that we need a generic routine for primitive<->state variable conversion and use it for io.

One question is, should the restart file always use the same variables as for visualization? If this is something limited by mfem capability, then I guess there is nothing we can do and we should keep the conversion to primitive variables.

koomie commented 2 years ago

One question is, should the restart file always use the same variables as for visualization? If this is something limited by mfem capability, then I guess there is nothing we can do and we should keep the conversion to primitive variables.

The restart capability is of our own creation so we can do what we want and save want we want here. But as mentioned above, we need to be able to output primitive variables at some point anyway. Presently we are writing things twice (one for the paraview output and one for HDF5). I'd like to get away from that and do visualization directly from the .h5 files at some point. If we absolutely had to write both primitive/conserved quantities to .h5, we certainly can, but it doesn't seem to really be necessary to me. After all, if a restart can't work with primitive or conserved variables, that means there is a bug-a-boo converting between the two variants.