SimScale CAE Forum

Running OpenFoam checkMesh -writeAllFields on a SimScale .h5m or .vtu mesh file


#2

Hey Dale,

Forwarded your question - let’s see what you can achieve here.

Best,

Jousef


#3

Hello Dale,
Although is far from ideal, the easiest thing you could do is set up a simple CFD analysis, run 1 time step and download the results (that obviously contains the mesh in Openfoam format).

Best

Edoardo


#4

Hi Edoardo,

LOL, Ric beat me in testing your idea…

Unfortunately, the ‘Standard’ solver not only saves meshes in different formats, but seems to generate a different TET mesh between ‘Static’ FEA and ‘CFD’ simulations… Ric said the CFD version mesh with same settings had a different number of cells :frowning:

We are on a track the lets us think we can do a conversion of the .h5m mesh into a format that OpenFoam checkmesh likes…

Dale


#5

Hey,

I was trying to help Dale on this one. Just to give an example of FEA and CFD standard meshes:

A standard mesh made under an incompressible analysis:


And a standard mesh made under a static analysis:

Do you think there’s a way to somehow grab the “static” mesh and use it for an incompressible analysis? I tried to download and upload it, but this .h5m format is not accepted


#6

Hi all,

Agreed on if there is a way to translate h5m files to something that checkmesh can be used on would be great. Since working with snappyhex, tet meshes are not able to be used when they are needed. For example if i have a super complex geometry but I just want to get a mesh using the tet cells, no way to do a checkmesh to determine what is erroneous.

Cheers everyone.


#7

Ric, have you made any progress on that MOAB install into BlueCFD that we talked about?


#8

Nop, after documenting it I didn’t try other options


#9

Ok then, continuing our quest for .h5m conversion is still on our ‘ToDo’ list …

Unless there is a Linux/C++/GCC expert watching this topic who can build MOAB for use in BlueCFD :pray:

Here is what is at the top of a blueCFD window:
’Setting environment for OpenFOAM 5.x mingw-w64 Double Precision (of5-64), using MSMPI71’

And Mingw-w64 is created to support the GCC compiler on Windows systems.

The killing issue right now in the MOAB build process is that there is no ‘autoreconf’ available in the blueCFD terminal window :sob:


#10

A couple of months ago @DaleKramer and I found a way to run checkMesh on tet meshes used in CFD analysis (it doesn’t work for FEA meshes).

For tet meshes, you need to download the results of a full run (even a 1 iteration run should work). For hex meshes, downloading the mesh file also works.

So after downloading the zip file with the results, you have to extract it to a folder. The folder should look like this:

image

Using a “Windows version” of OF (blueCFD) you can do the following:

  • Change the directory to the mesh folder that you want to analyze. The command should look like this (depending on where your folder is):

image

For the folder from the picture above, the command would be:

image

  • Then simply run:

checkMesh

And then you get the mesh quality report:

image


#11

Ah yes now I remember… thanks Ric.

But I prefer to right click ON the directory where the case.foam file exists and then selecting, from the right click menu, to open BlueCFD at the mesh directory, like this:

And then in the BlueCFD terminal that pops up (now conveniently navigated to the case.foam directory), enter your checkmesh commad:


#12

If you want to see, in the blueCFD OpenFoam checkmesh results, the same quality parameters (and at the same trigger levels for illegal cell determination) which appear in the SimScale meshing log of a Hex parametric mesh, like this:

Here is the procedure:

  1. Place this text in file named ‘meshQuailtyDict’ (caps important and it can not have a file extension):
    /------------- C++ --------------
    |OpenFOAM:The Open Source CFD Toolbox|
    | Version: 4.x DaleKramer V1.0 |
    | Web: www.OpenFOAM.org |
    *-----------------------------------*/
    FoamFile
    {
    version 2.0;
    format ascii;
    class dictionary;
    object meshQualityDict;
    }
    // ********************************** //
    #includeEtc “caseDicts/meshQualityDict”
    maxNonOrtho 70;
    minVol 1e-13;
    maxConcave 80;
    maxInternalSkewness 4;
    maxBoundarySkewness 20;
    minFaceWeight 0.02;
    minVolRatio 0.01;
    minArea -1;
    minTwist 0.01;
    minDeterminant 0.001;
    minTetQuality -1e+30;
    minTriangleTwist -1;
    nSmoothScale 4;
    errorReduction 0.75;
    minVolCollapseRatio 0.5;
    minFaceFlatness -1;
    relaxed
    {
    maxNonOrtho 0.75;
    }
    // ********************************** //

  2. Place that file in the ‘system’ folder that is in the directory where the case.foam file is located.

  3. Use the -meshQuality parameter for the checkmesh command.

NOTE with regard to trigger values in the above meshQaulityDict:

minVolCollapseRatio [scalar]
minVolCollapseRatio:

// if >0 : preserve single cells with all points on the surface if the
// resulting volume after snapping (by approximation) is larger than
// minVolCollapseRatio times old volume (i.e. not collapsed to flat cell).
// If <0 : delete always.
//minVolCollapseRatio 0.5;

That comes from here:
https://www.openfoam.com/documentation/guides/latest/doc/guide-meshing-snappyhexmesh-meshquality.html

SimScale does not allow us to change the minVolCollapseRatio value (or the optional minFaceFlatness parm).

SimScale allows us to set all those other quality trigger in the HEXpara algo parms, SimScale defaults seems to use tighter trigger for minFaceWeight (0.02 vs OpenFoam 0.05) and minTwist (0.01 vs OpenFoam 0.02) AND SimScale uses default -1e-30 for minTetQuality vs OpenFoam default of 1e-15…

All other default Quality triggers used by SimScale are the same as the OpenFoam defaults for them. :slightly_smiling_face:
.
.
If you use the ‘-writeAllFields’ parameter with ‘checkmesh’, all the quality fields and there values for each cell will become available to view and filter in ParaView.

PLEASE NOTE THAT THE CURRENT VERSION OF OpenFoam supplied with blueCFD DOES NOT HAVE THE ‘-writeAllFields’ PARAMETER :sob:
.
.
.
.
If you want to create a .vtk file in the ‘postProcessing\constant\meshQualityFaces’ directory of the directory where the case.foam file is located (this .vtk file can be opened in ParaView so that you can see all the cells that failed the quality check):

NOTE: When using the -meshQuality -writeSets vtk parameters for checkMesh, AND there is a suitable meshQualityDict file in the system dir, a vtk file by the name of meshQualityFaces.vtk will be written in the postProcessing… dir which includes all faces that fail at their trigger points, of all items in the meshQualityDict file… Unfortunately, ParaView does not seem to be able to differentiate between what cells failed which tests, and again the only thing ParaView does is show you the face shape/size and where failed cells are in mesh. I do not see that this can help much in our mesh refinement process, but I presented the method above for completeness…
.
.
.
.
.
The ONLY way I have found so far to get non-ortho and skewness values for each cell in the mesh and then be able to view that ‘value’ data in ParaView, is to run the ‘writemeshquality’ OpenFoam command that needs to be loaded and built into blueCFD from its git repository.

You should be able to figure how to download and build ‘writeMeshQuality’ from this image:

That command puts gz files in the iteration 0 folder which can be viewed (including the parameter values :slight_smile: ) in ParaView with the ‘reload’ trick AFTER the case.foam is loaded and the mesh is seen on the screen. I see these .gz files helping us quite a bit in our mesh refinement process🙂 (IF WE CAN FIGURE OUT WHY THEIR MAX/MIN/AVERAGE parameter values do NOT match the SimScale ‘mesh log’ and the OpenFoam ‘checkmesh’ MAX/MIN/AVERAGE parameter values :disappointed: )

On that last point, on a spreadsheet analysis of the text data in the .gz files with regard to MAX/MIN/AVERAGE values, the analysis does NOT match the results that a ‘checkmesk’ command reports:


#13

Please, someone try the procedures Ric and I have posted here, so we can verify that what ‘we can do’, ‘you can also do’ :slight_smile:

If you can not do what we do, just post your issues here and we can explain further (it was not the easiest thing to figure out :wink: )…

And even if you succeed, please let us know that we helped somebody…
.
.
.
.
EDIT: It looks like the blueCFD terminal window is not a normal Linux install…

Here is what is at the top of a blueCFD window:
’Setting environment for OpenFOAM 5.x mingw-w64 Double Precision (of5-64), using MSMPI71’

And Mingw-w64 is created to support the GCC compiler on Windows systems.

But to answer this topic fully we still need a Linux/C++/GCC expert watching this topic who is willing to build MOAB for use in BlueCFD :pray:

The killing issue right now in the MOAB build process is that there is no ‘autoreconf’ available in the blueCFD terminal window :sob:


#14

Hi Dale and Ric,

Great post. I have used BlueCFD and i remembered now why I was unwilling to continue with it. However, for checkMesh it does make sense. Saves the hassle of needing to boot up in Ubuntu on my laptop.

BlueCFD was a problem for me back then as performance was a problem. I’m not sure if its possible to export out the checkMesh data to visualize it outside of BlueCFD via a native windows installed ParaView which can fully utilize the computing resources I have (namely my 32GBs of DDR4 RAM). This is especially useful if im running big meshes in order of 100 million cells and above like in my thesis back then.

So basically, is there a way to either allows BlueCFD to fully utilize all computing resources or allow export of the file to windows for use in a native ParaView version?

Cheers.


#15

Yes, once the .vtk files are in the postprocessing directory as mentioned. To use ParaView in another OS to view them, you would just have to access/transfer the case.foam directory and it sub-directories to where the other OS can use them.

I think the .gz files that writeMeshQuality creates in the 0 time directory could be accessed the same way…


#16

Hi Dale,

Awesome. Will attempt this sometime this week or next week.

Update you both on how it goes.

Cheers.


#17

How to run OpenFoam ‘checkmesh’ on a downloaded Hex parametric mesh (not from a full solution set download !!!):
.
.

Sorry for the continued posting here, but I am trying to pull a summary of all the things Ric and I discovered from a LONG, multi-day session (about 90 days ago) in our RocketChat environment.

We quickly discovered that we could run OpenFoam ‘checkmesh’ on a downloaded HEX parametric mesh (not from a full solution set). BUT, there was a trick to do this.

Here is Rics summary of that HEX parametric mesh trick:

  • Download a mesh, extract it to a folder. In this folder, you have to add a system folder containing fvSolution, fvSchemes and controlDict. Apart from this, open a notepad and save it as 0 byte case.foam (.foam extension).

.
Once you do that, the OpenFoam ‘checkmesh’ can be run in blueCFD from the directory of the case.foam file.

This was a great discovery as this will be an unheard of aid for us in order to make better meshes BEFORE we use them in a sim run.

I did not want to publish this until we had determined precisely where we could get an fvSolution, fvSchemes and controlDict file that would allow the trick to work.

Ric was persistent and was able to confirm that it seems we can get the system files from the directory structure of ANY downloaded full solution set. Ric even tried getting the system files from a TET mesh full solution set download :slight_smile:


#18

WOW, now that I have a little time on my hands, I watched a video that has been patiently waiting for me to view, in an open browser tab, for over a month now.

It is highly relevant here wrt ‘checkmesh’ and I just learned what the ‘-writeAllFields’ parameter of ‘checkmesh’ does.

If you use the ‘-writeAllFields’ parameter with ‘checkmesh’, all the quality fields and there values for each cell will become available to view and filter in ParaView.

PLEASE NOTE THAT THE CURRENT VERSION OF OpenFoam supplied with blueCFD DOES NOT HAVE THE ‘-writeAllFields’ PARAMETER :sob:

I will go back and update some of my posts wrt what ‘-writeAllFields’ does for us…

Here is the video:


#19

The method of Post 17, also works to allow you to open a downloaded HEX paramteric mesh and to view it in ParaView without even needing to run OpenFoam ‘checkmesh’ on it (but then of course you do not see the ‘checkmesh’ results in ParaView either.

This is a fairly quick way to view complex meshes before running a simulation on them using ParaViews more advanced mesh viewing features than the SimScale post processor has.


Porous Media Simulation Guide For FSAE Radiator
#20

Hi Dale,

Oh? Well that is unfortunate. Now that I think about it, its also probably why I didnt want to use BlueCFD and tried to get OpenFOAM installed natively on windows via the linux extension app. This way you will be able to run OpenFOAM and all its latest versions on windows without needing to switch OS.

However, directory organization again is a mess and I still have no idea how manage the files like keep Linux onto a different hardrive when running sims so it does not clog my main OS drive which has much much less space. Other than that, its a great way. Refer to this video.

Cheers.


#21

Well, I just watched our own @Retsam, aka ‘X masteretsam’ (palindrome intended :wink: and ‘X’ for OS’s ending in ‘x’ ), get MOAB running on Ubuntu 18.04 in Win10 as I tagged along in a RocketChat channel…

He did it :slight_smile: and with a little more work I am confident that I can create a description of all the processes he did in order to make that happen.

We are working on getting my install of MOAB on Unbuntu 18.04 in Win10 working, then I will make the procedure and post it here.

He was able to convert a download of a SimScale .h5m Standard TET mesh using ‘mbconvert’ into a .vtx file (and .stl file). :rainbow::fireworks::dart::beers:

There is hope that MOAB can be built on blueCFD, but more importantly, I think the ‘next step’ of getting an OpenFoam.com v1912, where ‘checkmesh -writeallfields’ can be used, built and running on Ubuntu 18.04 in Win10 will follow soon…

I am pretty sure that the ‘next step’ will be easier than what I saw X masteretsam do over the last couple days :slight_smile:

WE DID IT but I posted the answer to a new topic.

Lots of reasons for a new topic, the main one one being that we abandoned the ‘simpler to install’ OpenFOAM .org based blueCFD in favor of the OpenFOAM .com v1912 based WIN10 WSL install of Ubuntu 18.04 :wink:

BUT, this ‘leading up to the answer’ topic is a good background for the ‘answer topic’ and also has some valuable off-topic information which probably should be pulled out of here and put into some other new topic (that is WAY down my ToDo list)…