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

How to write Make/options File

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

Reply
 
LinkBack Thread Tools Display Modes
Old   October 17, 2011, 08:56
Default How to write Make/options File
  #1
Senior Member
 
Join Date: Mar 2009
Posts: 138
Rep Power: 7
camoesas is on a distinguished road
Hello Everybody,

I am trying to write my first utility (function was standing here :-).
I have started with a given one and applied some changes. But I don´t know how to adopt the 'options'-File in Make directory. I cant find any Information of how this file should be.

Can you give me some hints, literature, anything?

Thanks

Camoesas
__________________
OF - 2.0.0

Last edited by camoesas; October 18, 2011 at 08:59.
camoesas is offline   Reply With Quote

Old   October 17, 2011, 14:51
Default
  #2
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
Hi Camoesas

What do you mean by function? A new function in the same .C file? Code in a separate header included in your .C? Both need no change in Make files/options.

If you mean a new .so library (a .H and .C that are separate from the solver but the header is included in the solver) you need to add the last line of:
Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I.../lnInclude \
    -I<yourLibraryName>/lnInclude \
Note that before the name of your library you add an "l". You also need to include the path to the new .C file in the files file (like the solvers .C).

If you want to develop a generic BC, follow this tutorial:
http://cfd.iut.ac.ir/files/Tutorial,...20Diego%20.pdf

This should also apply to generic libraries.

Note that you can use #codeStream starting from OF 2.x. It is quite powerful. It may give you what you need without having to go coding in depth.

Best regards,
Hisham
Hisham is offline   Reply With Quote

Old   October 18, 2011, 07:40
Default
  #3
Senior Member
 
Join Date: Mar 2009
Posts: 138
Rep Power: 7
camoesas is on a distinguished road
Hey Hisham,

thanks for your reply. I mean I am writing a new utility to calculate wallshearstress in compressible cases. sorry for the incorrect expression in the first post.
__________________
OF - 2.0.0

Last edited by camoesas; October 18, 2011 at 09:08.
camoesas is offline   Reply With Quote

Old   October 18, 2011, 08:05
Default
  #4
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
You make it appear as if I've misunderstood utility

Anyways, I haven't done that before but looking at an example utility say gmshToFoam.C, the files file is straight forward (also when you have more than one .C file)

Code:
gmshToFoam.C
OtherCppFile.C

EXE = $(FOAM_APPBIN)/gmshToFoam
But the options file will be tricky as it depends on which Foam libraries do you need in your code. My approach would be:
1. Be generous, when in doubt include the library.
2. Look for Foam utilities/solvers that use the same libraries you need and typically copy the library includes from there.
3. I do not think it is a problem to over include libraries in the make files but if one needs to be picky that can need time, reading, and trial to find out which includes are really needed. I guess compile error messages would help ease the search!

Good luck
Hisham
Hisham is offline   Reply With Quote

Old   October 18, 2011, 09:07
Default
  #5
Senior Member
 
Join Date: Mar 2009
Posts: 138
Rep Power: 7
camoesas is on a distinguished road
Hey Hisham,

sorry youre right, it appears as if you just understand BOLD. :-) I have fixed it in the first post.

I will do try and error and include some more libraries.
__________________
OF - 2.0.0

Last edited by camoesas; October 18, 2011 at 09:55.
camoesas is offline   Reply With Quote

Old   October 18, 2011, 09:55
Default
  #6
Senior Member
 
Join Date: Mar 2009
Posts: 138
Rep Power: 7
camoesas is on a distinguished road
Here is the wmake output:

Code:
camoesas@chico:~/OpenFOAM/camoesas-2.0.0-dev/rhoWallShearStress> wmake
Making dependency list for source file rhoWallShearStress.C
SOURCE=rhoWallShearStress.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/meshTools/lnInclude -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/transportModels -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/turbulenceModels -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/thermophysicalModels/basic/lnInclude -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/OpenFOAM/lnInclude -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/rhoWallShearStress.o
rhoWallShearStress.C: In Funktion »int main(int, char**)«:
rhoWallShearStress.C:65:33: Fehler: »RASModel« wurde in diesem Gültigkeitsbereich nicht definiert
In file included from rhoWallShearStress.C:106:0:
/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/finiteVolume/lnInclude/compressibleCreatePhi.H:49:23: Fehler: »rho« wurde in diesem Gültigkeitsbereich nicht definiert
rhoWallShearStress.C:145:44: Fehler: no match for »operator=« in »((Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField*)wallShearStress.Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]())->Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::<anonym>.Foam::FieldField<Foam::fvPatchField, Foam::Vector<double> >::<anonym>.Foam::PtrList<T>::operator[] [with T = Foam::fvPatchField<Foam::Vector<double> >, Foam::label = int](patchi) = Foam::operator*(const Foam::UList<double>&, const Foam::tmp<Foam::Field<double> >&)(((const Foam::tmp<Foam::Field<double> >&)((const Foam::tmp<Foam::Field<double> >*)(& Foam::mag(const Foam::tmp<Foam::Field<Type> >&) [with Type = Foam::Vector<double>]()))))«
/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/finiteVolume/lnInclude/fvPatchField.C:266:6: Anmerkung: Kandidaten sind: void Foam::fvPatchField<Type>::operator=(const Foam::UList<T>&) [with Type = Foam::Vector<double>]
/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/finiteVolume/lnInclude/fvPatchField.C:276:6: Anmerkung:                  void Foam::fvPatchField<Type>::operator=(const Foam::fvPatchField<Type>&) [with Type = Foam::Vector<double>]
/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/finiteVolume/lnInclude/fvPatchField.C:387:6: Anmerkung:                  void Foam::fvPatchField<Type>::operator=(const Type&) [with Type = Foam::Vector<double>]
rhoWallShearStress.C:139:43: Warnung: Variable »mutPw« wird nicht verwendet
rhoWallShearStress.C:60:33: Warnung: Variable »state« wird nicht verwendet
make: *** [Make/linux64GccDPOpt/rhoWallShearStress.o] Fehler 1
__________________
OF - 2.0.0
camoesas is offline   Reply With Quote

Old   October 18, 2011, 17:05
Default
  #7
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,326
Blog Entries: 32
Rep Power: 72
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
Greetings to all!

@camoesas: See this tutorial: http://openfoamwiki.net/index.php/Ho...ure_to_icoFoam - Follow it closely and pay attention to the details

For a bit more, see also the online user guide: http://www.openfoam.com/docs/user/co...p#x10-690003.2

Note: I didn't pay much attention to the error messages in your post above Hopefully you'll figure it out after reading the links I've written down.

Best regards and good luck!
Bruno
wyldckat is offline   Reply With Quote

Old   October 18, 2011, 17:27
Default
  #8
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
I think you need to add:
Code:
# include "RASModel.H"
before the int main

Weil es nicht definiert ist

And then you need to figure out which library does the "RASModel.H" compile to in Foam and include it in the make/options file.

You should treat further similar errors in the same manner (as illustrated in Bruno's links):
1. Include the header files you need
2. Figure out which library they compile to in Foam and add it to options file (be generous )

Regards
Hisham
Hisham is offline   Reply With Quote

Old   October 20, 2011, 04:06
Default
  #9
Senior Member
 
Join Date: Mar 2009
Posts: 138
Rep Power: 7
camoesas is on a distinguished road
HI,

@Santos: Thanks for the tutorial you´ve posted. I´ve been browsing throw and its similar to the one of Tommaso. I have already tried this one, but it isnt working for OF-2.0.0

@Hisham: I have included:
Code:
#include "RASModel.H"
before int main. And checked the options file:

Make/options:
Code:
EXE_INC = \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/turbulenceModels \
    -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions \
    -I$(LIB_SRC)/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions \
    -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \
    -I$(LIB_SRC)/turbulenceModels/compressible/RAS/RASModel \
    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
    -I$(LIB_SRC)/finiteVolume/lnInclude

EXE_LIBS = \
    -lincompressibleRASModels \
    -lincompressibleTransportModels \
    -lbasicThermophysicalModels \
    -lspecie \
    -lcompressibleRASModels \
    -lfiniteVolume \
    -lgenericPatchFields
I have added the RASModel to make/options file (bold) but it still gives me the error:

Code:
camoesas@chico:~/OpenFOAM/camoesas-2.0.0-dev/rhoWallShearStress> wmake
Making dependency list for source file rhoWallShearStress.C
SOURCE=rhoWallShearStress.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/meshTools/lnInclude -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/transportModels -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/turbulenceModels -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/turbulenceModels/incompressible/RAS/RASModel -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/turbulenceModels/compressible/RAS/RASModel -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/thermophysicalModels/basic/lnInclude -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/finiteVolume/lnInclude -IlnInclude -I. -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/OpenFOAM/lnInclude -I/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/rhoWallShearStress.o
rhoWallShearStress.C: In Funktion »int main(int, char**)«:
rhoWallShearStress.C:67:33: Fehler: »RASModel« wurde in diesem Gültigkeitsbereich nicht definiert
In file included from rhoWallShearStress.C:108:0:
/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/finiteVolume/lnInclude/compressibleCreatePhi.H:49:23: Fehler: »rho« wurde in diesem Gültigkeitsbereich nicht definiert
rhoWallShearStress.C:147:44: Fehler: no match for »operator=« in »((Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField*)wallShearStress.Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField [with Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]())->Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField::<anonym>.Foam::FieldField<Foam::fvPatchField, Foam::Vector<double> >::<anonym>.Foam::PtrList<T>::operator[] [with T = Foam::fvPatchField<Foam::Vector<double> >, Foam::label = int](patchi) = Foam::operator*(const Foam::UList<double>&, const Foam::tmp<Foam::Field<double> >&)(((const Foam::tmp<Foam::Field<double> >&)((const Foam::tmp<Foam::Field<double> >*)(& Foam::mag(const Foam::tmp<Foam::Field<Type> >&) [with Type = Foam::Vector<double>]()))))«
/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/finiteVolume/lnInclude/fvPatchField.C:266:6: Anmerkung: Kandidaten sind: void Foam::fvPatchField<Type>::operator=(const Foam::UList<T>&) [with Type = Foam::Vector<double>]
/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/finiteVolume/lnInclude/fvPatchField.C:276:6: Anmerkung:                  void Foam::fvPatchField<Type>::operator=(const Foam::fvPatchField<Type>&) [with Type = Foam::Vector<double>]
/home/camoesas/OpenFOAM/OpenFOAM-2.0.0/src/finiteVolume/lnInclude/fvPatchField.C:387:6: Anmerkung:                  void Foam::fvPatchField<Type>::operator=(const Type&) [with Type = Foam::Vector<double>]
rhoWallShearStress.C:141:43: Warnung: Variable »mutPw« wird nicht verwendet
make: *** [Make/linux64GccDPOpt/rhoWallShearStress.o] Fehler 1
This makes me sad!
__________________
OF - 2.0.0
camoesas is offline   Reply With Quote

Old   October 20, 2011, 04:17
Default
  #10
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
I guess you have a missing point .... No really a missing point:
Code:
EXE_INC = \
     -I. \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/transportModels \
    -I$(LIB_SRC)/turbulenceModels \
    -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions \
    -I$(LIB_SRC)/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions \
    -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \
    -I$(LIB_SRC)/turbulenceModels/compressible/RAS/RASModel \
    -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
    -I$(LIB_SRC)/finiteVolume/lnInclude

EXE_LIBS = \
    -lincompressibleRASModels \
    -lincompressibleTransportModels \
    -lbasicThermophysicalModels \
    -lspecie \
    -lcompressibleRASModels \
    -lfiniteVolume \
    -lgenericPatchFields
This point is very important because it points to the utilities own directory.

I hope this helps!

Regards,
Hisham
Hisham is offline   Reply With Quote

Old   October 20, 2011, 04:56
Default
  #11
Senior Member
 
Join Date: Mar 2009
Posts: 138
Rep Power: 7
camoesas is on a distinguished road
HI Hisham,

Unfortunately this point makes no difference. I have compared the error messages and they are nearly identical...

Is the order of the linked libraries and header files important?
__________________
OF - 2.0.0
camoesas is offline   Reply With Quote

Old   October 20, 2011, 05:12
Default
  #12
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
Quote:
Originally Posted by camoesas View Post
HI Hisham,

Unfortunately this point makes no difference. I have compared the error messages and they are nearly identical...

Is the order of the linked libraries and header files important?
Can you echo the $(LIB_SRC) in the terminal:

Code:
$ echo $LIB_SRC

Last edited by Hisham; October 20, 2011 at 05:28.
Hisham is offline   Reply With Quote

Old   October 20, 2011, 05:17
Default
  #13
Senior Member
 
Join Date: Mar 2009
Posts: 138
Rep Power: 7
camoesas is on a distinguished road
Code:
LIB_SRC: command not found

Let me guess: This isnt good?
__________________
OF - 2.0.0
camoesas is offline   Reply With Quote

Old   October 20, 2011, 05:33
Default
  #14
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
I'm sorry I made a mistake

Code:
$ echo $LIB_SRC
without brackets.

If the variable is empty then you can try to use $FOAM_SRC instead.
Hisham is offline   Reply With Quote

Old   October 20, 2011, 08:07
Default
  #15
Senior Member
 
Join Date: Mar 2009
Posts: 138
Rep Power: 7
camoesas is on a distinguished road
HI Hisham,

I have tried both:

Code:
echo $LIB_SRC
is empty

Code:
echo $FOAM_SRC
returns: OpenFoam/Openfoam-2.0.0/src
__________________
OF - 2.0.0
camoesas is offline   Reply With Quote

Old   October 20, 2011, 08:47
Default
  #16
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
I think you can replace LIB_SRC with FOAM_SRC in options file and compile, although I don't think that will solve the problem.

To be honest, I think you should copy a utility from foam and only change the name of the .H & .C files and the name in Make/ files & options .... and change to $(FOAM_USER_APPBIN) in the files file and then compile it (that should work).

After that try taking it one step at a time. With every change (not literally) do a compile, so you have early control over bugs.
Hisham is offline   Reply With Quote

Old   October 20, 2011, 16:48
Default
  #17
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 7,326
Blog Entries: 32
Rep Power: 72
wyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the roughwyldckat is a jewel in the rough
Greetings to all!

"LIB_SRC" is defined in "wmake/Makefile": https://github.com/OpenFOAM/OpenFOAM...e/Makefile#L58
That is why it's not visible in the terminal/shell.

@camoesas: As for including the RASModel headers, use this instead:
Code:
-I$(LIB_SRC)/turbulenceModels/incompressible/RAS/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \
If you had studied a bit more how other applications and utilities include headers, you might have figured out that the "lnInclude" folders have symbolic links (i.e., shortcuts) for all of the headers for that library where the folder is present. This is a simpler way to not need to include that long list of folders you were adding to the "options" file
More about this here: http://www.openfoam.com/docs/user/co...0-720003.2.2.1 - section "3.2.2.1 Including headers".

Best regards,
Bruno

Last edited by wyldckat; October 20, 2011 at 17:29. Reason: had a malformed sentence!
wyldckat is offline   Reply With Quote

Old   October 20, 2011, 16:59
Default
  #18
Senior Member
 
Hisham's Avatar
 
Hisham El Safti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 247
Blog Entries: 10
Rep Power: 7
Hisham is on a distinguished road
Hi Bruno

Thanks a lot! This is very informative!

Regards,
Hisham
Hisham is offline   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Working directory via command line Luiz CFX 4 March 6, 2011 20:02
pisoFoam compiling error with OF 1.7.1 on MAC OSX Greg Givogue OpenFOAM Programming & Development 3 March 4, 2011 17:18
OF 1.6 | Ubuntu 9.10 (64bit) | GLIBCXX_3.4.11 not found piprus OpenFOAM Installation 22 February 25, 2010 13:43
tecio compilation errors in latest 1.6.x rsamuel OpenFOAM Bugs 1 December 22, 2009 03:34
Paraview command not found hardy OpenFOAM Paraview & paraFoam 7 September 18, 2008 04:59


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