Grain boundaries


I have cell data which correspond to grains. I would like to outline the edges that share 2 different grain IDs, a.k.a. grain boundaries.

I did an example (see picture) with 1 grain. I did:

threshold of 1 grain + feature edge view representation

I am not willing to do this by brute force (going 1 by 1). I am wondering if there is a simple solution to do this.

Many thanks,

This is very nice looking ! Thanks for sharing.

As for your question, I’m afraid there is no better way to do that currently.

An alternative could be to use the “DigitalRockPhysics” plugin and its “ExplodeMaterialClusters” filters.
See here for more info, it should work in 2D too.

Hi, I had the same problem. I hope you find a solution.

Finally, I used python shell to loop on the thereshold-FeatureEdge procedure to extract the grain boundaries.



what we did was:

  1. calculate the points where the boundaries are.
  2. Construct ‘quad’ elements in VTK using the previous points.
  3. Visualize them as feature edges

We also upgrade it to 3D. Also vectorize it, avoiding loops and making it a bit more efficient.

If needed, let me know and i can send the code.


Dear Fran,

I would be interested in the code, I am trying to visualize a similar structure. That would be very appreciated.

Best wishes
Frank (1.8 KB)

Hello, here the code. It uses functions from modules of DAMASK ( Files · v3.0.0-alpha3 · damask / DAMASK · GitLab (

Something like this would be the work flow.
file = Grid.load(ref_path/‘get_grain_boundaries_8g12x15x20.vtr’)
GB = file.get_grain_boundaries(periodic=True,direction=‘xyz’)’get_grain_boundaries_8g12x15x20_{direction}_{periodic}.vtu’,parallel=False)