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

Read partitioned Gmsh files #1006

Open
CsatiZoltan opened this issue Mar 28, 2024 · 0 comments
Open

Read partitioned Gmsh files #1006

CsatiZoltan opened this issue Mar 28, 2024 · 0 comments
Labels
enhancement Enhances already existing code New feature Adds a new feature to the code

Comments

@CsatiZoltan
Copy link
Collaborator

t8code is able to read ASCII Gmsh files and create a cmesh out of it. Then the uniform cmesh partitioning function can distribute the cmesh among MPI processes. What is not supported yet is directly creating a partitioned cmesh based on the mesh partitions that come from a partitioned Gmsh file.

When you partition a mesh in Gmsh, you have the option to save the ghost elements too. Moreover, when you export the mesh, you have the choice to save one file per partition or save all the partitions into the same file. Since reading from the exported text file is done line by line, the one-file-per-partition approach could be read faster by t8code. Preferably, both single-file and multi-file .msh reading should be supported.

There are two main steps to implement this feature:

  1. Create a parser function in t8_cmesh/t8_cmesh_readmshfile.cxx to fetch the ghost elements. We need to look for the $GhostElements section in the .msh file. See the Gmsh manual for the specification.

  2. Compute extra connectivity information. For a cmesh to be partitioned, t8code needs one ghost layer (already supplied by Gmsh) plus a bit more knowledge: to which elements the ghost elements are neighbours. As an example, consider the following configuration. Proc 0 has element 1, element 1 is neighbour of element 2. Proc 1 has element 2, element 2 is neighbour of element 3. Proc 2 has element 3. Then Proc 0 needs the following information when building the cmesh:

    • tree class of element 1
    • tree class of element 2
    • element 1 and element 2 are neighbours via faces a, b
    • element 2 and element 3 are neighbours via faces c, d

    The required connectivity information is described in the t8_cmesh_set_partition_range function:

    t8code/src/t8_cmesh.h

    Lines 160 to 192 in 6d8644e

    /** Declare if the cmesh is understood as a partitioned cmesh and specify
    * the processor local tree range.
    * This function should be preferred over \ref t8_cmesh_set_partition_offsets
    * when the cmesh is not derived from another cmesh.
    * This call is only valid when the cmesh is not yet committed via a call
    * to \ref t8_cmesh_commit.
    * \param [in,out] cmesh The cmesh to be updated.
    * \param [in] set_face_knowledge Several values are possible that define
    * how much information is required on face connections,
    * specified by \ref t8_cmesh_set_join.
    * 0: Expect face connection of local trees.
    * 1: In addition, expect face connection from
    * ghost trees to local trees.
    * 2: In addition, expect face connection between
    * ghost trees.
    * 3: Expect face connection of local and ghost trees.
    * Consistency of this requirement is checked on
    * \ref t8_cmesh_commit.
    * -1: Do not change the face_knowledge level but keep any
    * previously set ones. (Possibly by a previous call to \ref t8_cmesh_set_partition_range)
    * \param [in] first_local_tree The global index ID of the first tree on this process.
    * If this tree is also the last tree on the previous process,
    * then the argument must be -ID - 1.
    * \param [in] last_local_tree The global index of the last tree on this process.
    * If this process should be empty then \a last_local_tree
    * must be strictly smaller than \a first_local_tree.
    *
    * \see t8_cmesh_set_partition_offset \see t8_cmesh_set_partition_uniform
    * \note A value of \a set_face_knowledge other than -1 or 3 is not yet supported.
    */
    void
    t8_cmesh_set_partition_range (t8_cmesh_t cmesh, int set_face_knowledge, t8_gloidx_t first_local_tree,
    t8_gloidx_t last_local_tree);

    Computing and storing the aforementioned ghost information should be possible with a few MPI communications. I.e. each process knows the connections: local tree -> ghost trees and local tree -> local tree. And then we would need to communicate these connections for the appropriate elements with the neighbouring processes.

@holke holke changed the title Read partitioned Gmesh files Read partitioned Gmsh files Apr 4, 2024
@holke holke added enhancement Enhances already existing code New feature Adds a new feature to the code labels Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhances already existing code New feature Adds a new feature to the code
Projects
None yet
Development

No branches or pull requests

2 participants