Glutton for punishment, trying to install an operational CfdOF workbench for FreeCAD on MacOS

WobblyHand

H-M Supporter - Diamond Member
H-M Lifetime Diamond Member
Joined
Dec 18, 2019
Messages
7,292
A while back, while I still had my Linux laptop as my main machine, I had tried to do some simulations using air as a fluid. This lead to me learning a little about CFD. https://en.wikipedia.org/wiki/Computational_fluid_dynamics
Mind you, I know practically nothing about it, but I was previously able to do FEA on FreeCAD, so I thought I could do CFD. I tried to get it installed on my linux laptop but got nowhere pretty quickly. My linux laptop sort of crapped out on me and I didn't want to deal with hardware that seemed to die well before it's time.

So, I don't know what possessed me, but I ended up getting an M3 MacBook Pro last year on Black Friday. Slowly got stuff running again, including FreeCAD and FEA, which was nice. But I still wanted to get CFD running. Being tenacious, I asked a bunch of dumb questions and got some answers, and a few clues, but basically have been informed this isn't so easy, especially on a Mac. A lot of the software was developed on Linux, and then ported to Windows, but the Mac really was an ugly step child (at least to the developers).

Sort of have things installed, but things aren't quite fully working just yet. I did install the meshing tools, and the main solver OpenFOAM. After a struggle I got the program HiSA installed, which can be used for high speed and turbulent flow. Even figured out how to get a required customized meshing tool to install cfmesh-cdof after finding an obscure reference that stated openmp could only be compiled on Apple Silicon by prepending the command -Xclang before -fopenmp. Openmp is a specialized add on to C that allows parallel processing. With complicated structures one tends to get a lot of cells, and that can really slow down solving, hence the need for parallel processing.

It would seem the version of Paraview (a visualization tool) that I have for the Mac, isn't quite the same as the one for Linux. There are some subtleties. They are sufficient to break things. :(
Currently, the program is expecting to have the script pvScript.py to be called, but there's no such file on my Mac. Oops! That will be tomorrow's journey I guess.

This is the demo model that is being simulated. The blue is the intake, the red the exhaust. The purple region is porous. You can also see a baffle of sorts in the horizontal tube.
Screenshot 2024-03-31 at 9.33.03 PM.png
So I get this simulation residual errors - which tell me that it's trying to work.
Screenshot 2024-03-31 at 9.36.43 PM.png
But I can't view the results! Almost there, but not quite...
 
You are doing well. The most I use the FreeCAD FEA tool for (so far)is to discover the weak and bendy places on on the bench stuff I am kinocking together. CFD is a whole other game.

I use Linux pretty much always, mine being LinuxMint, "Mate" desktop. My FreeCAD is 0.22 freecad-weekly, which I manage by using the Appimage pack. I keep two versions lurking in my Applications folder. One is the latest, and the other is the one previous (just in case). I use AppimageUpd to set up when I put a newer FreeCAD there, and to delete reference to the oldest one, which I then dump.
I am not sure I would get on well with FreeCAD on a laptop :)

The most recent Appimage I got was
FreeCAD_weekly-builds-36526-2024-03-22-conda-Linux-x86_64-py311

From --> HERE --> https://github.com/FreeCAD/FreeCAD-Bundle/releases/tag/weekly-builds
 
You are doing well. The most I use the FreeCAD FEA tool for (so far)is to discover the weak and bendy places on on the bench stuff I am kinocking together. CFD is a whole other game.

I use Linux pretty much always, mine being LinuxMint, "Mate" desktop. My FreeCAD is 0.22 freecad-weekly, which I manage by using the Appimage pack. I keep two versions lurking in my Applications folder. One is the latest, and the other is the one previous (just in case). I use AppimageUpd to set up when I put a newer FreeCAD there, and to delete reference to the oldest one, which I then dump.
I am not sure I would get on well with FreeCAD on a laptop :)

The most recent Appimage I got was
FreeCAD_weekly-builds-36526-2024-03-22-conda-Linux-x86_64-py311

From --> HERE --> https://github.com/FreeCAD/FreeCAD-Bundle/releases/tag/weekly-builds
I think I was at my high point there :)

Did some FEA analysis of a high pressure cylinder - not that I actually trusted it for that, but more to see what the effects of various features did for stresses. Was quite interesting. Even managed to put in non-linear plastic deformation. This was while my Linux laptop was alive. When I jumped to a Mac, I ran the sim again, just to see that it work, and it did. That's quite a testament to multi-platform development.

Been working through the CFDOF issues with the main developer - who doesn't have a Mac, so can't test his fixes in his home country. So I'm doing the testing and obviously the cycle time is longer, especially since he lives on the other side of the globe from me.

Finally, got the dependency checker to be satisfied, and got a bit ahead of myself... And was rewarded with an application crash and an auto-generated crash report sent to Apple and FreeCAD. And of course, it left no breadcrumbs behind (that I know of).

Crash (this time) was:
Code:
Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000122
Exception Codes:       0x0000000000000001, 0x0000000000000122

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [40735]
So there's some kind of bug. Shouldn't be running off to invalid addresses...
 
Been working with the developer, kind of a slow slog, both with the time zone differences, the complexity of the issues, and the fact that the dev doesn't have the platform to test on.

Updated my mesher and HiSA, a coupled, density-based compressible CFD solver for high-speed aerodynamic flows based on the OpenFOAM toolkit. Some of the CfdOF demos complete in the automated test suite, but some others fail. I'm hoping to get them all to work, simply because they should be the building blocks to learn from. I don't mind individual tests failing, but it's pretty painful when the whole application crashes and I don't know where to find the log files, if they exist. So I'm just plodding along testing out suggestions. Some of the suggestions were one's I found out and supplied to the developer, others he provided. So there's been some give and take to help make this powerful application available to Apple users. I'll be pretty happy if we can get this to work on a Mac, and even happier if I can use it to evaluate an idea I have.
 
Managed to get an install that runs 6 out of 8 test cases, which is good. The developer said that he expected two to fail, since he hadn't updated those two cases. If I run the test bench from FreeCAD, it works, but not if initiated from the console in the openFOAM environment. Don't know if all is well, but at least my install passes the basic stuff. Well, that was the easy stuff - now I need to learn CFD. I realize I'll never be an expert at it, but I hope I can pick up enough to dabble a bit and learn something. Think this will keep me off the streets for a while.
 
Slow going. Got the supplied macros to initialize the geometry and mesh to simulate a supersonic rocket like thing. But the called for mesh refinement seems to fail, with some cryptic error. (Cryptic to me anyways.) May still be some improperly installed program on my Mac or some error on my part. Good thing I'm not in a hurry.
 
You are ambitious. Trying to debug a huge application on a machine it's not native to can be challenging. If you don't have one already, a good debugger would be helpful. I'm probably preaching to the choir though :).

I have simFlow installed on my linux machine but haven't done much with it yet. Definitely a step beyond mechanical/electromag FEA. I downloaded it to try to model a DIY diffusion pump (for high vacuum experiments) but found that used ones for good prices occasionally show up on ebay.
 
You are ambitious. Trying to debug a huge application on a machine it's not native to can be challenging. If you don't have one already, a good debugger would be helpful. I'm probably preaching to the choir though :).

I have simFlow installed on my linux machine but haven't done much with it yet. Definitely a step beyond mechanical/electromag FEA. I downloaded it to try to model a DIY diffusion pump (for high vacuum experiments) but found that used ones for good prices occasionally show up on ebay.
I'd say I was overambitious. This has been a bugger to get going. On the good side, I have gotten some sims to work. But the examples I want to examine, as mentioned above, well, can't get them to work yet. I need to see if the meshing programs are installed and confirmed configured correctly, as I am getting SIGSEGV's (segmentation faults) when deployed by FreeCAD. So I need to do the cfmesh without FreeCAD, just to determine where the heck the issue is. A SIGSEGV autogenerates a trouble report to Apple and FreeCAD. Unfortunately, I have yet to uncover enough of a log to give me any clues. The SIGSEGV blows away (to my knowledge) the log file - or I can't find it. It also terminates FreeCAD, so I can't even get a screenshot of the output. Hmm, maybe I can launch FreeCAD from a shell and the shell might survive the SIGSEGV/GPF event. So there might be some text in that console...

What makes this tough is MacOS has many Linux like underpinnings, but it's different enough, so that I can sort of, but not quite, apply my meager Linux skills. (25 years of 'inexperience'.) Where stuff gets located in Mac is "non-standard" relative to Linux. Homebrew is somewhat unconventional too. It's not quite a package manager, and it's hard to revert a package. All in all, things are tough to sort out. If I could get Linux to be fully functional on my M3, I'd try it. From what I have read so far, it's almost there for M1's & M2's, but not the M3. Not good enough of a hacker to brave taking the leap. CFD is more than hard enough for me to grasp!

I have been able to build FreeCAD from source on the Mac, so conceivably I could create a debug version. Maybe I could put in some traps/asserts/whatevers to log things. I haven't used this version much, since it is a dev version and isn't as stable as the release version. For the most part I use 0.21.1. Dev version is at 0.22.dev and depending on when you build it, it can be quirky. But if you wait a day and build it, usually it's fine. But this introduces yet another variable, so I won't try this unless the CfdOF author recommends it. I build the code using Visual Studio and conda. That was quite an adventure on a Mac, but it worked.
 
IIRC Visual Studio has pretty decent debugging features. But, still, big applications can be challenging. When I was still working I used an open-source program called "Electric" to view IC layouts, but it had a problem with certain IC designs. It didn't render them correctly, something to do with how it handled the design hierarchy. I worked on it for months (it seemed) and never did figure out what was going on.
 
IIRC Visual Studio has pretty decent debugging features. But, still, big applications can be challenging. When I was still working I used an open-source program called "Electric" to view IC layouts, but it had a problem with certain IC designs. It didn't render them correctly, something to do with how it handled the design hierarchy. I worked on it for months (it seemed) and never did figure out what was going on.
This is the downside of open source. Sometimes there's bugs. Worse, sometimes you can't fix it, or get someone to help you. Especially if the problem is only manifested by one person (you). So the developer isn't motivated. Or they are just plain busy with their own lives. On the other hand, been burned with commercial software too, and sometimes they just can't be bothered, because they already have your money.

CfdOF (computational fluid dynamics using open foam) is big enough, but it's layered with FreeCAD. It's really more than a bit over my head. At the moment, I have no idea how to debug this, as I don't know enough about the program architecture and flow. But, I think I can execute from the console, and maybe it will preserve some more information, should it segfault again.

Been away for nearly a couple of weeks, and it's hard to get my head around this. I'll try some more things. Being tenacious has some merit, but knowing when to stop is also good. Have several dozen projects in the queue, so if I don't get some tangible movement on this, I'll have to give it a rest for a while.

My only clue to date is the meshing is failing. The mesher program cfmesh uses parallel processing using OpenMP. Something happens during or just after that process and segfaults.

What is odd is that if I run the CfdOF WorkBench self test, this particular example file passes the test. (6 out of 8 tests pass, which I have been told is correct. The test file I am using is one of the passing tests. So either the self test is falsely passing, or I have (probably) messed something up in the configuration. Something in the two scripts must be different...
 
Back
Top