|
[Sponsors] |
[Fortran]Transform ICEM mesh file format to Fortran use |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
New Member
XIE JIN
Join Date: Apr 2022
Location: Sydney AU
Posts: 15
Rep Power: 4 ![]() |
Hello everyone,
Do you know how to transform mesh file generated by ICEM to the data format that can be used by Fortran, Coding a complex geometry is very difficult for me. Thanks in advance. Best Jin |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
|
Fortran is a general, low level, programming language that can read any binary or text file.
However, the concept of having some command that will automagically read a full mesh file in an arbitrary format is just wrong, such thing doesn't exist in Fortran or any other programming language. Not even MATLAB (where the availability of several advanced functions might have led you to think so), because would be too specific even for it. What you're looking for is some actual piece of code that would do exactly that, read the mesh file record by record and store that information. I have no idea if there is any such piece of code out there, publicly available. Let me also add that, while I don't specifically know ICEM, it is very likely that it actually outputs its mesh in a number of formats used in several solvers. So, for example, you might find a Fortran code that reads a certain mesh format that is among the ones allowed in output for ICEM. But even in that case, my experience is that you never find full fledged mesh reader out in the wild. Typically, they are either outdated or too simple for several practical cases. So, depending on your needs, you might have to write that code yourself. |
|
![]() |
![]() |
![]() |
![]() |
#3 | |
New Member
XIE JIN
Join Date: Apr 2022
Location: Sydney AU
Posts: 15
Rep Power: 4 ![]() |
Quote:
Thank you very much for your opinion. Your understanding is right and I need some lines of codes that can be used to transform formats that I can use. I opened the .msh file generated by ICEM and found they are data like coordinates of nodes and I'm trying to find some methods to number these nodes and use some statements to read them. |
||
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
|
Looks like a Fluent mesh file in ascii format. Is it so? It shouldn't be difficult to read but, your comment on "finding some method to number them" indicates you need to first understand better how these files are written and that it won't be exactly easy or fast, given the point where you are (as, for example, the nodes are numbered, and referred to in the rest of the file, following the order they are written to file; same for faces and cells).
What is your end goal? Why do you want to read such a mesh file in Fortran? |
|
![]() |
![]() |
![]() |
![]() |
#5 | |
New Member
XIE JIN
Join Date: Apr 2022
Location: Sydney AU
Posts: 15
Rep Power: 4 ![]() |
Quote:
|
||
![]() |
![]() |
![]() |
![]() |
#6 |
Senior Member
|
Then, I guess, you need to delve into the structure of a Fluent mesh file. Note that, especially in ascii format, it is not very difficult to process, as long as you do not have to deal with more complicated stuff like periodic boundaries or hanging nodes. The Fluent user guide explains the format very clearly. I suggest you to start making a very simple mesh of a cube (say, 3x3x3 cells) and use that as reference to study and understand the format.
Numberings are implicit, the node number n referred to in the faces sections is the (n+1)-th (as it is C based numbering) in the list of nodes written in the file. Same for the C0-C1 cells referenced at the end of each face. However, additional info (e.g., the nodes of a cell, the faces of a cell, etc.) must be built. The book by Lohner has a section on such things that you may find useful. |
|
![]() |
![]() |
![]() |
![]() |
#7 |
Senior Member
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,282
Rep Power: 34 ![]() ![]() |
You can download wildkatze and convert fluent file to bmsh format.
This bmsh format you can very easily read with simple c or fortran code. The format is designed for it. https://fvus.github.io/wildkatze/ins...load-wildkatze Here the first step you do is to convert the mesh. If you decide to use bmsh then let me know i will show you the format. (which is basically just values put into a file) |
|
![]() |
![]() |
![]() |
![]() |
#8 | |
New Member
XIE JIN
Join Date: Apr 2022
Location: Sydney AU
Posts: 15
Rep Power: 4 ![]() |
Quote:
|
||
![]() |
![]() |
![]() |
![]() |
#9 | |
New Member
XIE JIN
Join Date: Apr 2022
Location: Sydney AU
Posts: 15
Rep Power: 4 ![]() |
Quote:
I followed your Youtube installation tutorial step by step, but I met an error as shown in attachment. Do you know how to solve it? I tried many ways but they don't work. |
||
![]() |
![]() |
![]() |
![]() |
#10 |
Senior Member
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,282
Rep Power: 34 ![]() ![]() |
you do not need to run the gui.
mpirun -np 1 ./wildkatze -lc fluent2bmsh fluentmesh should do the job. I will put you a simple c++ code that loads bmsh and you can use that. |
|
![]() |
![]() |
![]() |
![]() |
#11 | |
Senior Member
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,282
Rep Power: 34 ![]() ![]() |
Quote:
This error is due to java. You need to google this error because some java are doing this. (some java seem to be missing awt) |
||
![]() |
![]() |
![]() |
![]() |
#12 | |
New Member
XIE JIN
Join Date: Apr 2022
Location: Sydney AU
Posts: 15
Rep Power: 4 ![]() |
Quote:
I kindly appreciate your help. The command "solver.sh lc fluent2bmsh sample" works fine and I can follow the tutorial to run the sample calculation, but if I use "mpirun -np 1 ./wildkatze -lc fluent2bmsh sample", it gives mpirun was unable to launch the specified application as it could not access or execute an executable: Executable: ./wildkatze Node: xiejin while attempting to start process rank 0." Is it okay that I use the command "solver.sh lc fluent2bmsh sample" to transform mesh? In addition, could you plz tell me your mentioned c++ code to transform the mesh that I can use. Thank you so much. |
||
![]() |
![]() |
![]() |
![]() |
#13 |
Senior Member
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,282
Rep Power: 34 ![]() ![]() |
I attach you a simple C++ class that loads the bmsh file and store it at region object.
You can retrive the data from it. JUST NOTE that following the fluent file format the cells are indexed from 1, ... NCells. The boundaries shall have 0 as right cell index. |
|
![]() |
![]() |
![]() |
![]() |
#14 | |
New Member
XIE JIN
Join Date: Apr 2022
Location: Sydney AU
Posts: 15
Rep Power: 4 ![]() |
Quote:
I really appreciate your time and the codes. I am really new in c++ and I don't know how to properly run the codes. I transformed the mesh from Fluent to bmsh by Wildkatze, and now I try to use Microsoft Visual c++ 6.0 to run the codes. I put sample.bmsh and sample.info.bmsh into file folder containing c++ codes you shared. After compiling the cpp codes, it gives the following errors, what should I do? Should I modify some codes in the cpp codes? --------------------Configuration: BMeshObject - Win32 Debug-------------------- Compiling... BMeshObject.cpp C:\Users\z5345552\OneDrive - UNSW\Desktop\Meshtrans\bmsh\BMeshObject.cpp(21) : error C2664: 'void __thiscall std::basic_fstream<char,struct std::char_traits<char> >: ![]() char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called C:\Users\z5345552\OneDrive - UNSW\Desktop\Meshtrans\bmsh\BMeshObject.cpp(293) : error C2039: 'data' : is not a member of 'vector<double,class std::allocator<double> >' C:\Users\z5345552\OneDrive - UNSW\Desktop\Meshtrans\bmsh\BMeshObject.cpp(294) : error C2039: 'data' : is not a member of 'vector<double,class std::allocator<double> >' C:\Users\z5345552\OneDrive - UNSW\Desktop\Meshtrans\bmsh\BMeshObject.cpp(295) : error C2039: 'data' : is not a member of 'vector<double,class std::allocator<double> >' C:\Users\z5345552\OneDrive - UNSW\Desktop\Meshtrans\bmsh\BMeshObject.cpp(297) : error C2039: 'data' : is not a member of 'vector<int,class std::allocator<int> >' C:\Users\z5345552\OneDrive - UNSW\Desktop\Meshtrans\bmsh\BMeshObject.cpp(298) : error C2039: 'data' : is not a member of 'vector<int,class std::allocator<int> >' C:\Users\z5345552\OneDrive - UNSW\Desktop\Meshtrans\bmsh\BMeshObject.cpp(393) : error C2374: 'r' : redefinition; multiple initialization C:\Users\z5345552\OneDrive - UNSW\Desktop\Meshtrans\bmsh\BMeshObject.cpp(134) : see declaration of 'r' C:\Users\z5345552\OneDrive - UNSW\Desktop\Meshtrans\bmsh\BMeshObject.cpp(404) : error C2374: 'r' : redefinition; multiple initialization C:\Users\z5345552\OneDrive - UNSW\Desktop\Meshtrans\bmsh\BMeshObject.cpp(134) : see declaration of 'r' Error executing cl.exe. BMeshObject.obj - 8 error(s), 0 warning(s) Thank you again! |
||
![]() |
![]() |
![]() |
![]() |
#15 |
Senior Member
|
If you will accept the fact that I won't be able to help you in any case and that the approach might be naive and flawed with respect to a certain number of aspects, then you might want to give a look at the attached matlab file (I had to chang the extension to upload it here). It reads (or, at least it still should) Fluent/Gambit .msh files in ASCII format.
I developed it as a student for learning purposes on ustructured FV methods, so it is naive and limited and possibly erroneous in some ways that I would be unable to tell you as of today. But it used to work and, if Fortran is what you want, this might be close enough for you to develop YOUR solution. DO NOT just follow it row by row, use it to learn what's inside the .msh file and try to figure out by yourself how to do what you need. Let me restate again that this is not something I'm interested in maintaining or supporting. So, if you want to use this, you are on your own. |
|
![]() |
![]() |
![]() |
![]() |
#16 | |
New Member
XIE JIN
Join Date: Apr 2022
Location: Sydney AU
Posts: 15
Rep Power: 4 ![]() |
Quote:
Thank you pretty much, I will look at it and study the idea for matlab, and I will also study the Fluent mesh file format. As you said, the idea should be similar for Fortran. |
||
![]() |
![]() |
![]() |
![]() |
#17 | |
Senior Member
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,282
Rep Power: 34 ![]() ![]() |
Quote:
Somehow your compiler is having problem with std::vector and std::string etc. Very strange. The code that i gave you compiles fine on gnu machine and i have tested it by loading the bmsh file before i passed to you. You can simply read the code to see that the format is simple. You can re-write it using the files i provided (its not complicated). |
||
![]() |
![]() |
![]() |
![]() |
#18 | |
New Member
XIE JIN
Join Date: Apr 2022
Location: Sydney AU
Posts: 15
Rep Power: 4 ![]() |
Quote:
xiejin@L-C2N69K3:~/bmsh$ g++ BMeshObject.cpp -o test /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: In function `_start': (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status |
||
![]() |
![]() |
![]() |
Tags |
fortran, icem, mesh format |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using PengRobinsonGas EoS with sprayFoam | Jabo | OpenFOAM Running, Solving & CFD | 36 | July 16, 2024 03:52 |
Custom Thermophysical Properties | wsmith02 | OpenFOAM | 4 | June 1, 2023 14:30 |
centOS 5.6 : paraFoam not working | yossi | OpenFOAM Installation | 2 | October 9, 2013 01:41 |
"parabolicVelocity" in OpenFoam 2.1.0 ? | sawyer86 | OpenFOAM Running, Solving & CFD | 21 | February 7, 2012 11:44 |
DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 17:51 |