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

Compiling a new thermophysical model

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By Gerry Kan
  • 1 Post By stockzahn

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 24, 2020, 06:28
Default Compiling a new thermophysical model
  #1
Member
 
stockzahn's Avatar
 
Join Date: Oct 2018
Location: France
Posts: 34
Rep Power: 7
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:


Code:
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?


Sincerely,
stockzahn
stockzahn is offline   Reply With Quote

Old   March 24, 2020, 09:24
Default
  #2
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 347
Rep Power: 10
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:

Code:
#ifndef __YOUR_HEADER_NAME__
#define __YOUR_HEADER_NAME__

  // contents of your original header file goes here

#endif
Hope that helps, Gerry.
stockzahn likes this.

Last edited by Gerry Kan; April 16, 2020 at 07:54.
Gerry Kan is offline   Reply With Quote

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


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


stockzahn


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.
Gerry Kan likes this.

Last edited by stockzahn; March 24, 2020 at 12:48.
stockzahn 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
[IHFOAM] The IHFOAM Thread Phicau OpenFOAM Community Contributions 392 September 8, 2023 18:10
viewFactor radiation model stuck shach934 OpenFOAM 1 May 25, 2021 11:01
[swak4Foam] swakExpression not writing to log alexfells OpenFOAM Community Contributions 3 March 16, 2020 18:19
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 11:17.