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

Gmsh version must be >= 2.0 in PFC software mesh calling #784

Closed
alisheikholeslam opened this issue Feb 28, 2021 · 15 comments
Closed

Gmsh version must be >= 2.0 in PFC software mesh calling #784

alisheikholeslam opened this issue Feb 28, 2021 · 15 comments

Comments

@alisheikholeslam
Copy link

alisheikholeslam commented Feb 28, 2021

I haved used FiPy.Gmsh3D(.msh) to open gmsh2 file by python v2.7.9, within PFC software which using FiPy v3.1, and the error below was appeared, I would be appreciated if you could help me to solve this error. By my searching, some other PFC users was struggling with this error. FiPy and Python couldn't be updated to newer versions.

IPython QtConsole 3.1.0
Python 2.7.9 (default, Jan 13 2015, 08:39:28) [MSC v.1500 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 3.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
%guiref   -> A brief reference about the graphical user interface.
Traceback (most recent call last):
  File "<itasca-code-0-667c6ce5de1e>", line 116, in <module>
  File "<itasca-code-0-667c6ce5de1e>", line 11, in __init__
  File "C:\Program Files\Itasca\PFC500\exe64\python27\lib\site-packages\fipy\meshes\gmshMesh.py", line 1937, in __init__
    background=background)
  File "C:\Program Files\Itasca\PFC500\exe64\python27\lib\site-packages\fipy\meshes\gmshMesh.py", line 151, in openMSHFile
    raise EnvironmentError("Gmsh version must be >= 2.0.")
EnvironmentError: Gmsh version must be >= 2.0.
@guyer
Copy link
Member

guyer commented Mar 1, 2021

  • What version of FiPy are you using?
    import fipy
    print(fipy.__version__)
  • What does gmsh --version return when run from the command line?

@guyer
Copy link
Member

guyer commented Mar 1, 2021

Based on the line numbers of the error messages you posted, you are running FiPy 3.1.3 or older, which is at least three years old. Based on the fact that you're getting this error message, I'd guess that you're FiPy installation is five to seven years old.

Please upgrade FiPy.

@guyer guyer closed this as completed Mar 1, 2021
@alisheikholeslam
Copy link
Author

Yes, you're right. FiPy is in version 3.1 as I mentioned in the explanation above. There is not any separated used gmsh software or library, the gmsh file is converted from vtk file by 'meshio' in gmsh -2 format. Is there any other solution way instead of upgrading? because FiPy and Python (version 2.7, which is embedded in PFC) are part of the main software, PFC, and connection between them are programmed by ITSASCA PFC programmers. Thus, the way to upgrade them is not easy as we thought.
Thank you for your reply.

@wd15
Copy link
Contributor

wd15 commented Mar 1, 2021

Is this one the same question as this Stackoverflow question?

@guyer
Copy link
Member

guyer commented Mar 2, 2021

Are you using an extremely old version of itasca? I've never used it, but googling "itasca fipy" turns up:

  • This says "Oct 15, 2019...Update FiPy Python module."
  • This says "Adding utility to convert a FLAC3D mesh into a FiPy mesh...jkfurtney committed on Jul 23, 2020"

It seems improbable that either of those is talking about a version of FiPy that was released in 2013.

If they really haven't upgraded in that long, then @jkfurtney (CTO of Itasca) offered this on our mailing list many years ago (when it was still necessary):

I use the following "monkey patch" to get around this problem. Just
include these lines at the top of your FiPy script.

import fipy
fipy.meshes.gmshMesh._gmshVersion = lambda **kwargs : 2.0

@alisheikholeslam
Copy link
Author

Is this one the same question as this Stackoverflow question?

No, this is for the later stage. This error is appeared after trying to import the mesh, which mentioned in that link as 'worked', into PFC software by FiPy embedded lib.

@alisheikholeslam
Copy link
Author

Are you using an extremely old version of itasca? I've never used it, but googling "itasca fipy" turns up:

  • This says "Oct 15, 2019...Update FiPy Python module."
  • This says "Adding utility to convert a FLAC3D mesh into a FiPy mesh...jkfurtney committed on Jul 23, 2020"

It seems improbable that either of those is talking about a version of FiPy that was released in 2013.

If they really haven't upgraded in that long, then @jkfurtney (CTO of Itasca) offered this on our mailing list many years ago (when it was still necessary):

I use the following "monkey patch" to get around this problem. Just
include these lines at the top of your FiPy script.

import fipy
fipy.meshes.gmshMesh._gmshVersion = lambda **kwargs : 2.0

my version is not very old but there are lots of improvements on the next version, as I searched. I think errors that I'm facing to are solved in the new version. I tried Mr. Furtney solution way, that pass this error and I'm now facing with new error which, I think, is related to my windows variables ... .
I'm using PFC version 5 because my complicated simulations and codes are based on this version, and all of them must be changed and adapted to the new versions, which is very time consuming. I have used 'updated FiPy module' that you mentioned, which is updated by ITASCA, but I couldn't use that update by my version and result in errors, that shows it is adapted by new version of PFC. I guess these errors are solved by updates in new version, which uses FiPy version 3.1, yet, as it is written in its documentation.

@guyer
Copy link
Member

guyer commented Mar 2, 2021

I see. It looks like Itasca 5 was last updated in mid-2019. I assume they have their reasons for both embedding FiPy and not updating it in a recently-supported version. If they're running a Python interpreter, it should be possible for you to manually update FiPy, but you'd need to ask the Itasca developers how to do that.

I tried Mr. Furtney solution way, that pass this error and I'm now facing with new error which, I think, is related to my windows variables ... .

OK, what is the new error?

@guyer guyer reopened this Mar 2, 2021
@alisheikholeslam
Copy link
Author

I see. It looks like Itasca 5 was last updated in mid-2019. I assume they have their reasons for both embedding FiPy and not updating it in a recently-supported version. If they're running a Python interpreter, it should be possible for you to manually update FiPy, but you'd need to ask the Itasca developers how to do that.

I tried Mr. Furtney solution way, that pass this error and I'm now facing with new error which, I think, is related to my windows variables ... .

OK, what is the new error?

Before anything else, thank you for your follow-up and responses dear Dr. Guyer,
I would try to upgrade FiPy. does latest FiPy version can be added to python 2.7 ? I tried to install FiPy on pycharm, and on python 2.7, but I couldn't install the latest one and I forced to install version 3.1.3. but I could install the latest one on python 3.8 . I didn't try install FiPy by conda, perhaps I must to do by conda. (Could this be the reason ITASCA didn't upgrade FiPy?).

The new error is :

Traceback (most recent call last):
File "", line 118, in
File "", line 13, in init
File "C:\Program Files\Itasca\PFC500\exe64\python27\lib\site-packages\fipy\meshes\gmshMesh.py", line 1937, in init
background=background)
File "C:\Program Files\Itasca\PFC500\exe64\python27\lib\site-packages\fipy\meshes\gmshMesh.py", line 228, in openMSHFile
stdout=PIPE)
File "C:\Program Files\Itasca\PFC500\exe64\python27\lib\subprocess.py", line 710, in init
errread, errwrite)
File "C:\Program Files\Itasca\PFC500\exe64\python27\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

@guyer
Copy link
Member

guyer commented Mar 2, 2021

Before anything else, thank you for your follow-up and responses dear Dr. Guyer,

You're welcome

I would try to upgrade FiPy. does latest FiPy version can be added to python 2.7 ? I tried to install FiPy on pycharm, and on python 2.7, but I couldn't install the latest one and I forced to install version 3.1.3. but I could install the latest one on python 3.8 . I didn't try install FiPy by conda, perhaps I must to do by conda. (Could this be the reason ITASCA didn't upgrade FiPy?).

FiPy supports both Python 2.7 and Python 3.x. We test on both.

conda is not required for installing FiPy (it's pure Python and can be installed with pip), but it's the easiest way to get some of FiPy's prerequisites. Still, if you already have the prerequisites, it should be possible to just update the FiPy Python package. I don't know how Itasca has its site-packages set up or anything, so I have no idea how to do that; you'd need to ask their support.

The new error is :
:
File "C:\Program Files\Itasca\PFC500\exe64\python27\lib\site-packages\fipy\meshes\gmshMesh.py", line 228, in openMSHFile
stdout=PIPE)

This line of code is for converting a Gmsh GEO file to a Gmsh MSH file. I thought you already had an MSH file? What is it called?

@alisheikholeslam
Copy link
Author

The new error is :
:
File "C:\Program Files\Itasca\PFC500\exe64\python27\lib\site-packages\fipy\meshes\gmshMesh.py", line 228, in openMSHFile
stdout=PIPE)

This line of code is for converting a Gmsh GEO file to a Gmsh MSH file. I thought you already had an MSH file? What is it called?

Is 'background=background', in line 1937, related to that you mentioned "converting a Gmsh GEO file to a Gmsh MSH file"?
I have converted an Ansys fluent ".msh" (which was exported from OpenFOAM for Ansys .msh format) file to gmsh format 2 ".msh" by meshio.
all my OpenFOAM exported meshes and the converted mesh is attached in the zip file.

Meshes.zip

@guyer
Copy link
Member

guyer commented Mar 3, 2021

Is 'background=background', in line 1937, related to that you mentioned "converting a Gmsh GEO file to a Gmsh MSH file"?

No, unless you provided a background= argument to Gmsh3D, its default value is None. Regardless, the background needs to be a POS file, not a GEO or MSH file. This has nothing to do with the error on line 228.

I have converted an Ansys fluent ".msh" (which was exported from OpenFOAM for Ansys .msh format) file to gmsh format 2 ".msh" by meshio.
all my OpenFOAM exported meshes and the converted mesh is attached in the zip file.

Meshes.zip

You're trying to load Converted.msh? This file reads fine for me using either FiPy 3.1 or FiPy 3.4.2.

The error at line 227 means that FiPy thinks it's trying to read GEO file. This can happen for two reasons:

  • The argument to Gmsh3D isn't a file path to an existing file
  • The file that is referred to doesn't start with "$MeshFormat" (Converted.msh does start with this line).

Please show everything that you're doing to get to this point.

Are these first lines of the traceback your code or are they Itasca code?

Traceback (most recent call last):
File "", line 118, in
File "", line 13, in __init__
  • If they're your code, please provide it.
  • If they're Itasca's, what do you do to tell Itasca what mesh file to use?

@alisheikholeslam
Copy link
Author

The error at line 227 means that FiPy thinks it's trying to read GEO file. This can happen for two reasons:

  • The argument to Gmsh3D isn't a file path to an existing file
  • The file that is referred to doesn't start with "$MeshFormat" (Converted.msh does start with this line).

yes, 'converted.msh' was the converted one.
Fortunately, the problem went away. The addressed mesh file path have a mistaken letter in it. It was my mistake. I'm sure I couldn't find the solutions so soon without your hints.
I sincerely appreciate your ongoing assistance and the time that you devoted to solve these errors, dear Dr. Guyer.

@guyer
Copy link
Member

guyer commented Mar 3, 2021

Glad to hear it's working for you.

@guyer guyer closed this as completed Mar 3, 2021
@chenyong97-cloud
Copy link

I see. It looks like Itasca 5 was last updated in mid-2019. I assume they have their reasons for both embedding FiPy and not updating it in a recently-supported version. If they're running a Python interpreter, it should be possible for you to manually update FiPy, but you'd need to ask the Itasca developers how to do that.

I tried Mr. Furtney solution way, that pass this error and I'm now facing with new error which, I think, is related to my windows variables ... .

OK, what is the new error?

Dear Dr.Guyer:
Now I am also troubled by the same problem. I wonder if you can help me find a solution.
Gmsh3D.zip

When I input the code(with Mr. Furtney solution way) in the attachment in PFC6.0 (the software has built-in version 3.6.1 of Ipython), the following error message appears:

IndexError Traceback (most recent call last)
C:\Program Files\Itasca\PFC600\exe64\python36\lib\site-packages\fipy\meshes\gmshMesh.py in read(self)
793 ghostsData,
--> 794 facesData) = self._parseElementFile()
795

C:\Program Files\Itasca\PFC600\exe64\python36\lib\site-packages\fipy\meshes\gmshMesh.py in _parseElementFile(self)
1123 geometricalEntity) = _parseTags(offset=faceOffset,
-> 1124 currLineInts=currLineInts)
1125 currLineInts[0] -= faceOffset

C:\Program Files\Itasca\PFC600\exe64\python36\lib\site-packages\fipy\meshes\gmshMesh.py in _parseTags(offset, currLineInts)
1052
-> 1053 numTags = currLineInts[2]
1054 tags = currLineInts[3:(3+numTags)]

IndexError: list index out of range

During handling of the above exception, another exception occurred:

PermissionError Traceback (most recent call last)
in ()
41 Surface Loop(33) = {27, 28, 29, 30, 31, 32};
42 Volume(34) = {33};
---> 43 ''' % locals())
44

C:\Program Files\Itasca\PFC600\exe64\python36\lib\site-packages\fipy\meshes\gmshMesh.py in init(self, arg, communicator, order, background)
1942 self.cellGlobalIDs,
1943 self.gCellGlobalIDs,
-> 1944 self._orderedCellVertexIDs_data) = self.mshFile.read()
1945
1946 self.mshFile.close()

C:\Program Files\Itasca\PFC600\exe64\python36\lib\site-packages\fipy\meshes\gmshMesh.py in read(self)
851 finally:
852 os.unlink(self.nodesPath)
--> 853 os.unlink(self.elemsPath)
854 if self.namesPath is not None:
855 os.unlink(self.namesPath)

PermissionError: [WinError 32] Another program is using this file, and the process cannot access it : 'C:\Users\chenyong\AppData\Local\Temp\tmpvgib8l76Elements'
Gmsh3D.zip
Gmsh3D.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants