Visualize particles p_set or material_id

Hi everyone,

I’m currently working with two sets of particles I’ve defined in the entity_sets file. Then I define for each pset_id a different material_id. I use material_sets option to do this.

"material_sets": [
    {
        "material_id": 0,
        "pset_id": 0
    },
    {
        "material_id": 1,
        "pset_id": 1
    }
],

My question is about how to view the pset_id or material_id in paraview. I would like to return the material_id or pset_id in the vtk file in order to separate the particules. I wonder if the vtk_statevars could be used for this. I found that material_id is in this case returned in the hdf5 particle file. So I try to export this fonctionnality with vtk_statevars but It doesn’t work and return NaN values.

    "vtk_statevars": [
        {
            "phase_id": 0,
            "statevars": [
                "material_id"
            ]
        }

Has anyone found a way to do this yet?

Hi @mardvd,

Its a bit difficult to list the available statevars since each material model offers different state variables (based on the formulation, etc.) and they are not necessarily useful parameters (e.g. internal model parameters).

I think the quickest way to determine the available statevars is just by looking at the material file you’re using. For example, in Mohr-Coulomb, there are 7 state variables to select from (see here) vs. 18 state variables in Modified Cam Clay (see here). I’m unaware of a material model that offers "material_id" as a state variable.

Its not too difficult to add material_id as state variable for any given material model. Below is what I would add to the bottom of the initialise_state_variables() function in Mohr-Coulomb (here).

//! Initialise state variables
template <unsigned Tdim>
mpm::dense_map mpm::MohrCoulomb<Tdim>::initialise_state_variables() {
  mpm::dense_map state_vars = {// MC parameters
                               ...
                               // Material id
                               {"material_id", this->id_}};
  return state_vars;
}

Then you should be able to use

    "vtk_statevars": [
        {"phase_id": 0, "statevars": ["material_id"]}
    ]

to get the material id as a vtk file.

Warning: I only quickly verified this approach for a model with a single material, but I expect it will be ok for models with multiple materials.
Edit: this approach works for a simple 2 material model on my end.

1 Like

Thanks a lot @jgiven100 it works great!

1 Like