Skip to content
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

Merged
merged 1 commit into from
Sep 8, 2024

Conversation

yungyuc
Copy link
Member

@yungyuc yungyuc commented Sep 8, 2024

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.

For issue #404.

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.
@yungyuc yungyuc added mesh Spatial mesh multidim Multi-dimensional solver labels Sep 8, 2024
@yungyuc yungyuc self-assigned this Sep 8, 2024
@yungyuc yungyuc marked this pull request as draft September 8, 2024 12:59
Copy link
Member Author

@yungyuc yungyuc left a 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(
Copy link
Member Author

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():
Copy link
Member Author

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 @@
/*
Copy link
Member Author

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;
Copy link
Member Author

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
Copy link
Member Author

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]>
Copy link
Member Author

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)
Copy link
Member Author

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.

Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Member Author

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).

@yungyuc yungyuc marked this pull request as ready for review September 8, 2024 13:05
@yungyuc
Copy link
Member Author

yungyuc commented Sep 8, 2024

The PR will go to the multidim branch. I created multidim branch to track work porting 2/3D solver from the old solvcon code base to modmesh. (It's not so convenient in the current collaborative model and I will go back to master branch later.)

@yungyuc
Copy link
Member Author

yungyuc commented Sep 8, 2024

@j8xixo12 I am merging this PR.

@yungyuc yungyuc merged commit 9c4e122 into solvcon:multidim Sep 8, 2024
13 checks passed
@yungyuc yungyuc deleted the multidim-rectangle-2dmesh branch September 8, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mesh Spatial mesh multidim Multi-dimensional solver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant