Skip to content

Commit

Permalink
Develop (#29)
Browse files Browse the repository at this point in the history
* Add python script for mesh conversion to openFOAM

* Update script for openFOAM mesh conversion

* Rename python script for openFOAM grid conversion

* Update script "convert2foam.py" to fix mesh orientation issues in openFOAM's checkMesh routine

* Fix bugs in convert2foam.py

* Fix bugs in convert2foam.py

* Add example parameter file that covers the mesh of a thin fracture

* Add thin fracture example as cpp file

* Update parameter files for examples 02 and 06

The files `input/02_square_in_channel.para`
and `input/06_airfoil_from_csv.para` generated invalid meshes and
have thus be adjusted for it.

* Update example 02 cpp file

* Remove vertex-edge-intersection check in FrontUpdate.h

The call to `vertex.intersects_mesh_edges()`, which checked if a
vertex is placed too close to its surrounding edges has been removed.
This check led to wrong element sizes when choosing quad layers with
very small heights (compared to the global element size).
It was also found that this check is not required to pass the
current meshing tests and thus has been removed.

* Update example 06 to get rid of invalid front edges

* Update Readme

* Update readme

* Update Readme

* Add missing call for facet-connectivity-update to smoothing strategies

* Remove namespace "TQAlgorithm"

* Put includes into TQMesh.h and update examples / application for it

* Add single include to TQMesh.h in for each header file

* Add MeshChecker

* Add input file for ParaReader tests

* Put CppUtils includes into single file. Use again separate includes of headers in algorithm part and testing part

* Add MeshChecker to TQMeshApp.h & Update Readme

* Add CHANGELOG.md
  • Loading branch information
FloSewn committed Jun 10, 2024
1 parent b3e029a commit 5bd09f0
Show file tree
Hide file tree
Showing 82 changed files with 2,441 additions and 1,058 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Changelog

## [1.3.2] - 2024-06-10

### Fixed

- Add missing call to update of face-connectivity prior to mesh smoothing strategies,
which let to invalid meshing attempts in example 2 and example 6 (based on issue [#24](https://github.com/FloSewn/TQMesh/issues/24))
([`0ce9393`](https://github.com/FloSewn/TQMesh/commit/0ce9393))

### Changed

- Remove `ve_intersection_` attribute in `src/algorithm/FrontUpdate.h`, which prevented quad layer heights
to be removed adequately in the vicinity of small element sizes and which had no impact on the actual mesh generation
([#26](https://github.com/FloSewn/TQMesh/issues/26)) ([`1762bdd`](https://github.com/FloSewn/TQMesh/commit/1762bdd))
- Change namespace `TQMesh::TQAlgorithm` simply to `TQMesh`
- Add single include header files `src/algorithm/TQMesh.h` and `src/utils/CppUtils.h` to reduce include statements
within exampes / TQMesh application

### Added

- **convert2foam.py** to convert the TQMesh text-format to the OpenFOAM compatible mesh format ([#19](https://github.com/FloSewn/TQMesh/issues/19)) ([`df2a078`](https://github.com/FloSewn/TQMesh/commit/df2a078))
- New example **thin fracture**, which involves merging two meshes that model a thin fraction interface (based on [#26](https://github.com/FloSewn/TQMesh/issues/26)).
- **MeshChecker** class in `src/algorithm/MeshChecker.h`, which acts as interface for general mesh validity checks ([`7ca7320`](https://github.com/FloSewn/TQMesh/commit/7ca7320))
(might be extened in future for mesh quality checks)

2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

project(TQMesh
LANGUAGES CXX
VERSION 1.1)
VERSION 1.3.2)

set( BIN ${CMAKE_SOURCE_DIR}/bin )
if(WIN32)
Expand Down
37 changes: 24 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,18 @@ results in the *input/* and *src/examples* directories.


<details>
<summary>Example 1: Local mesh refinement</summary>
<summary>Local mesh refinement</summary>

This example shows a triangular mesh which features local element refinement.
The element size is determined either by the domain's edge segments,
through sizing factors that are attributed to boundary vertices or through a size function which is defined by the user.
**TQMesh** combines a simple definition of mesh domain boundaries with a versatile specification of the
element size. The latter is either determined by the domain's edge segments,
through sizing factors that are attributed to boundary vertices or via user-defined size functions.

<img src="doc/simple_triangular_mesh.png" alt="TQMesh-simple-triangular-mesh" width="300"/>
<img src="doc/thin_fracture.png" alt="TQMesh-thin-fracture" width="338"/>
</details>

<details>
<summary>Example 2: Quad layers and subdivision</summary>
<summary>Quad layers and subdivision</summary>

**TQMesh** also features the generation of quadrilateral elements, as well as layers of quad elements in the vicinity of boundaries.
This 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.
Expand All @@ -120,7 +121,7 @@ In this way, it is possile to generate elements that consist only of quadrilater
</details>

<details>
<summary>Example 3: Boundary shapes</summary>
<summary>Boundary shapes</summary>

It is possible to create meshes through predefined boundary shapes, such as rectangles, circles or triangles.

Expand All @@ -130,7 +131,7 @@ It is possible to create meshes through predefined boundary shapes, such as rect
</details>

<details>
<summary>Example 4: Local mesh refinement and element coloring</summary>
<summary>Local mesh refinement and element coloring</summary>

During the meshing process, each element gets an associated color value.
These colors can be adjusted during the meshing process, as indicated in this example.
Expand All @@ -140,26 +141,25 @@ It also possible to define interior mesh vertices, in order to influence the loc
</details>

<details>
<summary>Example 5: Merge meshes</summary>
<summary>Merge meshes</summary>

**TQMesh** gives the possibility to create and merge several meshes, preserving the conformity of their boundary edges.
This makes it even easier to assign different color values to different element areas in the domain.
This example shows the output from a successive mesh generation.

<img src="doc/merge_meshes.png" alt="TQMesh-merge-meshes" width="250"/>
<img src="doc/multiple_meshes.png" alt="TQMesh-multiple-meshes" width="250"/>
</details>

<details>
<summary>Example 6: Import boundaries from CSV files</summary>
<summary>Import boundaries from CSV files</summary>

In case you want to automate the meshing process, **TQMesh** offers the possibility to import boundary definitions
via CSV files. This example shows an airfoil that has been meshed in this way.

<img src="doc/airfoil.png" alt="TQMesh-airfoil" width="350"/>
</details>



## Output format
Currently, **TQMesh** features the VTU output format (which can be read for example by Paraview) or alternatively a simple text output format.

Expand Down Expand Up @@ -232,13 +232,23 @@ The last entry of the mesh output refers to the size function values at every ve

</details>

## Convert meshes for OpenFOAM
<img src="doc/banner_3d.jpeg" alt="TQMesh-OpenFOAM-support" width="300"/>

To convert meshes from **TQMesh** to a format that is supported by OpenFOAM
you can use a script that is provided in `scripts/convert2foam.py`.
```sh
python scripts/convert2foam.py [-e EXTRUSION] Mesh.txt export-prefix
```
This script simply extrudes the provided mesh into the z-direction and
generates the required files which can be used as input for OpenFOAM.

## Plot your meshes
A simple python script to plot your mesh is provided under `scripts/plot_mesh.py`.
It requires the mesh given in the format described above.
Simply run it with
```sh
python scipts/plot_mesh.py Mesh.txt (-s -v -e -b -f)
python scripts/plot_mesh.py Mesh.txt (-s -v -e -b -f)
```
Optional flags:
* `-s`: Add a contour plot of the underlying size-function
Expand All @@ -258,8 +268,9 @@ The following plots show some performance statistics.
<img src="doc/BenchmarkPlot_QTree.png" alt="TQMesh-QTree-Benchmark" width="400"/> <img src="doc/BenchmarkPlot_Mesh.png" alt="TQMesh-Mesh-Benchmark" width="400"/>

## To Do's
* Boundary definition via splines
* Fixed edges within domains
* Enhanced quad triangle-to-quad morphing
* Boundary definition via splines
* Improved documentation / testing

Feel free to contribute!
Expand Down
91 changes: 91 additions & 0 deletions auxiliary/test_data/ParaReaderTests.input.para
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@

# ----------------
# Mesh 1
# ----------------
Define mesh:

Define exterior boundary:
0.0, 0.0, 1
100.0, 0.0, 1
100.0, 100.0, 1
0.0, 100.0, 1
End exterior boundary

Define interior boundary:
10.0, 10.0, 2
90.0, 10.0, 2
90.0, 90.0, 2
10.0, 90.0, 2
End interior boundary

End mesh

# ----------------
# Mesh 2
# ----------------
Define mesh:

Define exterior boundary:
10.0, 10.0, 2
90.0, 10.0, 2
90.0, 90.0, 2
10.0, 90.0, 2
End exterior boundary

Define interior boundary:
20.0, 20.0, 3
80.0, 20.0, 3
80.0, 80.0, 3
20.0, 80.0, 3
End interior boundary

Define interior boundary:
20.0, 20.0, 3
80.0, 20.0, 3
80.0, 80.0, 3
20.0, 80.0, 3
End interior boundary

Define interior boundary:
20.0, 20.0, 3
80.0, 20.0, 3
80.0, 80.0, 3
20.0, 80.0, 3
End interior boundary

End mesh

# ----------------
# Mesh 3
# ----------------
Define mesh:

Define exterior boundary:
20.0, 20.0, 3
80.0, 20.0, 3
80.0, 80.0, 3
20.0, 80.0, 3
End exterior boundary

Define interior boundary:
40.0, 40.0, 4
60.0, 40.0, 4
60.0, 60.0, 4
40.0, 60.0, 4
End interior boundary

End mesh

# ----------------
# Mesh 4
# ----------------
Define mesh:

Define exterior boundary:
40.0, 40.0, 4
60.0, 40.0, 4
60.0, 60.0, 4
40.0, 60.0, 4
End exterior boundary

End mesh
Binary file modified doc/airfoil.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/banner_3d.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/multiple_meshes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/thin_fracture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions input/02_square_in_channel.para
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ Define mesh:
4.00, 0.00 # v1
4.00, 1.00 # v2
0.00, 1.00 # v3
0.35, 0.35, 0.05, 0.20 # v4
0.35, 0.65, 0.05, 0.20 # v5
0.65, 0.65, 0.05, 0.20 # v6
0.65, 0.35, 0.05, 0.20 # v7
0.35, 0.35, 0.03, 0.25 # v4
0.35, 0.65, 0.03, 0.25 # v5
0.65, 0.65, 0.03, 0.25 # v6
0.65, 0.35, 0.03, 0.25 # v7
End boundary vertices

Define exterior boundary edges:
Expand Down
14 changes: 11 additions & 3 deletions input/06_airfoil_from_csv.para
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#===========================================================

#-----------------------------------------------------------
# MESH DEFINITION
# OUTER MESH DEFINITION
#-----------------------------------------------------------
Define mesh:
Element size: 0.003
Expand All @@ -22,13 +22,21 @@ Define mesh:

Define interior boundary from CSV file: ../auxiliary/test_data/Airfoil.csv

Add quad layers: 0.69132, 0.09754, 0.69132, 0.09754, 10, 0.0003, 1.10
Add quad layers: 0.69132, 0.09754, 0.69132, 0.09754, 10, 0.0004, 1.10

#---------------------------------------------------------
# LOCAL REFINEMENT
#---------------------------------------------------------
Define fixed vertices:
0.69095, 0.09625, 0.0020, 0.02
0.85985, 0.07582, 0.0008, 0.005
End fixed vertices

End mesh


#-----------------------------------------------------------
# Mesh #3
# INNER MESH DEFINITION
#-----------------------------------------------------------
Define mesh:
Element size: 0.003
Expand Down
53 changes: 53 additions & 0 deletions input/08_thin_fracture.para
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#===========================================================
# TQMESH
#===========================================================

#-----------------------------------------------------------
# MESH DEFINITION
#-----------------------------------------------------------
Define mesh:
Element size: 4
Element color: 1
Meshing algorithm: Tri-to-Quad
Number of quad refinements: 1
Smooth quad layers: 0
Number of smoothing iterations: 3

# Output formats: COUT, TXT, VTU
Output file format: VTU
Output file prefix: ./thin_fracture

#---------------------------------------------------------
# BOUNDARIES
#---------------------------------------------------------
Define boundary vertices:
55.00, -140.0000
90.00, -140.0000
90.00, -110.0000
55.00, -110.0000
77.03125, -134.0878, 0.1, 0.035
77.04852, -134.0778, 0.1, 0.035
68.49935, -119.4510, 0.1, 0.035
68.48208, -119.4611, 0.1, 0.035
End boundary vertices

Define exterior boundary edges:
0, 1, 1
1, 2, 2
2, 3, 3
3, 0, 4
End exterior boundary edges

Define interior boundary edges:
4, 7, 5
7, 6, 5
6, 5, 5
5, 4, 5
End interior boundary edges

#---------------------------------------------------------
# QUAD-LAYERS
#---------------------------------------------------------
Add quad layers: 77.03125, -134.0878, 77.03125, -134.0878, 2, 0.1, 1.3

End mesh
Loading

0 comments on commit 5bd09f0

Please sign in to comment.