|
[Sponsors] |
[Tutorials] OpenFOAM programming tutorials for beginners |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 4, 2017, 18:21 |
OpenFOAM programming tutorials for beginners
|
#1 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 |
Hi Foamers!
I wanted to share with you a couple of simple pieces of codes I wrote to demonstrate basic OpenFOAM functionality to beginner C++ programmers: https://github.com/UnnamedMoose/Basi...mmingTutorials The reason for the existence of these is that during my time at a University I've found that many students starting their research using OpenFOAM are required to develop code for it but have little to no prior knowledge of C++. This usually makes it very hard for them to jump from basic programming to the admittedly complex OpenFOAM framework, and also makes using many on-line materials quite challenging. The above tutorials hope to help with making this step. I've "tested" them on a few of my colleagues and collaborators and I hope they may help a wider audience in the future. Feedback always welcome! But please bear in mind I'm self-taught both in OpenFOAM and C++, so go easy on me Also, if you'd like to contribute a new tutorial or offer improvements to the ones already there, I'd highly welcome your input! Happy foaming, Artur |
|
July 11, 2017, 23:40 |
|
#2 |
Member
Vu
Join Date: Nov 2016
Posts: 42
Rep Power: 10 |
Thank you so much for your sharing.
Actually i am at the first steps of learning programming with openfoam and this would make my live much easier. |
|
July 18, 2017, 14:53 |
|
#3 |
Member
Vu
Join Date: Nov 2016
Posts: 42
Rep Power: 10 |
Hi Artur,
I've gone through the Tutorial number 2 and now I'm able to get access to some basic mesh informations. But I wonder is there any way to read information from a trisurface .stl mesh? For example read points and faces and put them into a list? |
|
July 18, 2017, 15:44 |
|
#4 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 |
Hi,
Glad to see more people using the materials. I've never worked with stl's in OpenFOAM so can't give precise advice, but a quick look under the hood suggests starting off with the triSurface object, defined in Code:
$FOAM_SRC/triSurface/triSurface/triSurface.H Code:
$FOAM_APP/utilities/surface/surfaceClean If you figure out a minimum working example showing how to load a specific surface, access its elements etc. I encourage putting it on GitHub and creating a pull request into the tutorials to share your experience with the others Also, it's great to hear from other people in this thread, but if you have any more specific questions about the stl stuff I suggest opening a new thread for it to make the forum more readable. All the best Artur Last edited by Artur; July 18, 2017 at 17:41. |
|
July 18, 2017, 17:40 |
|
#5 |
Member
Vu
Join Date: Nov 2016
Posts: 42
Rep Power: 10 |
Thanks for your suggestion, triSurface object seems to be a great starting point. I'll spent time to play around with it. And I would love to contribute too
|
|
July 25, 2017, 20:25 |
|
#6 |
Senior Member
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 16 |
Dear Artur
Many thanks for your tutorials. As a member of OpenFoam community, I wanted to express my gratitude for sharing these tutorials with others. For curiosity, I went through almost all of them. Your comments were nice and helpful. Sometimes, the level of C++ was higher than my standards. Regards |
|
August 6, 2017, 04:43 |
|
#7 |
New Member
Join Date: Jun 2016
Posts: 6
Rep Power: 10 |
Dear Artut,
Thank you for taking the effort in writing these materials. I'm so excited that I found them. Currently I'm trying to teach my self the basics of C++ in parallel with learning programming with OpenFOAM and every day I can see that learning C++ is a must if you are planning to do some serious work with OF. Again, thank you and I will definitely gonna give feedback on the materials once I'm done with them. Ahmed |
|
August 7, 2017, 16:36 |
|
#8 |
Member
Join Date: Sep 2016
Posts: 63
Rep Power: 10 |
Hello Artur,
Thank you very much for your tutorial, I learned a lot from them, especially about the mesh, volScalarField, volVectorField. I could manage some simple postProcess utilities after running your tutorials. I have one question about the last tutorial, is the 0/beta missing? I didn't figure it out how to create one. Thank you very much in advance! I have difficulties understanding the OFtutorial8, since there are so many include files/classes/templates which are not familiar to me. I wonder whether you have suggestions about understanding the C++ source guide of OpenFOAM? I would appreciate greatly! Best regards, sitajeje |
|
August 9, 2017, 13:39 |
|
#9 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 |
Hi Sitajeje,
Thank you for pointing out the missing file in 0/ in tutorial 9, I added it to the github repo now. My bad. As for your question, you can try: 1. Doxygen on line (my goodness, just realised they released OF 5 and I'm still using 3.0.1!): https://cpp.openfoam.org/v4/files.html 2. you can compile doxygen yourself although I've never done it, maybe this will work: how to use Doxygen to generate a PDF with OpenFOAM's source code documentation? 3. Personally, I just tend to look up the header files and arrange them in my editor in order from the most basic to most "derived" class In general, I don't think there are many shortcuts you can take on this one If you figure out some useful comments that would make the tutorial easier to understand I'd very much welcome your contribution! All the best, Artur |
|
August 9, 2017, 15:26 |
|
#10 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi Arthur,
very well done. Nice stuff. I love it. Especially the parallel stuff - never went into that and it is a very good start I like seeing people all over the world contributing to the community. One thing I want to mention. It would be great if you add a page to the openfoamwiki page. Otherwise it might happen that this thread and all your great work get lost during time. Keep going doing that nice things Cheers,
__________________
Keep foaming, Tobias Holzmann |
|
August 9, 2017, 15:46 |
|
#11 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 |
Hi Tobias,
Many thanks, glad you found it useful. Very good idea with the wiki page, I'll definitely do that. I think first I need to upgrade the code to work with the new version since being two major releases behind is a bit much! All the best, A |
|
August 22, 2017, 05:24 |
|
#12 |
New Member
Tom Dylan
Join Date: May 2015
Posts: 20
Rep Power: 11 |
Hi Artur,
the understandingTheMesh-tutorial yielded more insight than the tens of solvers I have been trying to understand. Thank you for the efforts! Tom |
|
August 22, 2017, 17:41 |
chemFoam
|
#13 |
New Member
Golden
Join Date: Jun 2017
Posts: 4
Rep Power: 9 |
Hello,
I am new to openfoam and find it to be a useful program. I have a question. I am learning how to use chemFoam. How does one write extra variables to a file. The file is chemFoam.out. The file currently writes time, temperature and pressure. I want to write out all of the species variables (CH4, O2, N2, CO2, CO, ….) too. How does one do this? |
|
August 23, 2017, 11:30 |
|
#14 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 |
Hi,
Have a look at tutorial 3 which covers field operations, such as creating new fields and writing them. Specie concentrations are simply scalar fields you should be able to access without too much trouble through the multi-specie mixture interface created in createFields.H: Code:
basicMultiComponentMixture& composition = thermo.composition(); PtrList<volScalarField>& Y = composition.Y(); All the best, A |
|
November 7, 2017, 08:07 |
|
#16 |
New Member
Germilly Barreto
Join Date: Jul 2016
Location: Portugal
Posts: 25
Rep Power: 10 |
Artur,
Thank you for your sharing. This solved my problems. Regards |
|
November 15, 2017, 05:20 |
General description of the OpenFOAM suite
|
#17 |
Member
Amod Kumar
Join Date: Jan 2010
Location: Delhi, India
Posts: 39
Rep Power: 16 |
Hello OF Users,
Just to add, I found this PDF file which explains each line of code (being PDF, it looks like a book). Hope this will add to the nice information already put in here. I cannot upload this file due to size restrictions and put a link to http://cfdyna.com/Home/OpenFOAM/of_T...escription.pdf Regards, |
|
November 15, 2017, 05:53 |
|
#18 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 |
Thanks for sharing, indeed quite a useful resource!
|
|
November 21, 2017, 14:16 |
|
#19 |
New Member
alix cattermole
Join Date: Nov 2017
Posts: 14
Rep Power: 9 |
hello i am an absolute beginner and would like to go through these tutorials as i need to learn openfoam for my university project but i cannot figure out how to get started. Please can you help me and tell me where and how to start?
|
|
November 22, 2017, 05:06 |
|
#20 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 |
Hi,
It's not very clear what you're asking - learning OF as in doing CFD or programming and development? If the latter, I suggest just follow the Requirements part of the README on the GitHub page, there's not much more I could say than what is already there. If you mean running CFD with OF in general, the official tutorials are always a good start, then there are some excellent pages you could find by just typing "getting started with OpenFOAM" into Google, which have all the info you might need to kick off: Getting Started with OpenFOAM Also look into course materials here: http://www.tfd.chalmers.se/~hani/kurser/OS_CFD/ If you're struggling with something specific, I suggest you start a new thread under "Running, solving and CFD" to keep things organised and increase your chances of actually getting some help. |
|
Tags |
turorial files, tutorial |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Map of the OpenFOAM Forum - Understanding where to post your questions! | wyldckat | OpenFOAM | 10 | September 2, 2021 06:29 |
OpenFOAM 4.0 Released | CFDFoundation | OpenFOAM Announcements from OpenFOAM Foundation | 2 | October 6, 2017 06:40 |
OpenFOAM Training: Programming CFD Course 12-13 and 19-20 April 2016 | cfd.direct | OpenFOAM Announcements from Other Sources | 0 | January 14, 2016 11:19 |
OpenFOAM v3.0.1 Training, London, Houston, Berlin, Jan-Mar 2016 | cfd.direct | OpenFOAM Announcements from Other Sources | 0 | January 5, 2016 04:18 |
Openfoam Programming from scratch | shovan | OpenFOAM Programming & Development | 1 | July 9, 2015 13:38 |