CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Beginner: How to bridge the gap between basic C++ knowledge to openFOAM programming (https://www.cfd-online.com/Forums/openfoam-programming-development/91399-beginner-how-bridge-gap-between-basic-c-knowledge-openfoam-programming.html)

bigbang August 9, 2011 14:32

Beginner: How to bridge the gap between basic C++ knowledge to openFOAM programming
 
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

vatavuk August 10, 2011 10:03

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

bigbang August 10, 2011 13:07

Thanks for this reply. Very helpful.

elvis August 11, 2011 07:45

Hello,

have you read http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2010/ and the years before?

bigbang August 11, 2011 08:31

Quote:

Originally Posted by elvis (Post 319734)
Hello,

have you read http://www.tfd.chalmers.se/~hani/kurser/OS_CFD_2010/ and the years before?

Great academic reference. Thank you.

marupio August 11, 2011 09:50

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.

bigbang August 11, 2011 09:51

Quote:

Originally Posted by vatavuk (Post 319626)
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?

vatavuk August 11, 2011 09:53

Hi,
The NUMAP 2009 also has interesting lectures: http://powerlab.fsb.hr/ped/kturbo/Op...2009/lectures/

vatavuk August 11, 2011 10:07

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.

bigbang August 11, 2011 14:51

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.

vatavuk August 13, 2011 08:27

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.

TengWU February 15, 2012 16:11

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

vatavuk July 9, 2015 12:34

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

decah February 13, 2017 22:21

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!

BuzzB July 10, 2018 05:34

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.

https://www.cfd-online.com/Forums/op...beginners.html


All times are GMT -4. The time now is 12:04.