The .geo file below was ran with ‘gmsh mesh.geo -2 -o mesh.msh’ . After generation, a gmsh.io command (see code below) leads to MPI rank problems. The error is also given below:
// -----------------------------------------------------------------------------
//
// Gmsh GEO
//
// -----------------------------------------------------------------------------
//gmsh file.geo -2 -o mesh.msh
h = 0.05; //mesh size
hcrack = 0.002; //mesh size near crack
// ------------------------------------------------------
// ------------------------------------------------------
// A)Geometry Definition: 1)Points
// 2)Lines
// 3)Curve
// 4)Surface
// ------------------------------------------------------
// A1)Points Definitions:
//
// P4*----------*P3
// | |
// P5* \ |
// *P7 *P8
// P6* / |
// | |
// P1*----------*P2
//
// |Y
// |
// ---X Dimensions: 1 x 1 x 0.01
// Z /
//
// -----Coordinates--
//Points: ----X,------Y,---Z,
Point(1) ={ -0.5, -0.5, 0, h};
Point(2) ={ 0.5, -0.5, 0, h};
Point(3) ={ 0.5, 0.5, 0, h};
Point(4) ={ -0.5, 0.5, 0, h};
Point(5) ={ -0.5, 0.001, 0, h};
Point(6) ={ -0.5, -0.001, 0, h};
Point(7) ={ 0.0, 0.0, 0, h};
Point(8) ={ 0.5, 0.0, 0, h};
// ------------------------------------------------------
// A2)Lines Definition
//
// <-L3
// *----------*
// |L4| |
// * \L5 | ^
// * |L2
// * /L6 |
// L7| |
// *----------*
// L1->
Line(1) = {1, 2}; //L1:from P1 to P2: P1*--L1-->*P2
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 5};
Line(5) = {5, 7};
Line(6) = {7, 6};
Line(7) = {6, 1};
// ------------------------------------------------------
// A3)Curve Definition
//
//
// *----<-----*
// | |
// * \ |
// * ^ Curve 5
// * / |
// | |
// *----->----*
//
Curve Loop(5) = {1,2,3,4,5,6,7}; //C5: through lines L1,L2,...,L7
// ------------------------------------------------------
// A4)Surface Definition
//
// *----------*
// | |
// * \ |
// * S6 |
// * / |
// | |
// *----------*
//
Plane Surface(6) = {5}; // Curve loop 5 C5 --> Surface S6
Recombine Surface {6};
// ------------------------------------------------------
// ------------------------------------------------------
// B)Mesh Generation: 1)Mesh size Box1
// 2)Mesh size Box2
// 3)Mesh min(Box1,Box2)
// 3)Extrude Mesh
// 4)Mesh Algorithm
// ------------------------------------------------------
// B1) Mesh size Box1
//
// *----------------*
// | |
// | |
// | |
// * -----------|
// | hcrack F6 | (Field[6])
// * -----------|
// | |
// | |
// | |
// *----------------*
Field[6] = Box;
Field[6].VIn = hcrack;
Field[6].VOut = h;
Field[6].XMin = -0.05;
Field[6].XMax = 0.5;
Field[6].YMin = -0.015;
Field[6].YMax = 0.015;
// ------------------------------------------------------
// B2) Mesh size Box2
//
// *----------------*
// | |
// | |
// | -------------|
// | | |
// * | hcrack*10 |
// * | F7 | (Field[7])
// | | |
// | -------------|
// | |
// | |
// *----------------*
Field[7] = Box;
Field[7].VIn = hcrack*10;
Field[7].VOut = h;
Field[7].XMin = -0.15;
Field[7].XMax = 0.5;
Field[7].YMin = -0.1;
Field[7].YMax = 0.1;
// ------------------------------------------------------
// B3) Mesh min(Box1,Box2)
//
// *----------------*
// | |
// | -------------|
// | | hcrack*10 |
// * | ----------|
// | | | hcrack F8| Field[8]
// * | ----------|
// | | F8|
// | -------------|
// | |
// *----------------*
Field[8] = Min;
Field[8].FieldsList = {6,7};
Background Field = 8;
// ------------------------------------------------------
// B4)Extrude Mesh
// {X, Y, Z} Surface
Extrude{0, 0, 0.01}{Surface{6}; Layers{{1},{1}}; Recombine;}
// ------------------------------------------------------
// B5)Mesh Algorithm
Geometry.Tolerance = 1e-12;
Mesh.SaveAll = 1;
// ------------------------------------------------------
// Physical groups definition
//
// "top"
// *----------*
// | |
// * \ |
// * *
// * / |
// | |
// *----------*
// "bottom"
//
Physical Surface("bottom", 45) = {19};
Physical Surface("top", 46) = {27};
import numpy as np
import dolfinx
from mpi4py import MPI
import petsc4py
import os
msh_file ="mesh.msh" # Path to the mesh file
gdim = 2 # Geometric dimension of the mesh
gmsh_model_rank = 0 # Rank of the Gmsh model in a parallel setting
mesh_comm = MPI.COMM_WORLD # MPI communicator for parallel computation
rank = MPI.COMM_WORLD.Get_rank()
size = MPI.COMM_WORLD.Get_size()
print(f"Rank {rank} out of {size}")
msh, cell_markers, facet_markers = dolfinx.io.gmshio.read_from_msh(msh_file, mesh_comm, gmsh_model_rank, gdim)
Info : Reading 'mesh.msh'...
Info : 46 entities
Info : 9833 nodes
Info : 15049 elements
Info : Done reading 'mesh.msh'
Invalid rank, error stack:
internal_Issend(60788): MPI_Issend(buf=0x36f653a1, count=1, MPI_BYTE, 1, 1, comm=0x84000005, request=0x36f65384) failed
internal_Issend(60749): Invalid rank has value 1 but must be nonnegative and less than 1
Abort(339346182) on node 0 (rank 0 in comm 416): application called MPI_Abort(comm=0x84000005, 339346182) - process 0