CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   cfd codes in c language? (http://www.cfd-online.com/Forums/main/106315-cfd-codes-c-language.html)

nikhilbagalkot August 24, 2012 21:30

cfd codes in c language?
 
can anyone please help me how to start with c coding in cfd, i.e any study material which has good number of examples with codes.

yonchong August 25, 2012 10:26

Openfoam is written with C++ and open source. You should be able to see the source code but I don't know why you want to write CFD code in C as it will take a huge effort.

cfdnewbie August 25, 2012 10:33

C or Fortran are the languages of choice for efficient codes, so writing one in C is not a bad idea!

yonchong August 25, 2012 10:37

Sorry I did not meant the choice of language was wrong but rather why do you want to write a CFD code any way.

nikhilbagalkot August 25, 2012 11:13

Quote:

Originally Posted by nikhilbagalkot (Post 378615)
can anyone please help me how to start with c coding in cfd, i.e any study material which has good number of examples with codes.

THANKS for the sugestions but none of you have answered my question, please help me:confused:.let me know a good study material or website for the above purpose.

cfdnewbie August 25, 2012 11:28

Quote:

Originally Posted by yonchong (Post 378665)
Sorry I did not meant the choice of language was wrong but rather why do you want to write a CFD code any way.


You should rather encourage him :) It is the best and only way to truly learn CFD! Anyone doing CFD should be forced to write a least a simple 2 code in my opinion! :)

regarding the question of study material for a C cfd code...I'm afraid there is none, at least I have never seen something. Is your focus on learning CFD (then you will find some good books in the section here in the forum) or learning C? Then there are certainly a lot of free resources on the web...

I guess the short answer is:
If you want to learn CFD, then take a class or read some books / papers.
If you want to learn how to program, just program :)=

leflix August 25, 2012 11:31

Quote:

Originally Posted by nikhilbagalkot (Post 378669)
THANKS for the sugestions but none of you have answered my question, please help me:confused:.let me know a good study material or website for the above purpose.

To learn C programming, there exist a huge quantity of material available on internet, just type " C tutorial" on google.

First you have to master the language by learning it, in a general context, not CFD.

Second start to learn CFD and discretization methods,schemes and algorithm.
The book from Gribel

http://books.google.fr/books/about/N...cC&redir_esc=y

is very good for that. Especially because after you can get his code Nast2D. As it is written in C it should fulfil your will

http://home.arcor.de/drklaus.bauerfe.../eNaSt2DA.html



Good luck !

yonchong August 25, 2012 11:58

I also don't know any textbook with CFD code listing in C.

However, if you are willing to learn Fortran, I used a book called "Computer-Aided Engineering: Heat transfer and fluid flow" by Gosman, Launder and Reece when I was an undergrad. They are the force behind Start CD.

Fortran style in the book is now very old but Fortran is still very useful language for scientic code so I don't think it is a complete waste of time to learn the language.

leflix August 25, 2012 13:15

Quote:

Originally Posted by yonchong (Post 378675)
but Fortran is still very useful language for scientic code so I don't think it is a complete waste of time to learn the language.


yes but he wants to learn C!! and we can imagine that he certainly knows why! ;)

yonchong August 25, 2012 21:39

I wasn' t saying he shouldn't be learning C. I am saying he could learn Fortran as well.

I think people talk too much about which languages to use but most of the tasks can be done with any language including BASIC. However C and Fortran are the most common and you should learn both if you are serious about programming. Frankly I have seen more Fortran than C but that's because I am working in an engineering company not software company and old fashioned. :-)

cdegroot August 26, 2012 10:15

Quote:

Originally Posted by cfdnewbie (Post 378671)
You should rather encourage him :) It is the best and only way to truly learn CFD! Anyone doing CFD should be forced to write a least a simple 2 code in my opinion! :)

Thank you for this comment! I could not agree with you more. You hear a lot these days that you should not write your own CFD code because of tools like openfoam. Seriously, if you want to be a CFD developer or even an "expert" CFD user you need to write at least one code yourself, even if it is a simple one... not to be confused with SIMPLE :)

leflix August 26, 2012 12:23

Quote:

Originally Posted by cdegroot (Post 378748)
You hear a lot these days that you should not write your own CFD code because of tools like openfoam. Seriously, if you want to be a CFD developer or even an "expert" CFD user you need to write at least one code yourself, even if it is a simple one...

You told the truth cdegroot and cfdnewbie!!!! I perfectly agree with you. I will never talk deeply with a so called CFD "expert" until I'm sot sure he has already written a code whatever it is.
Because it's only when you put your hands in dirty oil that you become a good car mechanic ;)
Theory is good but practice is invaluable!
So please let nikhilbagalkot conducting his own experience... It would be great for him.

FMDenaro August 26, 2012 15:43

Quote:

Originally Posted by leflix (Post 378753)
You told the truth cdegroot and cfdnewbie!!!! I perfectly agree with you. I will never talk deeply with a so called CFD "expert" until I'm sot sure he has already written a code whatever it is.
Because it's only when you put your hands in dirty oil that you become a good car mechanic ;)
Theory is good but practice is invaluable!
So please let nikhilbagalkot conducting his own experience... It would be great for him.

I agree, definitely! writing a cfd code is a necessary (but not sufficient) to come into issues of CFD.
I have no idea of a book where you can find example of C++ applied in CFD, expecially for newcomer in CFD ...I think to only C++ program-language book that treat general topics maybe an idea could be to use Maple programming a general algorithm and then use the translate function in C ...

However, see Ref at page 22 of http://powerlab.fsb.hr/ped/kturbo/op...s/C++Intro.pdf

leflix August 26, 2012 18:24

nikhilbagalkot is not seeking for C++ code but C code. And I gave him the reference of NaSt2D code written in C.
If he wants C++ Openfoam is a must...but perhaps a bit difficult to start with when you do not have a sufficient experience.
iNavier is also in C++ and I guess there exist others...

Jet_Power September 10, 2012 09:56

There are CFD solvers written by C. I'm sure. If you want to develop a new solver for a company or an institue, the choose of C is also a good way.
For learning or hoppy, in my opinion, Python is better.


All times are GMT -4. The time now is 18:26.