A comparison of mesh generators.

Overview

Mesh Generator Comparison

This repository creates meshes of the same domains with multiple mesh generators and compares the results. The used mesh generators are

For each domain and mesh generator (if applicable), the repostory shows the following data:

  • the mesh generation time
  • the average and minimum cell quality
  • the nummber of CG iterations for the FEM-Poisson-problem on the mesh.

If you'd like to see other mesh generators, domains, or quality measures: Let me know!

Disk

alt text
alt text alt text

L-shape

alt text
alt text alt text

Rectangle with refinement

alt text
alt text alt text

Quarter annulus

alt text
alt text alt text

Sphere (surface)

alt text
alt text (Poisson problem not applicable.)

Ball

alt text
alt text alt text

Cylinder

alt text
alt text alt text

L-shape in 3D

alt text
alt text alt text

Box with refinement

alt text
alt text alt text

License

This software is published under the GPLv3 license.

Comments
  • cylinder benchmark suggestion?

    cylinder benchmark suggestion?

    • Cylinders are pretty common in FEM analysis and would be a nice additional benchmark for 3D.
    # Mesh a cylinder
    from mpi4py import MPI
    import meshio
    
    import SeismicMesh
    
    comm = MPI.COMM_WORLD
    
    hmin = 0.10
    
    cylinder = SeismicMesh.Cylinder(h=1.0, r=0.5)
    
    points, cells = SeismicMesh.generate_mesh(
        domain=cylinder,
        edge_length=hmin,
    )
    
    points, cells = SeismicMesh.sliver_removal(
        points=points,
        domain=cylinder,
        edge_length=hmin,
    )
    
    if comm.rank == 0:
        meshio.write_points_cells(
            "Cylinder.vtk",
            points,
            [("tetra", cells)],
            file_format="vtk",
        )
    
    opened by krober10nd 8
  • L-shaped in SeismicMesh

    L-shaped in SeismicMesh

    Adding L-shaped domains for SeismicMesh 3.0.5. The 3D L-shaped domain indeed has some trouble with the pockets between SDFs so that remains to be improved but it's a valid mesh with a bounded minimum dihedral angle.

    Note: min() and max() of two SDFs do not always produce a valid SDF. The result is actually not a distance field, but just a lower bound to the real distance to the resulting surface. Here I use the union to approximate the domain which results in errors "deep" in the interior of the geometry but this okay for meshing in these examples...

    • 2D
     import numpy as np
     import meshio
     from SeismicMesh import Rectangle, generate_mesh, geometry
     
     hmin = 0.05
     bbox = (0.0, 1.0, 0.0, 1.0)
     
     
     bbox0 = (0.0, 1.0, 0.0, 0.5)
     rect0 = Rectangle(bbox0)
     
     bbox1 = (0.0, 0.5, 0.0, 1.0)
     rect1 = Rectangle(bbox1)
     
     
     corners = geometry.corners
     
     
     def union(x):
         return np.minimum.reduce([rect0.eval(x), rect1.eval(x)])
     
     
     pfix = np.vstack((corners(bbox0), corners(bbox1)))
     
     points, cells = generate_mesh(
         bbox=bbox,
         domain=union,
         edge_length=hmin,
         pfix=pfix,
         verbose=2,
     )
     
     meshio.write_points_cells(
         "L_shape_2d.vtk",
         points,
         [("triangle", cells)],
     )
    

    Lshape

    • 3D
     from SeismicMesh import Cube, generate_mesh, sliver_removal, geometry
     
     hmin = 0.05
     bbox = (0.0, 1.0, 0.0, 1.0, 0.0, 1.0)
     
     tol = hmin/10
     
     
     bbox0 = (0.0, 1.0, 0.0, 1.0, 0.0, 0.50 + tol)
     cube0 = Cube(bbox0)
     
     bbox1 = (0.0, 1.0, 0.5, 1.0, 0.50 - tol, 1.0)
     cube1 = Cube(bbox1)
     
     bbox2 = (0.5 - tol, 1.0, 0.0, 1.0, 0.50 - tol, 1.0)
     cube2 = Cube(bbox2)
     
     corners = geometry.corners
     
     
     def union(x):
         return np.minimum.reduce([cube0.eval(x), cube1.eval(x), cube2.eval(x)])
     
     
     pfix = np.vstack((corners(bbox0), corners(bbox1), corners(bbox2)))
     
     points, cells = generate_mesh(
         bbox=bbox,
         domain=union,
         edge_length=hmin,
         pfix=pfix,
         verbose=2,
     )
     
     points, cells = sliver_removal(
         points=points,
         bbox=bbox,
         domain=union,
         edge_length=hmin,
         verbose=2,
     )
     
     meshio.write_points_cells(
         "L_shape.vtk",
         points,
         [("tetra", cells)],
     )
    

    L_shaped_3d

    opened by krober10nd 3
  • quarter annulus?

    quarter annulus?

    One more FEMish benchmark that I've used a bunch:

     import meshio
     import SeismicMesh
     
     h = 0.025
     
     rect = SeismicMesh.Rectangle((0.0, 1.0, 0.0, 1.0))
     disk0 = SeismicMesh.Disk([0.0, 0.0], 0.25)
     diff0 = SeismicMesh.Difference([rect, disk0])
     
     disk1 = SeismicMesh.Disk([0.0, 0.0], 1.0)
     quarter = SeismicMesh.Intersection([diff0, disk1])
     
     
     def sizes(x):
         return h + 0.10 * abs(disk0.eval(x))
     
     
     points, cells = SeismicMesh.generate_mesh(domain=quarter, edge_length=sizes, h0=h)
     meshio.Mesh(points, {"triangle": cells}).write("out.vtk")
    

    quarter

    Feel free to reject, I don't want to add more work for you but just think it would bolster this neat page.

    opened by krober10nd 2
  • Possibly add a recommendation section?

    Possibly add a recommendation section?

    You mentioned being willing to add things...

    The graphs are lovely, but someone who is new to FE might not be able to interpret them as to when would be a good reason to use one generator over another, which is a good multi-purpose generator (i.e. if you only learn one, this is the most useful...) You can certainly preface it with "IMHO", but a Recommendation section at the end of the ReadMe would certainly help the utility of the comparison.

    opened by EngineerMama 4
  • spectral radius for scalar wave equation

    spectral radius for scalar wave equation

    • A good way I can estimate the numerically stable timestep and the "goodness" of a 2D/3D simplical mesh is by measuring the spectral radius of the scalar wave operator.
    • dt < 2/sqrt(spectral_radius)
    • Here I used KMV elements which admit diagonal mass matrices for spatial orders < 5.
    • I've confirmed through ad hoc tests that the min. dihedral angle of the mesh reduces the spectral radius, thus increasing the maximum stable timestep.
    • The spectral radius can be calculated like this (in Firedrake):
    import scipy
    import numpy as np
    
    import firedrake as fd
    from firedrake import dot, grad
    import finat
    
    
    def estimate_timestep(mesh, V, c, estimate_max_eigenvalue=True):
        """Estimate the maximum stable timestep based on the spectral radius
        using optionally the Gershgorin Circle Theorem to estimate the
        maximum generalized eigenvalue. Otherwise computes the maximum
        generalized eigenvalue exactly
        Currently only works with KMV elements.
        """
    
        u, v = fd.TrialFunction(V), fd.TestFunction(V)
        quad_rule = finat.quadrature.make_quadrature(
            V.finat_element.cell, V.ufl_element().degree(), "KMV"
        )
        dxlump = fd.dx(rule=quad_rule)
        A = fd.assemble(u * v * dxlump)
        ai, aj, av = A.petscmat.getValuesCSR()
        av_inv = []
        for value in av:
            if value == 0:
                av_inv.append(0.0)
            else:
                av_inv.append(1 / value)
        Asp = scipy.sparse.csr_matrix((av, aj, ai))
        Asp_inv = scipy.sparse.csr_matrix((av_inv, aj, ai))
    
        K = fd.assemble(c*c*dot(grad(u), grad(v)) * dxlump)
        ai, aj, av = K.petscmat.getValuesCSR()
        Ksp = scipy.sparse.csr_matrix((av, aj, ai))
    
        # operator
        Lsp = Asp_inv.multiply(Ksp)
        if estimate_max_eigenvalue:
            # absolute maximum of diagonals
            max_eigval = np.amax(np.abs(Lsp.diagonal()))
        else:
            print(
                "Computing exact eigenvalues is extremely computationally demanding!",
                flush=True,
            )
            max_eigval = scipy.sparse.linalg.eigs(
                Ksp, M=Asp, k=1, which="LM", return_eigenvectors=False
            )[0]
    
        # print(max_eigval)
        max_dt = np.float(2 / np.sqrt(max_eigval))
        print(
            f"Maximum stable timestep should be about: {np.float(2 / np.sqrt(max_eigval))} seconds",
            flush=True,
        )
        return max_dt
    
    opened by krober10nd 4
  • min dihedral angle?

    min dihedral angle?

    • The minimum dihedral angle would be a useful diagnostic to plot for 3D (in additional too the existing cell-quality measure).

    • The element can still appear to be well-shaped but have a near zero dihedral angle leading to failure in FEM. I suppose this is already captured implicitly in the number of CG iterations.

    opened by krober10nd 0
Owner
Nico Schlömer
Mathematics, numerical analysis, scientific computing, Python. Always interested in new problems.
Nico Schlömer
Whole-day timezone comparison

Timezone Converter Compare a full day of your local timezone with foreign ones $ timezone-converter tijuana --zone $ timezone-converter tijuana new_yo

Iago Alonso 12 Nov 24, 2022
fetchmesh is a tool to simplify working with Atlas anchoring mesh measurements

A Python library for working with the RIPE Atlas anchoring mesh. fetchmesh is a tool to simplify working with Atlas anchoring mesh measurements. It ca

null 2 Aug 30, 2022
A Blender addon to align the origin to the top, center or bottom of a mesh object

Align Origin Blender Addon. Align Origin Blender Addon. What? This simple addon lets you align the origin to the top, center or bottom of a mesh objec

VA79 7 Nov 30, 2022
A python script for combining multiple native SU2 format meshes into one mesh file for multi-zone simulations.

A python script for combining multiple native SU2 format meshes into one mesh file for multi-zone simulations.

MKursatUzuner 1 Jan 20, 2022
Is a util for xferring skinning from one mesh to another

maya_pythonplugins skinTo: Is a util for xferring skinning from one mesh to another args: :param maxInfluences: is the number of max influences on the

James Dunlop 2 Jan 24, 2022
A repo that contains all the mesh keys needed for mesh backend, along with a code example of how to use them in python

Mesh-Keys A repo that contains all the mesh keys needed for mesh backend, along with a code example of how to use them in python Have been seeing alot

Joseph 53 Dec 13, 2022
Mesh Graphormer is a new transformer-based method for human pose and mesh reconsruction from an input image

MeshGraphormer ✨ ✨ This is our research code of Mesh Graphormer. Mesh Graphormer is a new transformer-based method for human pose and mesh reconsructi

Microsoft 251 Jan 8, 2023
CoSMA: Convolutional Semi-Regular Mesh Autoencoder. From Paper "Mesh Convolutional Autoencoder for Semi-Regular Meshes of Different Sizes"

Mesh Convolutional Autoencoder for Semi-Regular Meshes of Different Sizes Implementation of CoSMA: Convolutional Semi-Regular Mesh Autoencoder arXiv p

Fraunhofer SCAI 10 Oct 11, 2022
Given a 2D triangle mesh, we could randomly generate cloud points that fill in the triangle mesh

generate_cloud_points Given a 2D triangle mesh, we could randomly generate cloud points that fill in the triangle mesh. Run python disp_mesh.py Or you

Peng Yu 2 Dec 24, 2021
AI Face Mesh: This is a simple face mesh detection program based on Artificial intelligence.

AI Face Mesh: This is a simple face mesh detection program based on Artificial Intelligence which made with Python. It's able to detect 468 different

Md. Rakibul Islam 1 Jan 13, 2022
Official implementation of the paper Image Generators with Conditionally-Independent Pixel Synthesis https://arxiv.org/abs/2011.13775

CIPS -- Official Pytorch Implementation of the paper Image Generators with Conditionally-Independent Pixel Synthesis Requirements pip install -r requi

Multimodal Lab @ Samsung AI Center Moscow 201 Dec 21, 2022
Official implementation of "GS-WGAN: A Gradient-Sanitized Approach for Learning Differentially Private Generators" (NeurIPS 2020)

GS-WGAN This repository contains the implementation for GS-WGAN: A Gradient-Sanitized Approach for Learning Differentially Private Generators (NeurIPS

null 46 Nov 9, 2022
Code for ICCV 2021 paper: ARAPReg: An As-Rigid-As Possible Regularization Loss for Learning Deformable Shape Generators..

ARAPReg Code for ICCV 2021 paper: ARAPReg: An As-Rigid-As Possible Regularization Loss for Learning Deformable Shape Generators.. Installation The cod

Bo Sun 132 Nov 28, 2022
PyTorch code accompanying our paper on Maximum Entropy Generators for Energy-Based Models

Maximum Entropy Generators for Energy-Based Models All experiments have tensorboard visualizations for samples / density / train curves etc. To run th

Rithesh Kumar 135 Oct 27, 2022
Skywater 130nm Klayout Device Generators PDK

Skywaters 130nm Technology for KLayout Device Generators Mabrains is excited to share with you our Device Generator Library for Skywater 130nm PDK. It

Mabrains 18 Dec 14, 2022
lazy_table - a python-tabulate wrapper for producing tables from generators

A python-tabulate wrapper for producing tables from generators. Motivation lazy_table is useful when (i) each row of your table is generated by a poss

Parsiad Azimzadeh 52 Nov 12, 2022
Neural text generators like the GPT models promise a general-purpose means of manipulating texts.

Boolean Prompting for Neural Text Generators Neural text generators like the GPT models promise a general-purpose means of manipulating texts. These m

Jeffrey M. Binder 20 Jan 9, 2023
Pytorch implementation of the paper Progressive Growing of Points with Tree-structured Generators (BMVC 2021)

PGpoints Pytorch implementation of the paper Progressive Growing of Points with Tree-structured Generators (BMVC 2021) Hyeontae Son, Young Min Kim Pre

Hyeontae Son 9 Jun 6, 2022
Multtable is a collection of multiplication table generators in various languages.

Multtable Multtable is a collection of multiplication table generators in various languages. This project was created as a joke based on one of my bro

pollen__ 7 Mar 5, 2022
[ICLR 2022] Pretraining Text Encoders with Adversarial Mixture of Training Signal Generators

AMOS This repository contains the scripts for fine-tuning AMOS pretrained models on GLUE and SQuAD 2.0 benchmarks. Paper: Pretraining Text Encoders wi

Microsoft 22 Sep 15, 2022