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

Beginner: How to bridge the gap between basic C++ knowledge to openFOAM programming

Register Blogs Community New Posts Updated Threads Search

Like Tree46Likes
  • 8 Post By bigbang
  • 14 Post By vatavuk
  • 8 Post By elvis
  • 2 Post By vatavuk
  • 12 Post By vatavuk
  • 2 Post By decah

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 9, 2011, 14:32
Default Beginner: How to bridge the gap between basic C++ knowledge to openFOAM programming
  #1
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 15
bigbang is on a distinguished road
I have a mechanical engineering background with only undergraduate classes in various programming (C++, lingo, VB, html). My goal is to become free to use openFOAM as I please.

I did all the tutorials on http://www.cplusplus.com/doc/tutorial/ to refresh my knowledge and I am still very confused when I'm trying to understand the source code in openFOAM. I get lost trying to get to the source of several layers of classes of code for simple features. What can I do to bridge this gap.

Thanks
y_jiang, tariq, amolrajan and 5 others like this.
bigbang is offline   Reply With Quote

Old   August 10, 2011, 10:03
Default
  #2
Senior Member
 
Paulo Vatavuk
Join Date: Mar 2009
Location: Campinas, Brasil
Posts: 196
Rep Power: 17
vatavuk is on a distinguished road
Hi Alex,
I'm also trying to understand some details of the source code and I'm also finding it difficult. There is no detailed manual of the code implementation but you can obtain information distributed in a lot of sources. Here is a list of links that I found useful for understanding the code:

1)Dr. Hvoje Jasak presentation at the 6th OpenFOAM workshop http://www.openfoamworkshop.org/6th_...ak2_slides.pdf

2)Dr. Tommaso Lucchini programming tutorial http://cfd.iut.ac.ir/files/Tutorial,...20Diego%20.pdf

3) The Programmer Guide Addendum that appears in the OpenFOAM wiki has many interesting topics written by different authors: http://openfoamwiki.net/index.php/Ma...rGuideAddendum

This list is small but other people may help adding their preferred links.
Paulo
vatavuk is offline   Reply With Quote

Old   August 10, 2011, 13:07
Default
  #3
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 15
bigbang is on a distinguished road
Thanks for this reply. Very helpful.
bigbang is offline   Reply With Quote

Old   August 11, 2011, 07:45
Default
  #4
Senior Member
 
Elvis
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 620
Blog Entries: 6
Rep Power: 24
elvis will become famous soon enough
Hello,

have you read http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2010/ and the years before?
happydogy, qylin, meshman and 5 others like this.
elvis is offline   Reply With Quote

Old   August 11, 2011, 08:31
Default
  #5
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 15
bigbang is on a distinguished road
Quote:
Originally Posted by elvis View Post
Hello,

have you read http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2010/ and the years before?
Great academic reference. Thank you.
bigbang is offline   Reply With Quote

Old   August 11, 2011, 09:50
Default
  #6
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
The programmer's guide addendum has been expanded to the "OpenFOAM guide", a subsection of the wiki:

http://openfoamwiki.net/index.php/Ca...OpenFOAM_guide

I'm also planning to formalizing this into a pdf-ish programmer's guide for all OpenFOAM users.
marupio is offline   Reply With Quote

Old   August 11, 2011, 09:51
Default
  #7
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 15
bigbang is on a distinguished road
Quote:
Originally Posted by vatavuk View Post
2)Dr. Tommaso Lucchini programming tutorial http://cfd.iut.ac.ir/files/Tutorial,...20Diego%20.pdf
Hi vatavuk. Have you successfully completed the ramped boundary condition in Dr. Tommaso's programming tutorial?

I have had many debugging errors along the way just to get the compiler to work. Two corrections I made to the rampedFixedValueFvPatchField.C file were:

Change #1:
Code:
template<class Type>
rampedFixedValueFvPatchField<Type>::rampedFixedValueFvPatchField
(
const fvPatch& p,
//const Field<Type>& iF,
const DimensionedField<Type, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchField<Type>(p, iF),
refValueLow_("refValueLow", dict, p.size()),
refValueHigh_("refValueHigh", dict, p.size()),
startRamp_(readScalar(dict.lookup("startRamp"))),
endRamp_(readScalar(dict.lookup("endRamp"))),
curTimeIndex_(-1)
{
Info << "Hello from ramp! startRamp: " << startRamp_
<< " endRamp: " << endRamp_ << endl;
if (dict.found("value"))
{
fixedValueFvPatchField<Type>::operator==
(
Field<Type>("value", dict, p.size())
);
}
else
{
fixedValueFvPatchField<Type>::operator==
(
refValueLow_ + (refValueHigh_ - refValueLow_)*currentScale()
);
}
Change #2: I removed the preprocessor directive at the end of ...Field.H because I was getting "previously declared" compiling errors on all the classes declared in ...Field.C
Code:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

//#ifdef NoRepository
//#   include "rampedFixedValueFvPatchField.C"
//#endif

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //
Finally I compile icoFoamRamped and myBCs library as directed and make the necessary changes to the system/controlDict and 0/U files to include the new ramped boundary condition and I get this error when running icoFoamRamped:

Code:
...

Create time

Create mesh for time = 0

Reading transportProperties

Reading field p

Reading field U

icoFoamRamped: symbol lookup error: /home/alexander/OpenFOAM/alexander-2.0.1/platforms/linux64GccDPOpt/lib/libMyBCs.so: undefined symbol: _ZN4Foam28rampedFixedValueFvPatchFieldINS_6VectorIdEEEC1ERKNS_7fvPatchERKNS_16DimensionedFieldIS2_NS_7volMeshEEERKNS_10dictionaryE
alexander@alexander-G50VT:~/OpenFOAM/alexander-2.0.1/run/cavity$
Where have I gone wrong?
bigbang is offline   Reply With Quote

Old   August 11, 2011, 09:53
Default
  #8
Senior Member
 
Paulo Vatavuk
Join Date: Mar 2009
Location: Campinas, Brasil
Posts: 196
Rep Power: 17
vatavuk is on a distinguished road
Hi,
The NUMAP 2009 also has interesting lectures: http://powerlab.fsb.hr/ped/kturbo/Op...2009/lectures/
happydogy and shang like this.
vatavuk is offline   Reply With Quote

Old   August 11, 2011, 10:07
Default
  #9
Senior Member
 
Paulo Vatavuk
Join Date: Mar 2009
Location: Campinas, Brasil
Posts: 196
Rep Power: 17
vatavuk is on a distinguished road
Hi Alex,
I haven't tried these tutorials yet. In the slides, Dr. Lucchini mentions version 1.41 of OpenFOAM. I don’t know if this tutorial is compatible with version 2.01.
vatavuk is offline   Reply With Quote

Old   August 11, 2011, 14:51
Default
  #10
Member
 
Alex
Join Date: Jun 2010
Location: Planet Earth
Posts: 43
Rep Power: 15
bigbang is on a distinguished road
Thanks anyway vatavuk. I will continue to debug. In the meantime there is such a wealth of information on this thread that I will continue to learn and come back to the tommaso problem.

Thanks again.
bigbang is offline   Reply With Quote

Old   August 13, 2011, 08:27
Default
  #11
Senior Member
 
Paulo Vatavuk
Join Date: Mar 2009
Location: Campinas, Brasil
Posts: 196
Rep Power: 17
vatavuk is on a distinguished road
Hi Marupio,
I've been navigating the wiki for some time but haven't seen this guide until I saw your link above. Sometimes it's difficult to find some pages in the wiki.
Congratulations for your guide it will help many people. Making a pdf of it will be even better.
vatavuk is offline   Reply With Quote

Old   February 15, 2012, 16:11
Default
  #12
New Member
 
Teng Wu
Join Date: Feb 2012
Posts: 9
Rep Power: 14
TengWU is on a distinguished road
Hi Alex,
Have you successfully completed the ramped boundary condition in Dr. Tommaso's programming tutorial now? These days I'm also trying to figure out the debugging errors during the compiling process. Some issues similar with yours shows up...

Teng
TengWU is offline   Reply With Quote

Old   July 9, 2015, 12:34
Default
  #13
Senior Member
 
Paulo Vatavuk
Join Date: Mar 2009
Location: Campinas, Brasil
Posts: 196
Rep Power: 17
vatavuk is on a distinguished road
Hi,

I noticed that the links in my post #2 are broken, so I made a search and found the updated links:

1)Dr. Hvoje Jasak presentation at the 6th OpenFOAM workshop
http://iweb.dl.sourceforge.net/proje...ak2_slides.pdf

2)Dr. Tommaso Lucchini programming tutorial
http://www.tfd.chalmers.se/~hani/kur...ngTutorial.pdf

3) The Programmer Guide Addendum (now openFOAM guide):
http://openfoamwiki.net/index.php/OpenFOAM_guide

Best Regards,
Paulo
vatavuk is offline   Reply With Quote

Old   February 13, 2017, 22:21
Default
  #14
Member
 
Declan
Join Date: Oct 2016
Location: Ireland
Posts: 40
Rep Power: 9
decah is on a distinguished road
This is still a very relevant thread for those looking to dive into the source code for the first time.

This course by Joel Guerrero has some excellent material, see module 7 for programming.
http://www.wolfdynamics.com/our-serv...ing.html?id=50

If anyone else has useful links please share!
PanPeter and dyle like this.
decah is offline   Reply With Quote

Old   July 10, 2018, 05:34
Default
  #15
New Member
 
Sebastian
Join Date: Sep 2013
Posts: 14
Rep Power: 12
BuzzB is on a distinguished road
Since I find it very helpfull, I want to share the tutorial of the user Artur here as well. It perfectly fits into the topic of this thread.

OpenFOAM programming tutorials for beginners
BuzzB 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
A book for a beginner wanting to learn programming frank Main CFD Forum 9 May 12, 2014 23:15
Cross-compiling OpenFOAM 1.7.0 on Linux for Windows 32 and 64bits with Mingw-w64 wyldckat OpenFOAM Announcements from Other Sources 3 September 8, 2010 06:25
OpenFoam programming prapanj OpenFOAM 10 March 18, 2010 07:23
Programming in OpenFOAM vinu OpenFOAM 2 July 11, 2009 10:16
Adventure of fisrst openfoam installation on Ubuntu 710 jussi OpenFOAM Installation 0 April 24, 2008 14:25


All times are GMT -4. The time now is 02:30.