Closed OpenFoam-User closed 5 months ago
Hey,
this is definitely something I would like to implement in the near future.
In order to use the current state of the code, you could try exporting the meshes as VTU files and then convert them to the OpenFOAM format using auxiliary tools, such as for example meshio.
Do you think this could work?
Greetings Flo
Hi, Thank you for your reply.
Unfortunately, accoding to my experience with meshio (using it for some time), it is unreliable at best. In particular the VTK/VTU et al. formats are very buggy, and in most cases it is not possible to get them to convert to OpenFOAM format properly.
Supporting OpenFOAM in TQMesh, in my opinion, is the right way to achieve this.
Best regards.
Hey,
I guess you're right!
Is there any way to test such a grid file if it fits the OpenFOAM format without installing OpenFOAM? This would make things a lot easier... ;-)
Regards, Flo
Hey,
I guess you're right!
Is there any way to test such a grid file if it fits the OpenFOAM format without installing OpenFOAM? This would make things a lot easier... ;-)
Regards, Flo
Hi, thank you for your reply.
The easiest way I can think of is to use Paraview to open OpenFOAM meshes. You can download Paraview from the official website: https://www.paraview.org/download/
To open the Mesh, you need the following minimal setup (it doesn't require the 0 and system folders that are typically used by all OpenFOAM simulations):
$ tree .
.
├── constant
│ └── polyMesh
│ ├── boundary
│ ├── cells
│ ├── faces
│ ├── neighbour
│ ├── owner
│ └── points
└── test.foam
You need a folder named constant
which contains a subfolder named polyMesh
. The later contains the mesh files (boundary, points, faces, ... etc.).
To open the mesh in Paraview, you need to create an empty file with the extension .foam
. For example touch test.foam
. from Paraview, select File > Open ... to select the .foam
file.
Hey,
thanks - this helped me a lot!
So I added a small python script which converts a TQMesh text file into the mentioned openFOAM directory structure including the different mesh files.
You can find it here in the "develop" branch.
However, I am not sure if I got the face-orientation and the resulting direction between owner- and neighbor-elements correctly. Would you mind to test the script and check if its output files can be read into openFOAM? At least Paraview seems to be fine with it...
Thank you very much for your help!
Regards, Flo
Many thanks for your work.
Here is a link to the documenation about OpenFOAM meshes: https://www.openfoam.com/documentation/user-guide/4-mesh-generation-and-conversion/4.1-mesh-description
Meanwhile, could you please provide some meshes to play with? I am right now on Windows and I don't have TQMesh installed.
Regards
Hey there,
here is a sample file, that stems from example 1 (a simple triangular mesh): simple_triangular_mesh.txt
The python script to convert this file as an OpenFOAM mesh should also work on a Windows machine.
In case that it is not possible for you to run the script, here are the respective output-files of that script in a zip-file: simple_triangular_mesh.zip
Thank you very much for your help!
Regards, Flo
I just figured that the simple_triangular_mesh
example only features triangular elements.
For the testing purpose, it would be probably better to check if quad-elements do also work.
Here is another converted mesh, which features both element types:
fixed_vertices.zip
Greetings Flo
Hi.
I have played with fixed_vertices.zip
. It opens in Paraview but unfortunately has some issues when checked with OpenFOAM.
To check the mesh, I have run the OpenFOAM command checkMesh
and here are the results:
/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2312 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : _c39a0f64-20231220 OPENFOAM=2312 version=2312
Arch : "LSB;label=32;scalar=64"
Exec : checkMesh
Date : Mar 18 2024
Time : 13:36:17
Host : PC1053
PID : 2490
I/O : uncollated
Case : /mnt/c/Users/user/Desktop/test/tests/fixed_vertices
nProcs : 1
trapFpe: Floating point exception trapping enabled (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 5, maxFileModificationPolls 20)
allowSystemOperations : Allowing user-supplied system call operations
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time
Create mesh for time = constant
Check mesh...
Time = constant
Mesh stats
points: 2352
internal points: 0
faces: 7430
internal faces: 3176
cells: 2085
faces per cell: 5.08681
boundary patches: 3
point zones: 0
face zones: 0
cell zones: 0
Overall number of cells of each type:
hexahedra: 181
prisms: 0
wedges: 0
pyramids: 0
tet wedges: 0
tetrahedra: 0
polyhedra: 1904
Breakdown of polyhedra by number of faces:
faces number of cells
5 1904
Checking topology...
Boundary definition OK.
Cell to face addressing OK.
Point usage OK.
***Faces not in upper triangular order.
<<Writing 3176 unordered faces to set upperTriangularFace
Face vertices OK.
Number of regions: 1 (OK).
Checking patch topology for multiply connected surfaces...
Patch Faces Points Surface topology
boundary_1 84 168 ok (non-closed singly connected)
boundary_2 2085 1176 ok (non-closed singly connected)
boundary_3 2085 1176 ok (non-closed singly connected)
".*" 4254 2352 ok (closed singly connected)
Checking faceZone topology for multiply connected surfaces...
No faceZones found.
Checking basic cellZone addressing...
No cellZones found.
Checking basic pointZone addressing...
No pointZones found.
Checking geometry...
Overall domain bounding box (0 0 0) (3 3 1)
Mesh has 3 geometric (non-empty/wedge) directions (1 1 1)
Mesh has 3 solution (non-empty) directions (1 1 1)
Boundary openness (-2.13504e-18 0 -5.81691e-16) OK.
Max cell openness = 1.73184e-16 OK.
Max aspect ratio = 594.128 OK.
Minimum face area = 1.06401e-05. Maximum face area = 0.320113. Face area magnitudes OK.
Min volume = 3.54668e-06. Max volume = 0.0119652. Total volume = 2. Cell volumes OK.
Mesh non-orthogonality Max: 31.9636 average: 11.8505
Non-orthogonality check OK.
***Error in face pyramids: 4170 faces are incorrectly oriented.
<<Writing 4170 faces with incorrect orientation to set wrongOrientedFaces
Max skewness = 2.4877 OK.
Coupled point location match (average 0) OK.
Failed 2 mesh checks.
End
The command checkMesh
will created two files for the two errors under constant/polyMesh/sets
which are:
upperTriangularFace
wrongOrientedFaces
Hey,
thanks a lot! I guess the faces are not yet oriented correctly. I adjusted the script a little, such that the orientation should now be in accordance to the mesh format you showed me in the link above (at least I hope so...).
Maybe you could try if checkMesh
will accept this updated mesh:
fixed_vertices.zip
Otherwise, I will probably need to install openFOAM to debug this... ;-)
Anyway, thank you very much for helping!
Greetings Flo
Thanks for the update.
Unfortunately, the number of errors now increased to 5 as you can see below:
Check mesh...
Time = constant
Mesh stats
points: 2352
internal points: 0
faces: 7430
internal faces: 3176
cells: 2085
faces per cell: 5.08681
boundary patches: 3
point zones: 0
face zones: 0
cell zones: 0
Overall number of cells of each type:
hexahedra: 181
prisms: 0
wedges: 0
pyramids: 0
tet wedges: 0
tetrahedra: 0
polyhedra: 1904
Breakdown of polyhedra by number of faces:
faces number of cells
5 1904
Checking topology...
Boundary definition OK.
Cell to face addressing OK.
Point usage OK.
***Faces not in upper triangular order.
<<Writing 3176 unordered faces to set upperTriangularFace
Face vertices OK.
Number of regions: 1 (OK).
Checking patch topology for multiply connected surfaces...
Patch Faces Points Surface topology
boundary_1 84 168 ok (non-closed singly connected)
boundary_2 2085 1176 ok (non-closed singly connected)
boundary_3 2085 1176 ok (non-closed singly connected)
".*" 4254 2352 ok (closed singly connected)
Checking faceZone topology for multiply connected surfaces...
No faceZones found.
Checking basic cellZone addressing...
No cellZones found.
Checking basic pointZone addressing...
No pointZones found.
Checking geometry...
Overall domain bounding box (0 0 0) (3 3 1)
Mesh has 3 geometric (non-empty/wedge) directions (1 1 1)
Mesh has 3 solution (non-empty) directions (1 1 1)
Boundary openness (2.13504e-18 0 5.81687e-16) OK.
***High aspect ratio cells found, Max aspect ratio: 2.02375e+99, number of cells 2085
<<Writing 2085 cells with high aspect ratio to set highAspectRatioCells
Minimum face area = 1.06401e-05. Maximum face area = 0.320113. Face area magnitudes OK.
***Zero or negative cell volume detected. Minimum negative volume: -0.0119652, Number of negative volume cells: 2085
<<Writing 2085 zero volume cells to set zeroVolumeCells
Mesh non-orthogonality Max: 180 average: 168.15
***Number of non-orthogonality errors: 3176.
<<Writing 3176 non-orthogonal faces to set nonOrthoFaces
***Error in face pyramids: 6436 faces are incorrectly oriented.
<<Writing 3260 faces with incorrect orientation to set wrongOrientedFaces
Max skewness = 2.4877 OK.
Coupled point location match (average 0) OK.
Failed 5 mesh checks.
End
Thanks! I had to do some minor changes but finally got it working - does checkMesh also proceed for you?
It seems to work with most of the meshes from the examples. However, for some examples checkMesh still has some problems. But this could also be related to the meshes...
Anyway, I hope for now the script should work.
Thanks for sharing your idea and for your help! :-)
Cheers Flo
Thank you for the update!
Indeed the new script fixes the issues with the first mesh. I have also tried it with the second example 02_square_in_channel
but got a failing mesh due to some non-closed cells.
Check mesh...
Time = constant
Mesh stats
points: 6616
internal points: 0
faces: 12777
internal faces: 6161
cells: 3159
faces per cell: 5.99494
boundary patches: 6
point zones: 0
face zones: 0
cell zones: 0
Overall number of cells of each type:
hexahedra: 3147
prisms: 0
wedges: 0
pyramids: 0
tet wedges: 0
tetrahedra: 0
polyhedra: 12
Breakdown of polyhedra by number of faces:
faces number of cells
4 4
5 8
Checking topology...
Boundary definition OK.
Cell to face addressing OK.
Point usage OK.
Upper triangular ordering OK.
Face vertices OK.
Number of regions: 1 (OK).
Checking patch topology for multiply connected surfaces...
Patch Faces Points Surface topology
boundary_1 38 84 ok (non-closed singly connected)
boundary_2 184 376 ok (non-closed singly connected)
boundary_3 28 62 ok (non-closed singly connected)
boundary_4 48 106 ok (non-closed singly connected)
boundary_5 3159 3308 ok (non-closed singly connected)
boundary_6 3159 3308 ok (non-closed singly connected)
".*" 6616 6616 ok (closed singly connected)
Checking faceZone topology for multiply connected surfaces...
No faceZones found.
Checking basic cellZone addressing...
No cellZones found.
Checking basic pointZone addressing...
No pointZones found.
Checking geometry...
Overall domain bounding box (0 0 0) (4 1 1)
Mesh has 3 geometric (non-empty/wedge) directions (1 1 1)
Mesh has 3 solution (non-empty) directions (1 1 1)
Boundary openness (0 -2.91857e-17 -7.47199e-16) OK.
***Open cells found, max cell openness: 1, number of open cells 12
<<Writing 12 non closed cells to set nonClosedCells
Minimum face area = 1.59115e-05. Maximum face area = 0.0995267. Face area magnitudes OK.
Min volume = 2.15574e-05. Max volume = 0.00562089. Total volume = 3.90993. Cell volumes OK.
Mesh non-orthogonality Max: 47.6795 average: 12.1584
Non-orthogonality check OK.
Face pyramids OK.
Max skewness = 1.46892 OK.
Coupled point location match (average 0) OK.
Failed 1 mesh checks.
Thanks! I figured out that these errors are actually attributed to the meshes and not to the conversion script. This will be fixed in the coming release.
Greetings Flo
Hello, This is a very nice project.
I wonder if there are plans to support OpenFOAM mesh format? That would be very useful for the OpenFOAM community.
Best regards