1

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

  • "when I tried to import the mesh into Itasca I realized it is imported in unstructured way (tetrahedron)" - How did you import the mesh in Itasca? Is that the code at the end or something else? Does Itasca import Gmsh meshes natively? – jeguyer Feb 13 '23 at 14:57
  • "mesh plots in Gmsh and PFC + PFC node-ordering convention accordingly" - I see one plot, which I don't understand what it's showing me. Can you please explain what it is and what you expected to see? – jeguyer Feb 13 '23 at 14:58
  • Hello and Thank you for your contribution sir. The question edited for clarification. I hope the problem is clear now. @jeguyer – HadiMorovvatju Feb 15 '23 at 07:24
  • No sir. Itasca does not natively import Gmsh mesh but understands it through Fipy. In other words I imported mesh in Itasca using Fipy Gmsh mesh capability. You can see details in python code at the end of the post. @jeguyer – HadiMorovvatju Feb 15 '23 at 07:28
  • Thank you sir. I cant put in words how much I appreciate your generosity . Be safe. @jeguyer – HadiMorovvatju Feb 15 '23 at 21:09
  • To whomever keeps corn-fielding my comments, would you care to tell me why it's unacceptable to point to SO's own documentation on how to accept answers? To @HadiMorovvatju, I was happy to help. – jeguyer Feb 17 '23 at 00:55
  • @HadiMorovvatju: please do click below to accept the answer if you're indeed happy with it. – wd15 Feb 17 '23 at 16:12

1 Answers1

1

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

  • the nodes you pass to create_mesh() describe two quadrilaterals for each cell, parallel to the yz plane, whereas Itasca and Gmsh both want the two faces of a hexahedron to be parallel to the xy plane.
  • _cellVertexIDs does not guarantee any particular ordering and I find that different cells can be mirrored and twisted with respect to each other (FiPy doesn't use _cellVertexIDs for anything other than testing some known meshes, so we don't care that the ordering isn't consistent). There is a separate _orderedCellVertexIDs property that preserves the ordering of Gmsh elements.

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.

jeguyer
  • 2,379
  • 1
  • 11
  • 15