{"id":19361085,"url":"https://github.com/flosewn/tqmesh","last_synced_at":"2025-08-18T03:39:07.111Z","repository":{"id":40628533,"uuid":"461589375","full_name":"FloSewn/TQMesh","owner":"FloSewn","description":"A simple two-dimensional mesh generator with triangular and quadrilateral elements in C++","archived":false,"fork":false,"pushed_at":"2025-02-18T20:12:01.000Z","size":26933,"stargazers_count":75,"open_issues_count":3,"forks_count":16,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-19T19:11:27.234Z","etag":null,"topics":["advancing-front","cfd-simulation","fem-simulation","finite-element-methods","mesh-generation","mixed-element-mesh","quadrilateral-mesh","size-function","triangle-mesh","triangulation"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FloSewn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-20T19:11:32.000Z","updated_at":"2025-04-12T16:33:42.000Z","dependencies_parsed_at":"2024-03-03T09:23:35.000Z","dependency_job_id":"61c02af8-a387-4fe6-853a-21f71c4971df","html_url":"https://github.com/FloSewn/TQMesh","commit_stats":{"total_commits":237,"total_committers":4,"mean_commits":59.25,"dds":0.430379746835443,"last_synced_commit":"ee918018b71af3839c8ccaf20ec63283bda95ec6"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/FloSewn/TQMesh","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FloSewn%2FTQMesh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FloSewn%2FTQMesh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FloSewn%2FTQMesh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FloSewn%2FTQMesh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FloSewn","download_url":"https://codeload.github.com/FloSewn/TQMesh/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FloSewn%2FTQMesh/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270940600,"owners_count":24671677,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["advancing-front","cfd-simulation","fem-simulation","finite-element-methods","mesh-generation","mixed-element-mesh","quadrilateral-mesh","size-function","triangle-mesh","triangulation"],"created_at":"2024-11-10T07:20:33.764Z","updated_at":"2025-08-18T03:39:07.051Z","avatar_url":"https://github.com/FloSewn.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TQMesh: Simplifying Two-Dimensional Mesh Generation\n-----------------------\n\u003cimg src=\"doc/Example_6.png\" alt=\"TQMesh-Example-6\" width=\"750\"/\u003e\n\n**TQMesh** is a simple C++ library/application designed to streamline the process \nof generating two-dimensional meshes comprising triangles and quadrilaterals. \nWhether you're involved in Computational Fluid Dynamics (CFD), Finite Element Methods (FEM), \nor other fields, this tool simplifies the creation of grids for various applications.\n\n## Key Features\n\n- **Effortless Element Generation:** TQMesh employs an advancing-front method, \nrequiring users to define edge segments that outline the domain. This automated approach ensures smooth and accurate mesh generation.\n\n- **Localized Element Sizing:** Customize mesh properties effortlessly using the user-defined \nsize function. Achieve precise control over element sizing, allowing you to adapt the mesh to your specific needs.\n\n- **Boundary Flexibility:** Beyond triangles, TQMesh introduces the option of including quadrilateral \nelements along the near boundary region. This is particularly advantageous for enhancing mesh accuracy in various scenarios \n(e.g. to resolve boundary layers in fluid dynamics problems).\n\n\n\n## Installation\n\n**TQMesh** is a header-only library, which requires the files in the directories *src/algorithm* and *src/utils*. \nSimply include these files in your projects and start meshing!\n\nThe directory *src/app* contains the code for the application. \nTo install it, follow these steps:\n\n1. Clone the repository to your local machine:\n\n   ```sh\n   git clone https://github.com/FloSewn/TQMesh\n   cd TQMesh  # Enter the project directory\n   ```\n2. Create a build directory:\n   ```sh\n   mkdir build\n   cd build\n   ```\n3. Configure the build using CMake\n   ```sh\n   cmake ..\n   ```\n   If you want to use a specific compiler (e.g. clang), specify it during CMake configuration:\n   ```\n   cmake -DCMAKE_CXX_COMPILER=\u003cyour-compiler\u003e ..\n   ```\n   If you'd like to run in debug mode, use the additional flag `-DCMAKE_BUILD_TYPE=Debug` during the CMake configuration.\n\n4. Build and install TQMesh:\n   ```\n   make install \n   ```\n   \nAnd that's it! TQMesh is now installed and ready to be used. \n\n## Usage of the TQMesh library\nThe **TQMesh** library comes with a set of examples showcasing how to utilize its functions. \nThese examples can be found in the *src/examples* directory of the project.\n\nAfter successfully installing TQMesh, you can run these examples using the provided tool:\n\n1. Navigate to the main project directory in your terminal:\n   ```sh\n   cd TQMesh  # Enter the project directory\n   ```\n\n2. Run the examples tool along with the desired example identifier:\n   ```sh\n   ./bin/run_examples \u003cExample-ID\u003e\n   ```\n   Replace `\u003cExample-ID\u003e` with the specific example identifier you want to run.\n\n\n## Usage of the TQMesh application\nThe **TQMesh** application uses simple parameter files as input for the mesh generation.\nThere are some sample files given in the *input/* directory.\n\nTo use the application, navigate to your main project directory in your terminal and run: \n```sh\n./bin/TQMesh \u003cInput-file\u003e \n```\nReplace `\u003cInput-file\u003e` with the name of your chosen input parameter file.\n\n## Examples\nGenerating a mesh with **TQMesh** is a straightforward process that involves defining a few key global parameters \nalong with mesh boundaries represented by boundary nodes and edges. You have the option to assign markers \nto each boundary edge, which are then applied to the final mesh's boundary edges. \nFurthermore, the application supports creating multiple meshes consecutively, \neach with assigned color values for its elements.\n\nExplore the examples below to get an overview of **TQMesh**'s capabilities.\nYou can find both the example input files and their corresponding \nresults in the *input/* and *src/examples* directories.\n\n\n\u003cdetails\u003e\n\u003csummary\u003eLocal mesh refinement\u003c/summary\u003e\n\n**TQMesh** combines a simple definition of mesh domain boundaries with a versatile specification of the \nelement size. The latter is either determined by the domain's edge segments, \nthrough sizing factors that are attributed to boundary vertices or via user-defined size functions.\n\n\u003cimg src=\"doc/simple_triangular_mesh.png\" alt=\"TQMesh-simple-triangular-mesh\" width=\"300\"/\u003e\n\u003cimg src=\"doc/thin_fracture.png\" alt=\"TQMesh-thin-fracture\" width=\"338\"/\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eQuad layers and subdivision\u003c/summary\u003e\n\n**TQMesh** also features the generation of quadrilateral elements, as well as layers of quad elements in the vicinity of boundaries.\nThis example mesh was created by using the paving algorithm (which generates mixed-element meshes that are dominated by quads) and a subsequent quad-refinement of all elements.\nIn this way, it is possile to generate elements that consist only of quadrilaterals.\n\n\u003cimg src=\"doc/square_in_channel.png\" alt=\"TQMesh-square-in-channel\" width=\"650\"/\u003e\n\n\u003cimg src=\"doc/MeshRefinement_1.png\" alt=\"TQMesh-Refinement-1\" width=\"250\"/\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eBoundary shapes\u003c/summary\u003e\n\nIt is possible to create meshes through predefined boundary shapes, such as rectangles, circles or triangles.\n\n\u003cimg src=\"doc/boundary_shapes.png\" alt=\"TQMesh-boundary-shapes\" width=\"250\"/\u003e\n\u003cimg src=\"doc/MeshRefinement_2.png\" alt=\"TQMesh-Refinement-2\" width=\"250\"/\u003e\n\u003cimg src=\"doc/MeshRefinement_3.png\" alt=\"TQMesh-Refinement-3\" width=\"250\"/\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eLocal mesh refinement and element coloring\u003c/summary\u003e\n\nDuring the meshing process, each element gets an associated color value. \nThese colors can be adjusted during the meshing process, as indicated in this example.\nIt also possible to define interior mesh vertices, in order to influence the local element refinement, as shown below.\n\n\u003cimg src=\"doc/fixed_vertices.png\" alt=\"TQMesh-fixed-vertices\" width=\"250\"/\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eMerge meshes\u003c/summary\u003e\n\n**TQMesh** gives the possibility to create and merge several meshes, preserving the conformity of their boundary edges.\nThis makes it even easier to assign different color values to different element areas in the domain.\nThis example shows the output from a successive mesh generation.\n\n\u003cimg src=\"doc/merge_meshes.png\" alt=\"TQMesh-merge-meshes\" width=\"250\"/\u003e\n\u003cimg src=\"doc/multiple_meshes.png\" alt=\"TQMesh-multiple-meshes\" width=\"250\"/\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eImport boundaries from CSV files\u003c/summary\u003e\n\nIn case you want to automate the meshing process, **TQMesh** offers the possibility to import boundary definitions\nvia CSV files. This example shows an airfoil that has been meshed in this way.\n\n\u003cimg src=\"doc/airfoil.png\" alt=\"TQMesh-airfoil\" width=\"350\"/\u003e\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\u003csummary\u003eFixed interior edges\u003c/summary\u003e\n\nFixed edges can be defined within the domain to guide the meshing process.\n\n\u003cimg src=\"doc/fixed_edges.png\" alt=\"TQMesh-fixed-edges\" width=\"500\"/\u003e\n\u003c/details\u003e\n\n## Output format\nCurrently, **TQMesh** features the VTU output format (which can be read for example by Paraview) or alternatively a simple text output format.\n\n\u003cdetails\u003e\n\u003csummary\u003eMore infos about the text output format \u003c/summary\u003e\n\nThe following sample text output was generated for this mesh:\n\n\u003cimg src=\"doc/OutputMesh.png\" alt=\"TQMesh-Output\" width=\"350\"/\u003e\n\n``` sh\nMESH 1\nVERTICES 9            # The total number of mesh vertices\n1.00000,0.00000       # Coordinates of vertex 0\n1.50000,0.00000       # Coordinates of vertex 1\n2.00000,0.00000       # ...\n2.00000,0.50000\n2.00000,1.00000\n1.50000,1.00000\n1.00000,1.00000\n1.00000,0.50000\n1.50000,0.33319\nINTERIOREDGES 5       # The total number of interior mesh edges \n   5,   7,   1,   4   # The first edge connects vertex 5 \u0026 7 and has the\n   7,   8,   1,   0   # adjacent elements (1,4) to the left and right of it\n   3,   5,   1,   3   # ...\n   3,   8,   2,   1\n   8,   1,   2,   0\nBOUNDARYEDGES 8       # The total number of boundary mesh edges\n   0,   1,   0,   2   # The first edge connects vertex 0 \u0026 1, is \n   1,   2,   2,   2   # adjacent to element 0 and has marker 2\n   2,   3,   2,   2   # .....\n   3,   4,   3,   2\n   4,   5,   3,   2\n   5,   6,   4,   2\n   6,   7,   4,   1\n   7,   0,   0,   1\nINTERFACEEDGES 2          # The total number of interface edges between two neighboring meshes\n   6,   7,   4,   2,   2  # This interface edge connects vertices 6 and 7. It is adjacent to \n   7,   0,   0,   1,   2  # element 4 of this mesh and to element 2 of another mesh with index 2\nFRONT 0                   # Remaining advancing front edges after a failed meshing attempt\nQUADS 3                   # The total number of quadrilateral elements\n   0,   1,   8,   7,   2  # Quadrilateral made up of vertices 0, 1, 8 \u0026 7. \n   7,   8,   3,   5,   2  # The quad has the color value 2\n   8,   1,   2,   3,   2  # ...\nTRIANGLES 2               # The total number of triangular elements\n   3,   4,   5,   2       # Triangle made up of vertices 3, 4 \u0026 5. Its color value is 2\n   5,   6,   7,   2       # ...\nQUADNEIGHBORS 3\n   2,   1,  -1,  -1       # Element indices from the neighbors of quadrilateral 0\n   2,   3,   4,   0       # The index -1 indicates a mesh boundary adjacency\n  -1,  -1,   1,   0       \nTRIANGLENEIGHBORS 2\n  -1,   1,  -1            # Element indices of the neighbors of triangle 0\n  -1,   1,  -1            # The index -1 indicates a mesh boundary adjacency \nSIZEFUNCTION 9            \n0.50000                   # Size function value of vertex 0\n0.50000                   # Size function value of vertex 1 \n0.50000                   # ...\n0.50000\n0.50000\n0.50000\n0.50000\n0.50000\n0.50000\n```\nFor the adjacency lists, quadrilateral and triangular elements are indexed together. \nThis means, for example, if the mesh consists of 400 triangles and 300 quads, then quad 1 has element index 1 and triangle 1 has element index 401.\nThe last entry of the mesh output refers to the size function values at every vertex of the mesh.\n\n\u003c/details\u003e\n\n## Convert meshes for OpenFOAM\n\u003cimg src=\"doc/banner_3d.jpeg\" alt=\"TQMesh-OpenFOAM-support\" width=\"300\"/\u003e\n\nTo convert meshes from **TQMesh** to a format that is supported by OpenFOAM\nyou can use a script that is provided in `scripts/convert2foam.py`.\n```sh\npython scripts/convert2foam.py [-e EXTRUSION] Mesh.txt export-prefix\n```\nThis script simply extrudes the provided mesh into the z-direction and \ngenerates the required files which can be used as input for OpenFOAM.\n\n## Plot your meshes\nA simple python script to plot your mesh is provided under `scripts/plot_mesh.py`.\nIt requires the mesh given in the format described above.\nSimply run it with\n```sh\npython scripts/plot_mesh.py Mesh.txt (-s -v -e -b -f)\n```\nOptional flags: \n* `-s`: Add a contour plot of the underlying size-function\n* `-c`: Plot elements with their respective color values\n* `-v`: Add the mesh vertices and their indices to the plot\n* `-e`: Add the mesh element indices to the plot\n* `-b`: Highlight the mesh boundaries \n* `-f`: Highlight remaining advancing front edges (in case of a failed meshing attempt) \n\n\u003cimg src=\"doc/ExampleMesh_SizeFunction.png\" alt=\"TQMesh-Example-SizeFunction\" width=\"350\"/\u003e\n\n\n## Tests / Benchmarks\n**TQMesh** uses a customized QuadTree container structure to store and access all mesh entities. \nThe following plots show some performance statistics.\n\n\u003cimg src=\"doc/BenchmarkPlot_QTree.png\" alt=\"TQMesh-QTree-Benchmark\" width=\"400\"/\u003e \u003cimg src=\"doc/BenchmarkPlot_Mesh.png\" alt=\"TQMesh-Mesh-Benchmark\" width=\"400\"/\u003e\n\n## To Do's\n* Enhanced quad triangle-to-quad morphing\n* Boundary definition via splines\n* Improved documentation / testing\n\nFeel free to contribute!\n\n## Libraries used\n* [exprtk.h - C++ Mathematical Expression Toolkit Library](http://www.partow.net/programming/exprtk/index.html)\n\n## Sources\n* o'Rourke, Joseph. Computational geometry in C. Cambridge university press, 1998.\n* [Shewchuk, Jonathan R. Lecture Notes on Delaunay Mesh Generation, February 5, 2012](https://people.eecs.berkeley.edu/~jrs/meshpapers/delnotes.pdf)\n* [Jonathan R. Shewchuk's free course material on Mesh Generation and Geometry Processing in Graphics, Engineering, and Modeling ](https://people.eecs.berkeley.edu/~jrs/mesh/)\n* Lo, Daniel SH. Finite element mesh generation. CRC Press, 2014\n* Blazek, Jiri. Computational fluid dynamics: principles and applications. Butterworth-Heinemann, 2015\n* [Zhou and Shimada, An Angle-Based Approach to Two-Dimensional Mesh Smoothing, IMR 2000, 373-384, 2000](https://www.researchgate.net/profile/Kenji-Shimada-2/publication/221561796_An_Angle-Based_Approach_to_Two-Dimensional_Mesh_Smoothing/links/0deec53988e9f560ec000000/An-Angle-Based-Approach-to-Two-Dimensional-Mesh-Smoothing.pdf) \n\n## Licences\nThe project is licensed under the MIT License - see the LICENSE file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflosewn%2Ftqmesh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflosewn%2Ftqmesh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflosewn%2Ftqmesh/lists"}