GSoC2020, FEM: extend examples

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
Sudhanshu
Posts: 357
Joined: Mon Oct 15, 2018 5:22 am

Re: GSoC2020, FEM: extend examples

Post by Sudhanshu »

HoWil wrote: Sat Aug 08, 2020 8:46 pm
Sudhanshu wrote: Sat Aug 08, 2020 8:29 pm
HoWil wrote: Fri Aug 07, 2020 8:33 pm Here the model for Tutorial1 for the body heat source
Is the geometry/model imported in this one?
Yes, its the step file pump_carter_sup.stp directly imported from "ElmerTutorialFilesGUI/TemperatureFieldOfSolidObject"
This example is done: https://github.com/Sudhanshu-Dubey14/Fr ... 79f332126a

My results are just a little off:
elmer_gui1_heat_results.png
elmer_gui1_heat_results.png (71.98 KiB) Viewed 2793 times
But that's mostly because of the coarse mesh that I have.
Should I go for a finer mesh? Though I don't want to make it too large.

Also, the stp file is currently in Mod/Fem/femexamples. Should I place it with the other resources?
User avatar
Sudhanshu
Posts: 357
Joined: Mon Oct 15, 2018 5:22 am

Re: GSoC2020, FEM: extend examples

Post by Sudhanshu »

HoWil wrote: Sun Aug 09, 2020 3:30 pm I cant say much regarding the mesh import.
Maybe bernd has some idea about it.

HoWil wrote: Sun Aug 09, 2020 3:30 pm Regarding the results.... This is mainly because we use a coarse mesh and because the boundary conditions are not exactly the same as in the tutorial where the inlet velocity is a function of the "edge-coordiante" tx:

Code: Select all

BoundaryConditionName = Inlet
Navier-Stokes
Velocity 1 = Variable Coordinate 2; Real MATC "6*(tx-1)*(2-tx)"
Velocity 2 = 0.0
This could be resolved with the freetextinputs from over here https://forum.freecadweb.org/viewtopic. ... 10#p420614 .
So we should wait till this is merged in master, right.

HoWil wrote: Sun Aug 09, 2020 3:30 pm BTW: with merging the freetextinputs also the "Elmer static currents" model can be used after defining the material as freetextinput: https://forum.freecadweb.org/viewtopic. ... 67#p418345

EDIT BTW2: the size of the model has to be checked again.....from the tutorial: "One special result of interest is the point, on the x-axis, at whichthe direction of the flow changes. In this case its position is about 5.0 m after the step."
In this regard, I think that red line in the pressure result is where the direction of flow changes cause it's almost 5m away from the step:
laminar_flow_pressure_tutorial.png
laminar_flow_pressure_tutorial.png (19.29 KiB) Viewed 2785 times
In our results we have something similar at 5m from step:
laminar_flow_pressure.png
laminar_flow_pressure.png (18.33 KiB) Viewed 2785 times

But it's not clearly visible because of the different colour scheme.
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: GSoC2020, FEM: extend examples

Post by HoWil »

Sudhanshu wrote: Tue Aug 11, 2020 7:40 am But that's mostly because of the coarse mesh that I have.
I am pretty sure this is the reason but simply try to decrease the mesh-element-size e.g. <10mm and you will hopefully see the same results as in the tutorial. That is the daily work of somebody who works with FEM ... finding the sweet spot between number of mesh-elements (and therefore ram/disk space) and spacial and time-domain resolution.
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: GSoC2020, FEM: extend examples

Post by HoWil »

Sudhanshu wrote: Tue Aug 11, 2020 8:55 am So we should wait till this is merged in master, right.
I hope I can show the results of this model done with the free-textinput- branch until sunday.

But you can try it yourself if you find the time to play with it!

Alternatively, you could edit the .sif file created by FC (with pressing 'write' in the 'Solver control' of Elmer) and replace the boundary section of the inlet with the expression given above. You can than run the simulation with/in FC (without over-writing the .sif and model again, simply run the simulation with 'Run').
After that you could run the original model given with the tutorial by executing the following commands after replacing the following line in the .sif file called 'compress_step.sif' given in the 'FlowStepCompressible'- tutorial-folder
' Post File = "compress_step.ep"'
to
' Post File = "compress_step.vtu"'
and run the simulation after creating the mesh with

Code: Select all

ElmerGrid 1 2 mesh.grd
ElmerSolver compress_step.sif
After that you will find several .vtu files in the 'mesh' subfolder which you can import as fem-result objects into FC and compare it with your modified model done in FC!
User avatar
Sudhanshu
Posts: 357
Joined: Mon Oct 15, 2018 5:22 am

Re: GSoC2020, FEM: extend examples

Post by Sudhanshu »

HoWil wrote: Wed Aug 12, 2020 11:42 am
Sudhanshu wrote: Tue Aug 11, 2020 7:40 am But that's mostly because of the coarse mesh that I have.
I am pretty sure this is the reason but simply try to decrease the mesh-element-size e.g. <10mm and you will hopefully see the same results as in the tutorial. That is the daily work of somebody who works with FEM ... finding the sweet spot between number of mesh-elements (and therefore ram/disk space) and spacial and time-domain resolution.
And sure enough, with 10mm mesh I am getting the max temp as 603 which is equal to what your example has:
elmer_heat_10mm.png
elmer_heat_10mm.png (75.71 KiB) Viewed 2697 times

But then, in the tutorial it is stated that:
The maximum temperature should be about 586.5 K
This is really close to the 586.15K that I got earlier with the coarse mesh! :!:
So I think we should accept this as the correct result.
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: GSoC2020, FEM: extend examples

Post by HoWil »

HoWil wrote: Wed Aug 12, 2020 12:02 pm Alternatively, you could edit the .sif file created by FC (with pressing 'write' in the 'Solver control' of Elmer) and replace the boundary section of the inlet with the expression given above. You can than run the simulation with/in FC (without over-writing the .sif and model again, simply run the simulation with 'Run').
After that you could run the original model given with the tutorial by executing the following commands after replacing the following line in the .sif file called 'compress_step.sif' given in the 'FlowStepCompressible'- tutorial-folder
' Post File = "compress_step.ep"'
to
' Post File = "compress_step.vtu"'
and run the simulation after creating the mesh with

Code: Select all

ElmerGrid 1 2 mesh.grd
ElmerSolver compress_step.sif
After that you will find several .vtu files in the 'mesh' subfolder which you can import as fem-result objects into FC and compare it with your modified model done in FC!
When running the simulation as described above and loading the results from the original Elmer-tutorial-model back into FC you get the following:
Flow profile from the original tutorial model imported via .vtu into FC. One can still see fragments originating from the quad-mesh.
Flow profile from the original tutorial model imported via .vtu into FC. One can still see fragments originating from the quad-mesh.
Screenshot from 2020-08-12 14-51-16.png (220.46 KiB) Viewed 2660 times
Flow profile from the model created within FC after adopting the .sif to have the same velocity-pofile at the inlet.
Flow profile from the model created within FC after adopting the .sif to have the same velocity-pofile at the inlet.
Screenshot from 2020-08-12 14-51-08.png (255.74 KiB) Viewed 2660 times
The pressure distribution for the FC-Model.
The pressure distribution for the FC-Model.
Screenshot from 2020-08-12 14-50-59.png (220.75 KiB) Viewed 2660 times
The pressure distribution from the original tutorial model imported into FC.
The pressure distribution from the original tutorial model imported into FC.
Screenshot from 2020-08-12 14-50-56.png (182.98 KiB) Viewed 2660 times
In my opinion, the small differences in the results are due to the differences in the mesh.
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: GSoC2020, FEM: extend examples

Post by HoWil »

And another shot now using the new freetextinput on the inlet boundary.... so no further modification is needed after exporting the .sif file :mrgreen:
Attachments
FlowStepCompressible3D_simplified_initial_flow_recreated_2D_with modified boundary condition on inlet_freetextinput.FCStd
For the early adopters.
(800.39 KiB) Downloaded 68 times
Screenshot from 2020-08-13 20-14-30.png
Screenshot from 2020-08-13 20-14-30.png (289.85 KiB) Viewed 2658 times
User avatar
Sudhanshu
Posts: 357
Joined: Mon Oct 15, 2018 5:22 am

Re: GSoC2020, FEM: extend examples

Post by Sudhanshu »

HoWil wrote: Thu Aug 13, 2020 6:17 pm And another shot now using the new freetextinput on the inlet boundary.... so no further modification is needed after exporting the .sif file :mrgreen:
I tried to adopt the freetextinput in the example: https://github.com/Sudhanshu-Dubey14/Fr ... 3a5ee457c2

The results with MKS units are close to results from your file:
laminar_flow_freetextinput_mks.png
laminar_flow_freetextinput_mks.png (18.96 KiB) Viewed 2600 times

But when I calculate them in standard units, the pressure results are all zero:
laminar_flow_freetextinput_mm.png
laminar_flow_freetextinput_mm.png (15.06 KiB) Viewed 2600 times

Have you tried using freetextinput in standard units?

Also, regarding the mesh import issues, the edges are still not there but it doesn't seem to effect result visualisation like last time.
User avatar
Sudhanshu
Posts: 357
Joined: Mon Oct 15, 2018 5:22 am

Re: GSoC2020, FEM: extend examples

Post by Sudhanshu »

A few suggestions for the freetextinput implementation:

I got this error when I tried to change the ElmerFreetextinput property:

Code: Select all

<class 'SyntaxError'>: ('EOL while scanning string literal', ('<string>', 1, 146, 'FreeCAD.getDocument(\'Unnamed\').getObject(\'ConstraintFaceElmerFreetextinput001\').ElmerFreetextinput = "  Normal-Tangential Velocity = Logical True\n'))
Stack Trace: 
I think it will be better to implement this property using triple quotes rather than a single quote. This will resolve this error.

Also after freshly compiling your branch I got:

Code: Select all

/run/media/sudhanshu/Thunder/Repos/FreeCAD_sd/build_howil/Mod/Fem/femsolver/elmer/sifio.py:340: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if key is not 'freetextinput':

is is for identity comparison and not string equality.
I can't find the documentation for it, but here is a SO question regarding this: https://stackoverflow.com/questions/298 ... -in-python

Code: Select all

/run/media/sudhanshu/Thunder/Repos/FreeCAD_sd/build_howil/Mod/Fem/femsolver/run.py:254: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if path is "":
Similarly for this error message which I also get on a fresh compile, I have changed it here: https://github.com/Sudhanshu-Dubey14/Fr ... f32c0f0856
User avatar
Sudhanshu
Posts: 357
Joined: Mon Oct 15, 2018 5:22 am

Re: GSoC2020, FEM: extend examples

Post by Sudhanshu »

Sudhanshu wrote: Tue Aug 04, 2020 7:50 pm
Sudhanshu wrote: Tue Aug 04, 2020 3:56 am
bernd wrote: Tue Jul 21, 2020 8:25 pm - this very simple example from HoWil for CalculiX and Elmer. the analytical calculation should be added at file top as a coment. https://forum.freecadweb.org/viewtopic. ... 20#p194595
Based on the description given in the post and simscala validation test, I created the following model but I am getting a vonmises stress of 35.6 MPa:
In the second attempt, I have changed the material property to match those given on the simscala site and made a finer mesh (with max element size 50mm).
This example is coded here: https://github.com/Sudhanshu-Dubey14/Fr ... 42abeda042
The results are not entirely correct.
Post Reply