Skip to content

Commit

Permalink
Add MeshChecker to TQMeshApp.h & Update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
FloSewn committed Jun 10, 2024
1 parent 5c2cebc commit 321309f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
16 changes: 9 additions & 7 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.

<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,17 +131,18 @@ 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.
It also possible to define interior mesh vertices, in order to influence the local element refinement, as shown below.

<img src="doc/fixed_vertices.png" alt="TQMesh-fixed-vertices" width="250"/>
<img src="doc/multiple_meshes.png" alt="TQMesh-multiple-meshes" width="250"/>
</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.
Expand All @@ -150,7 +152,7 @@ This example shows the output from a successive mesh generation.
</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.
Expand Down Expand Up @@ -231,7 +233,7 @@ 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="600"/>
<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`.
Expand Down
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.
22 changes: 16 additions & 6 deletions src/app/TQMeshApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ class MeshConstruction

init_smoothing_parameters( mesh_reader );

generate_mesh();

return true;
return generate_mesh();

} // MeshConstruction::construct_mesh()

Expand All @@ -130,7 +128,7 @@ class MeshConstruction
/*------------------------------------------------------------------
| Generate the mesh
------------------------------------------------------------------*/
void generate_mesh()
bool generate_mesh()
{
ASSERT( domain_.get(), "MeshConstruction::generate_mesh: "
"Domain has not been properly initialized." );
Expand Down Expand Up @@ -222,6 +220,17 @@ class MeshConstruction
mesh_generator_.write_mesh(mesh, "DUMMY", MeshExportType::COUT);
}

// Check if meshing algorithm succeeded
MeshChecker mesh_check { mesh, domain };
if ( !mesh_check.check_completeness() )
{
LOG(ERROR) << "Failed to generate a valid mesh.";
return false;
}

// Mesh generation succeeded
return true;

} // MeshConstruction::generate_mesh()

/*------------------------------------------------------------------
Expand Down Expand Up @@ -886,6 +895,7 @@ class TQMeshApp

MeshConstruction mesh_construction {};
int mesh_id = 0;
bool success = true;

while( reader_.query( "mesh_reader" ) )
{
Expand All @@ -895,12 +905,12 @@ class TQMeshApp
LOG(INFO) << "============== " << "Create mesh " << mesh_id
<< " ==============";

mesh_construction.construct_mesh(mesh_id, mesh_reader);
success &= mesh_construction.construct_mesh(mesh_id, mesh_reader);

++mesh_id;
}

return true;
return success;

} // TQMeshApp::run()

Expand Down

0 comments on commit 321309f

Please sign in to comment.