CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Starting OF C++

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 30, 2016, 08:44
Default Starting OF C++
  #1
Member
 
Sebastian Trunk
Join Date: Mar 2015
Location: Erlangen, Germany
Posts: 60
Rep Power: 11
sisetrun is on a distinguished road
Hello everybody,

I would like to learn more about OF programming. I have some basic skills in C++ and python. So, I know that the mission is not that easy but somehow I have to start...

I had a look at the application/test. And that is where my problems already start: "How can I execute such a test case?"

I compiled the case with wmake, changed the Make/file with _USER_ and so on... But I have no clue executing the compiled file.

I am very thankful for every answer!

Thanks a lot,

Best regards

PS: Any additional info for getting used to programming OF is highly appreciated
sisetrun is offline   Reply With Quote

Old   June 30, 2016, 14:36
Default
  #2
Senior Member
 
SinaJ
Join Date: Nov 2009
Posts: 136
Rep Power: 16
sina_mech is on a distinguished road
This should be helpful:

https://openfoamwiki.net/index.php/H...ure_to_icoFoam
sina_mech is offline   Reply With Quote

Old   July 5, 2016, 06:44
Default
  #3
Member
 
Ben Jankauskas
Join Date: Jun 2013
Location: Exeter
Posts: 34
Rep Power: 12
rhythm is on a distinguished road
Hi,

Compiling applications/solvers in OpenFOAM is not much different than in regular C++.

Compilation creates a binary file that can be run and in your Make/files you specify where that binary is going to be saved (in your case it's in $FOAM_USER_APPBIN which is a variable inside OpenFOAM environment). After compilation was successful, in your terminal you can type
Code:
ls $FOAM_USER_APPBIN
and you should see a new binary file for the application you've just compiled.

When apps/solvers are compiled into binaries with [i]wmake[/it] they are seen globally on your machine, so simply typing the name of the app/solver inside your terminal should work and it should be run.
Rarely, but sometimes right after compilation your terminal can be temperamental and doesn't see the application even though you can see it's binary file. So either open a new terminal window or type
Code:
rehash
and it should work.

As sina_mech has posted, openfoam wiki is a good starting place to become more familiar with how OpenFOAM framework works.

Hope this helps.
Ben
rhythm is offline   Reply With Quote

Old   July 5, 2016, 07:01
Default
  #4
Member
 
Sebastian Trunk
Join Date: Mar 2015
Location: Erlangen, Germany
Posts: 60
Rep Power: 11
sisetrun is on a distinguished road
Thanks Ben and sina_mech,

I already had a look at the wiki.
Until now, I did some C++ tutorials form youtube and read about C++ in books.
Do you know a tutorial/lecture where C++ is directly linked to OpenFoam examples?
I found some where solvers and applications are modified. But this seems quit complicated to start with.

Thanks so far,
best regards
sisetrun is offline   Reply With Quote

Old   July 7, 2016, 12:23
Default
  #5
Member
 
Ben Jankauskas
Join Date: Jun 2013
Location: Exeter
Posts: 34
Rep Power: 12
rhythm is on a distinguished road
Hi sisetrun,

Regarding books
You might want to check out 'OpenFOAM Primer' written by Jens Hopken and Tomislav Maric. They worked on it when they were learning to work with OF, so it was tailored for people trying to bridge the gap between CFD knowledge, C++ and how it is done in OF framework.

The link:
http://www.sourceflux.de/book/


Regarding CFD
You might like other CFD books, but you'd have to build that 'bridge' between maths and numerics to C++ and OF framework by yourself. There is an abundance of such books and imho they are all pretty much equivalent (some may be better than others, but in the end it will depend on personal preference). Quick google search will show you the options.


Regarding tutorials/lectures
- I liked the lecture notes from Chalmers University course on OpenFOAM and CFD. I can't remember if it is publicly available, but a quick email to the organisers will help you to find that out.
- At the moment I can't think of any other comprehensive course material publicly available. Having said that, from my experience the best thing is to have a specific question in mind and then see if there's an answer somewhere on the web, because most of the time someone either made a presentation/lecture/paper about it or discussed it here on the forum.

Another note, starting with OF can be a little bit daunting, due to the size of the code, but in my experience the best thing is to start reading the code and getting used to the structure and the way it's written. After some practice it becomes much more clearer as to how mathematics is put to code and then it really is as some people say 'Like playing lego with CFD building blocks'

Hope this helps.
Ben
rhythm is offline   Reply With Quote

Old   July 7, 2016, 14:50
Default
  #6
Member
 
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 12
Jerryfan is on a distinguished road
Hi Sisetrun,


I also just started the learning process of this amazing code. I feel like I am gradually into it, although the way ahead is still very long. My suggestion is to install a debug mode version and try to debug the code. Also try to understand the structure of the code, especially the class inheritance relationships. I don't think there is a shortcut.
Jerryfan is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
big difference between clockTime and executionTime LM4112 OpenFOAM Running, Solving & CFD 21 February 15, 2019 03:05
bscw cgns wing kocjH SU2 3 May 16, 2017 02:56
Error Message "Stopped in Routine SIG_HANDLER" appears starting CFX-Solver Leuchte CFX 6 July 20, 2016 03:35
[OpenFOAM] XYZ starting points of streamtraces in Paraview deniggo ParaView 3 May 22, 2013 03:02
FoamX not starting Javarelated error agrahn OpenFOAM Pre-Processing 5 October 20, 2007 05:33


All times are GMT -4. The time now is 10:31.