-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 2D unstructured mesh of triangle elements in a rectangle #422
Conversation
Add `rectangle.geo` (Gmsh command file) and `rectangle.msh` (Gmsh mesh file (version 2.2)) and test loading the mesh into StaticMesh in memory. Add a menu item to show the 2D unstructured mesh in the viewer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remarks:
- We can keep mesh data files as fixture, but we should only keep small files. The rule of thumb is the size should not be larger than a medium-sized source file.
@@ -259,6 +259,10 @@ void RManager::setUpMenu() | |||
QString("Sample: mesh of \"solvcon\" text in 2D"), | |||
QString("Create a sample mesh drawing a text string of \"solvcon\""), | |||
QString("modmesh.gui.sample_mesh.mesh_solvcon_2dtext"))); | |||
m_meshMenu->addAction(new RPythonAction( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a menu item for the rectangle.
@@ -201,4 +204,25 @@ def mesh_3dmix(): | |||
w_3dmix.showMark() | |||
view.mgr.pycon.writeToHistory(f"3dmix nedge: {mh.nedge}\n") | |||
|
|||
|
|||
def mesh_rectangle(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show the new example mesh file rectangle.msh
.
@@ -0,0 +1,27 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Gmsh command file for the rectangle.
/* | ||
* A Gmsh template file for a rectangle domain. | ||
*/ | ||
lc = 0.25; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define the mesh size.
@@ -0,0 +1,327 @@ | |||
$MeshFormat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Store the mesh data file for testing.
@@ -1,35 +1,99 @@ | |||
# Copyright (c) 2024, Yung-Yu Chen <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supplement copyright notice.
|
||
data = open(path, 'rb').read() | ||
gmsh_instance = modmesh.core.Gmsh(data) | ||
blk = gmsh_instance.to_block() | ||
gmsh = mm.Gmsh(data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use mm
shorthand. Avoid the internal core
sub-module name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the local variable name short.
# had been shifted and start with index 3 | ||
np.testing.assert_almost_equal(blk.ndcrd.ndarray[3:, :].tolist(), | ||
# had been shifted and start with index 3 (number of ghost) | ||
ngst = blk.ngstcell |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a local symbol for the number of ghost cell.
self.assertEqual(blk.ngstface, 80) | ||
self.assertEqual(blk.ngstcell, 40) | ||
|
||
@unittest.expectedFailure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@j8xixo12 , it seems that we have a bug. I will create the issue later.
The mesh is all triangles. All cell types should be 4, but it fails. Some becomes 2 (line/edge).
The PR will go to the |
@j8xixo12 I am merging this PR. |
Add
rectangle.geo
(Gmsh command file) andrectangle.msh
(Gmsh mesh file (version 2.2)) and test loading the mesh into StaticMesh in memory.Add a menu item to show the 2D unstructured mesh in the viewer.
For issue #404.