geodynamics / aspect

A parallel, extensible finite element code to simulate convection in both 2D and 3D models.
https://aspect.geodynamics.org/
Other
227 stars 237 forks source link

Inconsistency in the meaning of "phase_index" in source/material_model/utilities.cc #6140

Open lhy11009 opened 2 weeks ago

lhy11009 commented 2 weeks ago

@gassmoeller. Hi Rene, I noticed that the variable "phase_index" is used in a couple of places in the source/material_model/utilities.cc file. First, it appears in the PhaseFunction.compute_value function as in.phase_index, where it’s used as an input. Then, it shows up in the phase_average_value function, where "phase_index" is used to loop over all the phases.

From the way these variables interact with phase_function_values, it seems like they might have slightly different meanings—one potentially indicating the index of the phase transition and the other referring to the index of the phase. In the first case, here is a piece of the code link

      for (unsigned int j=0; j < phase_function.n_phase_transitions(); ++j)
        {
          phase_inputs.phase_index = j;
          phase_function_values[j] = phase_function.compute_value(phase_inputs);
        }

And in the second case link

                averaged_parameter += phase_function_values[phase_index-composition_index] * (std::log(parameter_values[phase_index+1]) - averaged_parameter);

Does this interpretation align with your understanding as well? If so, perhaps we could rename in.phase_index to in.phase_transition_index for clarity.