CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Compiling a new thermophysical model

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By Gerry Kan

LinkBack Thread Tools Search this Thread Display Modes
Old   March 24, 2020, 06:28
Default Compiling a new thermophysical model
New Member
stockzahn's Avatar
Join Date: Oct 2018
Location: France
Posts: 26
Rep Power: 3
stockzahn is on a distinguished road
Dear Foamers,

I'm making my own thermophysical model. For that reason I wrote some functions I want to you use to calculate the different properties (in thermoI.H, and the respective rho*I.H, transport*I.H, thermo*I.H files). I include the header-file declaring all my functions in "thermoI.H", otherwise the compilation fails, since my functions are not defined.

The compilation of libspecie works w/o problems, but when I try to compile libfluidThermophysicalModels (in the "basic" folder), I get compiler errors telling me, that my functions are multiple defined, e.g. a small fraction of the error message:

Make/linux64GccDPInt32Opt/rhoThermo/rhoThermos.o: In function `PN_sSCByPT(double, double)':
rhoThermos.C:(.text+0x6bce0): multiple definition of `PN_sSCByPT(double, double)'
Make/linux64GccDPInt32Opt/psiThermo/psiThermos.o:psiThermos.C:(.text+0x6bce0): first defined here

These lines occur for all of my functions twice:
- for psiThermos.o & rhoThermos.o
- for psiThermos.o & liquidThermo.o

It seems like the compiler declares the functions several times, since their definitions are called by "thermoI.H". I now tried several options to circumvent that issue, but without success. Does anybody has an idea how to solve that issue?

stockzahn is offline   Reply With Quote

Old   March 24, 2020, 09:24
Gerry Kan's Avatar
Gerry Kan
Join Date: May 2016
Posts: 93
Rep Power: 5
Gerry Kan is on a distinguished road
Dear Stockzahn:

It sounds like you might need to implement include guards to your header file, so that all the objects / functions only get declared once during compile.

You should surround the contents of your header file with the following lines":

#ifndef __YOUR_HEADER_NAME__
#define __YOUR_HEADER_NAME__

  // contents of your original header file goes here

Hope that helps, Gerry.
stockzahn likes this.
Gerry Kan is offline   Reply With Quote

Old   March 24, 2020, 11:10
New Member
stockzahn's Avatar
Join Date: Oct 2018
Location: France
Posts: 26
Rep Power: 3
stockzahn is on a distinguished road
Dear Gerry,

thanks for the fast response, unfortunately that didn't work.


EDIT: I solved it: obviously a very beginner's mistake: I tested the functions in a different program, for which in included all C-files in the header files. This was the problem, I just copied all files into the inlude-folder and deleted the #include-commands in the header-files. But thanks for the hint with the include guards! That will be advantegeous in the future.

Last edited by stockzahn; March 24, 2020 at 12:48.
stockzahn is offline   Reply With Quote


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[IHFOAM] The IHFOAM Thread Phicau OpenFOAM Community Contributions 311 March 25, 2020 10:15
[swak4Foam] swakExpression not writing to log alexfells OpenFOAM Community Contributions 3 March 16, 2020 18:19
viewFactor radiation model stuck shach934 OpenFOAM 0 September 16, 2019 18:14
Thermophysical transport model to include shear rate Janez Turk OpenFOAM Programming & Development 3 March 24, 2018 11:30
Water subcooled boiling Attesz CFX 7 January 5, 2013 03:32

All times are GMT -4. The time now is 00:09.