|
[Sponsors] |
[Tutorials] OpenFOAM programming tutorials for beginners |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#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 |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Member
Vu
Join Date: Nov 2016
Posts: 42
Rep Power: 9 ![]() |
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. |
|
![]() |
![]() |
![]() |
![]() |
#3 |
Member
Vu
Join Date: Nov 2016
Posts: 42
Rep Power: 9 ![]() |
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? |
|
![]() |
![]() |
![]() |
![]() |
#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 16:41. |
|
![]() |
![]() |
![]() |
![]() |
#5 |
Member
Vu
Join Date: Nov 2016
Posts: 42
Rep Power: 9 ![]() |
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
![]() |
|
![]() |
![]() |
![]() |
![]() |
#6 |
Senior Member
Bobby
Join Date: Oct 2012
Location: Michigan
Posts: 454
Rep Power: 15 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#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 ![]() |
|
![]() |
![]() |
![]() |
![]() |
#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 |
|
![]() |
![]() |
![]() |
![]() |
#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 ![]() All the best, Artur |
|
![]() |
![]() |
![]() |
![]() |
#10 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 51 ![]() ![]() ![]() |
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 ![]() Keep going doing that nice things ![]() Cheers,
__________________
Keep foaming, Tobias Holzmann |
|
![]() |
![]() |
![]() |
![]() |
#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 |
|
![]() |
![]() |
![]() |
![]() |
#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 |
|
![]() |
![]() |
![]() |
![]() |
#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? |
|
![]() |
![]() |
![]() |
![]() |
#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 |
|
![]() |
![]() |
![]() |
![]() |
#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 |
|
![]() |
![]() |
![]() |
![]() |
#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, |
|
![]() |
![]() |
![]() |
![]() |
#18 |
Senior Member
Artur
Join Date: May 2013
Location: Southampton, UK
Posts: 372
Rep Power: 20 ![]() |
Thanks for sharing, indeed quite a useful resource!
|
|
![]() |
![]() |
![]() |
![]() |
#19 |
New Member
alix cattermole
Join Date: Nov 2017
Posts: 14
Rep Power: 8 ![]() |
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?
|
|
![]() |
![]() |
![]() |
![]() |
#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 |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Map of the OpenFOAM Forum - Understanding where to post your questions! | wyldckat | OpenFOAM | 10 | September 2, 2021 05:29 |
OpenFOAM 4.0 Released | CFDFoundation | OpenFOAM Announcements from OpenFOAM Foundation | 2 | October 6, 2017 05:40 |
OpenFOAM Training: Programming CFD Course 12-13 and 19-20 April 2016 | cfd.direct | OpenFOAM Announcements from Other Sources | 0 | January 14, 2016 10:19 |
OpenFOAM v3.0.1 Training, London, Houston, Berlin, Jan-Mar 2016 | cfd.direct | OpenFOAM Announcements from Other Sources | 0 | January 5, 2016 03:18 |
Openfoam Programming from scratch | shovan | OpenFOAM Programming & Development | 1 | July 9, 2015 12:38 |