PR 7100: FEM WB Elmer viscosity bug fix

About the development of the FEM module/workbench.

Moderator: bernd

mst31
Posts: 14
Joined: Sun Apr 03, 2022 10:43 pm

PR 7100: FEM WB Elmer viscosity bug fix

Post by mst31 »

When a project uses thermal-flow simulation for solid and fluid together then Navier-Stokes equation is applied both for solid and fluid. But solid has not "Viscosity" property so Elmer prints warnings "Requested property: [Viscosity], not found" and calculation has very long time or may not be converged.
This fix disables Stokes-Navier equation for Solid objects.

Example that demonstrated the problem is here:
https://forum.freecadweb.org/viewtopic.php?t=68764

Link to the PR:
https://github.com/FreeCAD/FreeCAD/pull/7100
User avatar
uwestoehr
Veteran
Posts: 4316
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany

Re: PR 7100: FEM WB Elmer viscosity bug fix

Post by uwestoehr »

Many thanks for the fix and also for the example file.

I merged your PR now.

For a while I was looking for a proper fluid example file. With this I see that the resulting pressure is wrong. To me it seems that FreeCAD misses in general a constraint to set the initial pressure. What do you think?

Looking at the .sif file written by FreeCAD, I don't see anything regarding pressure. Since you have some experience, what must be written into the .sif file?
mst31
Posts: 14
Joined: Sun Apr 03, 2022 10:43 pm

Re: PR 7100: FEM WB Elmer viscosity bug fix

Post by mst31 »

Thanks!
I updated the example in PR message:
https://github.com/FreeCAD/FreeCAD/file ... .FCStd.zip
It was velocity 0.1 mm/s but should be 0.1 m/s (I use this value for simple approximation of natural convection) - this is my fault. Now it is seen convective flow temperature.
As for pressure - it may be not used for heat-sink thermal modeling (e.g. in the heat sink example in Comsol Multyphisics). I think this is because calculation of temperature field requires only velocity field without pressure in some simple models.
Also I added Pressure Boundary Condition but now FreeCAD doesn't use it. If manually to add pressure condition on outlet surface then pressure is set throughout the air (it is seen in the paraview, but somehow pressure has negative sign). I think difference between inlet and outlet is not seen because flow has low velocity. sif-file attached.
Also the example needs radiation boundary condition to be more accurate: I check this in other model in Comsol and verified with experimental data. I think it also may be added in FreeCAD (Elmer has this feature in heat transfer model). What do you think?
Attachments
case.zip
(1.17 KiB) Downloaded 5 times
User avatar
uwestoehr
Veteran
Posts: 4316
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany

Re: PR 7100: FEM WB Elmer viscosity bug fix

Post by uwestoehr »

Do you allow me to use this file as example directly for FreeCAD?
mst31 wrote: Sun Jul 03, 2022 4:44 pm Also I added Pressure Boundary Condition but now FreeCAD doesn't use it.
That was my point. FreeCAD misses this. So when I find time, I will add this.

Many thanks for your .sif file!

-------

You example file shows that Elmer is not using all CPU cores. I will have a look at this as well.
However, I cannot predict when I will have time for this.
User avatar
uwestoehr
Veteran
Posts: 4316
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany

Re: PR 7100: FEM WB Elmer viscosity bug fix

Post by uwestoehr »

uwestoehr wrote: Sat Jul 09, 2022 11:07 pm You example file shows that Elmer is not using all CPU cores. I will have a look at this as well.
I did and it was much more work than expected. Here is a PR that adds multi-thread support for Elmer:
https://github.com/FreeCAD/FreeCAD/pull/7159
mst31
Posts: 14
Joined: Sun Apr 03, 2022 10:43 pm

Re: PR 7100: FEM WB Elmer viscosity bug fix

Post by mst31 »

uwestoehr wrote: Sat Jul 09, 2022 11:07 pm
Do you allow me to use this file as example directly for FreeCAD?
Yes of course
mst31
Posts: 14
Joined: Sun Apr 03, 2022 10:43 pm

Re: PR 7100: FEM WB Elmer viscosity bug fix

Post by mst31 »

uwestoehr wrote: Mon Jul 11, 2022 2:18 am
uwestoehr wrote: Sat Jul 09, 2022 11:07 pm You example file shows that Elmer is not using all CPU cores. I will have a look at this as well.
I did and it was much more work than expected. Here is a PR that adds multi-thread support for Elmer:
https://github.com/FreeCAD/FreeCAD/pull/7159
Thank you!
I can also try to add Pressure Boundary Condition. But I'm new to FreeCAD code.
User avatar
uwestoehr
Veteran
Posts: 4316
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany

Re: PR 7100: FEM WB Elmer viscosity bug fix

Post by uwestoehr »

Many thanks that we can use your example.
mst31 wrote: Tue Jul 12, 2022 6:05 pm Thank you!
I can also try to add Pressure Boundary Condition. But I'm new to FreeCAD code.
Can you compile FreeCAD, if yo it would help me if you could test my pull request that adds multithreading of Elmer, especially when you are on Linux or Mac.
If you are on Windows and can't compile, I can also prepare a Windows build for you.

Concerning the pressure, I meant a condition for the bulk pressure. I think one need to specify that the initial pressure of the water is in your example
1.0 bar and due to the heat it will be locally maybe 1.1 bar. However, I haven't had time yet to investigate how this is done that Elmer uses this info.
User avatar
uwestoehr
Veteran
Posts: 4316
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany

Re: PR 7100: FEM WB Elmer viscosity bug fix

Post by uwestoehr »

I merged the support for multi-threading of Elmer now. Please give it a try:
https://forum.freecadweb.org/viewtopic.php?f=18&t=70307
mst31
Posts: 14
Joined: Sun Apr 03, 2022 10:43 pm

Re: PR 7100: FEM WB Elmer viscosity bug fix

Post by mst31 »

uwestoehr wrote: Wed Jul 13, 2022 2:16 am Concerning the pressure, I meant a condition for the bulk pressure. I think one need to specify that the initial pressure of the water is in your example
1.0 bar and due to the heat it will be locally maybe 1.1 bar. However, I haven't had time yet to investigate how this is done that Elmer uses this info.
I made some investigation of this problem. I created more difficult model: taper tube with water, inside placed heat sink:
tube.png
tube.png (52.56 KiB) Viewed 397 times
In FC with Elmer I got pressure:
result.png
result.png (108.11 KiB) Viewed 397 times
It turns out that Elmer set ~0 Pa in open side of tube.
Next I corrected sif-file:
- Set pressure in open side of tube (sign "-" - because Elmer supposes that pressure is directed outside of body):

Code: Select all

Boundary Condition 25
  Name = String "Face28"
  Velocity 2 = Real 0.0
  Velocity 3 = Real 0.0
  External Pressure = Real -101000.0
End
- Set initial condition:

Code: Select all

Initial Condition 2
  Temperature = Real 300.0
  Velocity 1 = Real 0.01
  Velocity 2 = Real 0.0
  Velocity 3 = Real 0.0
  Pressure = Real 101000.0
End
Result of this modifications in paraview:
result_paraview.png
result_paraview.png (82.55 KiB) Viewed 397 times
Concerning locally changing of pressure because of changing temperature. I read ElmerModelsManual - in Sokes-Navier equations there is not temperature explicitly. Instead it needs to use either IdealGas compressibility model either incompressible flow with Boussinesq approximation. In any case Elmer will bind pressure and density with temperature. I want to create such example (e.g. natural convection in volume)...
Attachments
case.sif.zip
(1.26 KiB) Downloaded 7 times
fem-elmer-tube.FCStd.zip
(51.52 KiB) Downloaded 3 times
Post Reply