python-3.xfipygmsh

Gmsh structured mesh (Hexahedron mesh) gets imported in unstructured way (tetrahedron) into Itasca PFC software using Fipy


I'm trying to import a 3D cylindrical CFD mesh into Itasca PFC7-3D software from Gmsh using Fipy. The mesh created in Gmsh environment is fully structured(hexahedron cells). However when I tried to import the mesh into Itasca I realized it is imported in unstructured way (tetrahedron). As I don't know much about Fipy, my first guess is that maybe node-ordering convention differs in Itasca and Fipy. (Fipy version 3.4.3, python version 3.6, PFC3D version 7, Gmsh version 4.11.1). Any helps is wholeheartedly appreciated. This is what I built in Gmsh Gmsh mesh. As you see mesh structure is fully Hexa. Itasca PFC is supplied with a distribution of Python 3.6 called ipython that is specifically configured for use with Itasca software. So I tried to use Fipy in order to import my Gmsh mesh into Itasca PFC. But mesh imports distorted and fully tetra. This is the output element plot in Itasca PFC Itasca PFC mesh

I guessed mayby removing non-hexa elements in .msh file will do the trick(because Gmsh implements meshing first in 1D then in 2D and finally in 3D to create a 3D mesh and msh file contains all those information) but it never did. Also I tried to comprehend the node-ordering convention in both ways and applied changes in my python code but I failed. Here's the python code piece by which I tried to import Gmsh mesh into Itasca PFC using Fipy 3.4.3 :

import fipy as fp
import numpy as np
from itasca import cfdarray as ca

class DarcyFlowSolution(object):
    def __init__(self):
        self.mesh = fp.meshes.gmshMesh.Gmsh3D(r"C:\Users\lenovo\Documents\Itasca\pfc3d700\My Projects\c6") #.msh file directory
        ca.create_mesh(self.mesh.vertexCoords.T, 
           self.mesh._cellVertexIDs.T[:,(0,2,3,1,4,6,7,5)].astype(np.int64))
#itasca.cfdarray.create_mesh(nodes: array float{nnodes, 3}, elements: array int{nelem, 8}) → None.
#Create a cfd mesh. The indices in the array elem should index the node locations in the array node. Counting begins at 0.

Plus this is the node-ordering convention in PFC which is provided in Itasca documentation: node-ordering convention in PFC


Solution

  • I don't believe that you are getting tets. Instead, I think there are two issues:

    With the caveat that I do not have Itasca and have never used it, I think you should try

    ca.create_mesh(self.mesh.vertexCoords.T, 
               self.mesh._orderedCellVertexIDs.T.astype(np.int64))
    

    Note, this still might not work for you because the node-ordering convention in PFC image that you shared looks like a left-hand coordinate system to me which is... odd... Gmsh and FiPy both operate in a right-hand coordinate system.

    I diagnosed with a simple two element mesh generated with

    mesh = fp.GmshGrid3D(dx=5, dy=4, dz=3, nx=2, ny=1, nz=1)
    

    If the above doesn't work, please provide your .msh file and I'll try to do more diagnostics.