CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   #include directives? (

Natalie2210 May 14, 2013 05:04

#include directives?

I'm sorry since this is a basic question, but I'm pretty much confused about finding #include - directives within function bodys in OpenFOAM. What do they do there - I always thought #includes were preprocessor directives?

Thanks a lot,

akidess May 14, 2013 05:18

They are preprocessor directives indeed. You still retain the freedom to place them anywhere you want.

ngj May 14, 2013 05:50

Hi Natalie,

Yes, it is a bit confusing at first.

In OF you have the standard inclusion of header files, which tells the solver/utility/etc, which methods can be used in the program. These are those placed before "main".

Secondly, a considerable amount of source code is used several places throughout different solver, e.g. createMesh.H or createDynamicFvMesh.H. These are not conventional header files, but merely bits of source code, which construct different types of finite volume meshes. These are also included into the solvers/utilities using include statements, and I suppose this approach has been adopted in order to avoid duplicating source code and thereby reducing the risk of bugs.

Kind regards


Natalie2210 May 14, 2013 06:09

ah ok. I have had a look at the header files and they actually contain code which is, it seems, pasted by the preprocessor into the source. Thank you!


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