Mesh elements aspect ratio

Hi everyone,

I have a mesh made from quad and triangle elements. I wanted to get the aspect ratio of each mesh element but I could find any native GH component. Is there a way of obtaining that value for each mesh element?

Thanks in advance!

Hi @bbalbastre,

You can use the boundingbox tool for this.


aspect ratio.gh (5.1 KB)

1 Like

Hi @Erik_Beeren1

Thank you for the answer! Which plugin are you using to get that component? And also, to get the aspect ratio I suppose I have to get the division between Dim X and Dim y, is that right?

This is what I was looking for:

Aspect Ratio Calculation for 2D Finite Elements (engmorph.com)

I also read that there is a command to get the aspect ratio although I don’t know how to make it work in Grasshopper:

MeshFaceList.GetFaceAspectRatio method (rhino3d.com)

Also this one:

Thanks again

the component used in Erik’s post should be Bounding Rectangle from Pufferfish plugin

I guess you can use the Rhinocommon GetFaceAspectRatio like this

GetFaceAspectRatio_py.gh (8.1 KB)

by the way, not entirely sure what am I seeing here :slight_smile:

this assumes all the faces are planar?

1 Like

Thanks for the answer @inno , you are always very helpful!

You make the method work! :slight_smile:

Anyway, tt seems a bit strange the values you are getting, doesn’t it? For the cube sample you should get aspect ratios close to 1, since the geometries are closed to squares

Also for the sphere, it seems that the aspect ratio provided very distorted values although the elements does not seem so

The method I provided only works for planar 2D elements, which is the case I am looking for

Not sure about what this method is doing. Are we missing something else @dale ?

something like this should retrace the very same process depicted for quads in your image (which I guess assumes all the quads are planar, otherwise things might become very weird very fast?)

I didn’t match Z axis for L1/L2 because it takes min/max regardless… so I thought you can practically just ignore Z

Quad MeshFace Aspect Ratio L1-L2.gh (19.3 KB)

1 Like

Thank you for your time @inno

I will implement also the case for triangular elements following your example.

BTW, I am just being curious about why the “get face aspect ratio” is not working in our case…

What would happen if we apply this command to the mesh cube you modelled? I suppose the method the API uses to calculate the aspect ratio is the same employed in this method so what would happen in case of applying an aspect ratio of 1?

Mesh.CollapseFacesByByAspectRatio method (rhino3d.com)

And also, do you know if it is possible to apply this command from Grasshopper?

Maybe this works in our case :slight_smile:

Hi @bbalbastre,

RhinoCalculateAspectRatio is exposed as MeshFaceList.GetFaceAspectRatio in RhinoCommon.

– Dale

1 Like

Thank you @dale . By the way, how is it possible that using that command, the aspect ratio of a square is 2.00 instead of 1.00 as @inno showed in a previous post? Can someone from McNeel take a lot at that? It seems like a bug to me @scottd @stevebaer @kike @dan @eirannejad

Are we applying the command incorrectly?

image

Thanks again!

@tim - is this something you can help with?

We use the greatest aspect ratio of the triangles that can be made from vertices of the quad. I don’t know if that’s the right thing to do, but it is what we do.

The math is trivial though, you can always write your own function to do it the way you want to.

Tim

2 Likes

Hi @tim

Thank you for your response. I really appreciate it. I understand there is a logic behind the concept you are applying to quads, which might be useful in other fields as well.

In Finite Element Models, the mesh is crucial, especially in the structural field. To ensure well-distributed forces, it’s essential to have good aspect ratios for both triangular and quadrilateral elements. For example, an equilateral triangle has an aspect ratio of 1, and a square QUAD also has an aspect ratio of 1, as these are ideal geometries.

There are many ways to calculate aspect ratios, but the two principles I mentioned earlier always apply. If you’re interested, you can find more information here:

How different simulation softwares calculates aspect ratio (engmorph.com)

I wonder if there is room in the future to implement one of these methods in Rhino since I think that would be very helpful for many people. Meanwhile, I will try to do the calculations myself since having an aspect ratio of 2 for a square QUAD element makes no sense for me.

Thanks for the information,

BR-Borja

1 Like

In case anyone is interested I developed a C# solution to calculate the aspect ratio for QUADs and triangular elements of a mesh:

  private void RunScript(Mesh M, ref object Ratio)
  {

    // Initialize a list to store the EdgeLine objects
    var RatioList = new List<double>();

    for (int i = 0; i < M.Faces.Count; i++)
    {
      var path = new GH_Path(i);
      var temp_ratios = new List<double>();
      var Mesh_Edges = new List<double>();

      // Get the edges of the current face i
      var faceEdges = M.TopologyEdges.GetEdgesForFace(i);

      foreach (var edgeIndex in faceEdges)
      {
        var edge = M.TopologyEdges.EdgeLine(edgeIndex);
        Mesh_Edges.Add(edge.Length);
      }

      // Calculate the ratio and add it to the tree
      if (Mesh_Edges.Count > 0)
      {
        double maxEdgeLength = Mesh_Edges.Max();
        double minEdgeLength = Mesh_Edges.Min();
        double ratio = maxEdgeLength / minEdgeLength;
        RatioList.Add(ratio);
      }
    }

    Ratio = RatioList;

The calculations are based in the ABAQUS software method:

Hope it helps!