CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How to write Make/options File (http://www.cfd-online.com/Forums/openfoam-programming-development/93481-how-write-make-options-file.html)

camoesas October 17, 2011 08:56

How to write Make/options File
 
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

Hisham October 17, 2011 14:51

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

camoesas October 18, 2011 07:40

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.

Hisham October 18, 2011 08:05

You make it appear as if I've misunderstood utility :D

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

camoesas October 18, 2011 09:07

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.

camoesas October 18, 2011 09:55

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


wyldckat October 18, 2011 17:05

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

Hisham October 18, 2011 17:27

I think you need to add:
Code:

# include "RASModel.H"
before the int main

Weil es nicht definiert ist :D

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 :rolleyes:)

Regards
Hisham

camoesas October 20, 2011 04:06

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! :(

Hisham October 20, 2011 04:17

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

camoesas October 20, 2011 04:56

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?

Hisham October 20, 2011 05:12

Quote:

Originally Posted by camoesas (Post 328695)
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

camoesas October 20, 2011 05:17

Code:

LIB_SRC: command not found

Let me guess: This isnt good?

Hisham October 20, 2011 05:33

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.

camoesas October 20, 2011 08:07

HI Hisham,

I have tried both:

Code:

echo $LIB_SRC
is empty

Code:

echo $FOAM_SRC
returns: OpenFoam/Openfoam-2.0.0/src

Hisham October 20, 2011 08:47

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.

wyldckat October 20, 2011 16:48

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

Hisham October 20, 2011 16:59

Hi Bruno

Thanks a lot! This is very informative!

Regards,
Hisham


All times are GMT -4. The time now is 16:34.