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/)
-   -   wmake compiling new solver (http://www.cfd-online.com/Forums/openfoam-programming-development/74499-wmake-compiling-new-solver.html)

mksca April 1, 2010 14:49

wmake compiling new solver
 
Hello everyone,

I've been experimenting with openFoam for a little while now and everything was going great. I am running the software on Mac OS X 10.5 and am trying to create a new solver from an existing one as per the tutorial by Lucchini (creating icoScalarTransportFoam from icoFoam...).

physics.ucsd.edu/students/courses/spring2009/.../Tutorial2.pdf

I have copied the icoFoam solver to my directory, renamed it and modified the .C,.H, Make/files, files as described but when I go to compile using wmake this is what appears:

/*******************************************/
/bin/sh: cpp-4.2: command not found
make: *** [darwinPpcDPOpt/options] Error 127
/bin/sh: cpp-4.2: command not found
make: *** [darwinPpcDPOpt/files] Error 127
wmake error
file 'Make/darwinPpcDPOpt/objectFiles' was not created successfully
/*******************************************/

I don't understand the error message. Any help would be more than welcome.
If i copy the files and options files into the darwinPpcDPOpt directory, it conpiles a little further and this is the output then:

Making dependency list for source file icoScalarTransportFoam.C
could not open file PrimitivePatch.C for source file icoScalarTransportFoam.C
could not open file labelPair.H for source file icoScalarTransportFoam.C
could not open file boundBox.H for source file icoScalarTransportFoam.C
could not open file pointZoneMesh.H for source file icoScalarTransportFoam.C
could not open file faceZoneMesh.H for source file icoScalarTransportFoam.C
could not open file cellZoneMesh.H for source file icoScalarTransportFoam.C
could not open file lduMesh.H for source file icoScalarTransportFoam.C
could not open file fvBoundaryMesh.H for source file icoScalarTransportFoam.C
could not open file surfaceInterpolation.H for source file icoScalarTransportFoam.C
could not open file DimensionedField.H for source file icoScalarTransportFoam.C
could not open file volFieldsFwd.H for source file icoScalarTransportFoam.C
could not open file surfaceFieldsFwd.H for source file icoScalarTransportFoam.C
could not open file pointFieldsFwd.H for source file icoScalarTransportFoam.C
could not open file slicedVolFieldsFwd.H for source file icoScalarTransportFoam.C
could not open file slicedSurfaceFieldsFwd.H for source file icoScalarTransportFoam.C
could not open file fvPatchFvMeshTemplates.C for source file icoScalarTransportFoam.C
could not open file fvc.H for source file icoScalarTransportFoam.C
could not open file fvMatrices.H for source file icoScalarTransportFoam.C
could not open file fvm.H for source file icoScalarTransportFoam.C
could not open file linear.H for source file icoScalarTransportFoam.C
could not open file calculatedFvPatchFields.H for source file icoScalarTransportFoam.C
could not open file fixedValueFvPatchFields.H for source file icoScalarTransportFoam.C
could not open file adjustPhi.H for source file icoScalarTransportFoam.C
could not open file findRefCell.H for source file icoScalarTransportFoam.C
could not open file mathematicalConstants.H for source file icoScalarTransportFoam.C
could not open file argList.H for source file icoScalarTransportFoam.C
could not open file timeSelector.H for source file icoScalarTransportFoam.C
could not open file setRootCase.H for source file icoScalarTransportFoam.C
could not open file createTime.H for source file icoScalarTransportFoam.C
could not open file createMesh.H for source file icoScalarTransportFoam.C
could not open file createFields.H for source file icoScalarTransportFoam.C
could not open file initContinuityErrs.H for source file icoScalarTransportFoam.C
could not open file readPISOControls.H for source file icoScalarTransportFoam.C
could not open file CourantNo.H for source file icoScalarTransportFoam.C
could not open file TEqn.H for source file icoScalarTransportFoam.C
could not open file continuityErrs.H for source file icoScalarTransportFoam.C
SOURCE=icoScalarTransportFoam.C ; g++-4.2 -DdarwinPpc -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/Users/seccarene/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -IlnInclude -I. -I/Users/seccarene/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/Users/seccarene/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -Ddarwin -arch ppc -c $SOURCE -o Make/darwinPpcDPOpt/icoScalarTransportFoam.o
/bin/sh: g++-4.2: command not found
make: *** [Make/darwinPpcDPOpt/icoScalarTransportFoam.o] Error 127

I would be very grateful for any help anyone could provide!

Thanks

wyldckat April 1, 2010 18:11

Greetings mksca,

OK, although I don't have access to a Mac, I'll assume that the inner workings in a terminal are similar to a Linux box. So, run this:
Code:

which gcc
gcc -v

This will give you two informations: where do you have gcc installed and what version of gcc do you have installed.

Assuming you do have gcc installed, the which command should have given you something like:
Code:

/usr/bin/gcc
If not, you'll have to install it. How, I don't have a clue on a Mac :(

Now, OpenFOAM's wmake is looking for the 4.2 version, by referring directly to gcc-4.2 and g++-4.2. So, when you have gcc up and running, look at the following files for references to gcc-4.2 and g++-4.2 and change them to gcc and g++:
Code:

OpenFOAM-1.5/etc/bashrc
OpenFOAM-1.5/wmake/rules/darwinPpc/*

Other than that, only Mac+foam users can give you a better guidance on to work the thing ;)

Best regards,
Bruno

mksca April 3, 2010 09:31

Hi wyldckat,

Thank you for your reply. I thought the problem was along those lines so I downloaded gcc-4.2 and tried it again. "gcc -v" gave me version 4.0.1 as my default. Editing the files you mentioned was also something i considered. The problem I'm facing now is that OpenFoam is saved onto a sparse disc image and the contents are therefore read only. Tried editing the access rights and so on, tried login in as root user and the files as still not writable...

Should the contents of my OpenFOAM disc image be copied in my project directory where it would become writable and then change all the paths in the relevant files to match... seems unlikely to be the best solution?

I do realize you may not be familiar with the Mac stuff and I therefore appeal to anyone who would be able to help me.

Another question however, should i be able to run tutorial cases if supposedly my version of gcc (4.0) is not adequate? Does wmake require gcc-4.2 or higher whereas the cases don't?

Thanks for your time,

Marc

wyldckat April 5, 2010 17:40

Hello again Marc
Quote:

Originally Posted by mksca (Post 252997)
The problem I'm facing now is that OpenFoam is saved onto a sparse disc image and the contents are therefore read only. Tried editing the access rights and so on, tried login in as root user and the files as still not writable...

For Linux there is are a few mounting tools called FUSE and UnionFS that could be of some use to you. Here is a list of some more implementations, but I'm not sure how they will work on Mac. Search for more about it online? Ah, if my mind isn't totally off, UnionFS or FUSE or both allow to join 2 or more folders/paths into a single one, and declaring which ones are read-only and which ones are writable. There for, you can use a folder as source for files, and another for keeping the changes.

By the way, just found one that might suit you:Source: Wikipedia :)

As for the rest, might I suggest "keeping it simple" and going with the latest OpenFOAM version as well as the latest threads for Mac OS X? Like this one? ;)

I say this, because in the OpenFOAM-1.5 folder you have, there should be a README file and inside it, it should state which is the minimum version of gcc required to build it. So, if you have to install a new version of gcc, might as well go with the latest high-tech: OpenFOAM 1.6 and gcc-4.3.3 ;)

Then again, you might need to stick to the disk image you've got. Uhm, didn't that image come with additional instructions?

Best regards,
Bruno

gschaider April 6, 2010 12:23

Quote:

Originally Posted by mksca (Post 252997)
Hi wyldckat,

Thank you for your reply. I thought the problem was along those lines so I downloaded gcc-4.2 and tried it again. "gcc -v" gave me version 4.0.1 as my default. Editing the files you mentioned was also something i considered. The problem I'm facing now is that OpenFoam is saved onto a sparse disc image and the contents are therefore read only. Tried editing the access rights and so on, tried login in as root user and the files as still not writable...

Should the contents of my OpenFOAM disc image be copied in my project directory where it would become writable and then change all the paths in the relevant files to match... seems unlikely to be the best solution?

I do realize you may not be familiar with the Mac stuff and I therefore appeal to anyone who would be able to help me.

Another question however, should i be able to run tutorial cases if supposedly my version of gcc (4.0) is not adequate? Does wmake require gcc-4.2 or higher whereas the cases don't?

Thanks for your time,

Marc

Where did you get the gcc from? Usually it is installed from XCode (a v4.0 and a v4.2, but I'm not sure which versions of XCode install the later. Usually XCode is found on the OS install media, Apple just doesn't advertise it very loudly. If you plan to download XCode make sure that it works with your OS version. The latest version of XCode does NOT work with you OS)

If your diskimage is read-only use the DiskManager to convert it to a write-able format (there is also a command-line tool for that)

As a last resort try cheating:
alias cpp-4.2=cpp-4.0
and so on

Bernhard

mksca April 6, 2010 18:27

Greetings all,:)

First of all thank you very much for your help Bernhard/Wyldckat! I have Xcode 3.0 already installed on my machine and gcc versions 3.3, 4.0, 4.2.(Is that ridiculous, should i remove the older versions??:o) After bernhard's advice, I managed to convert my diskimage to a read/write one and have edited the wmake files as suggested by wyldckat previously. I copied gcc 4.2 into /usr/local/bin via the terminal as it wasn't in that directory previously. That allowed me to compile a little further with wmake and here's what i get:

g++-4.2 -DdarwinPpc -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/Users/seccarene/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -IlnInclude -I. -I/Users/seccarene/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/Users/seccarene/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -Ddarwin -arch ppc -lpthread -L/Users/seccarene/OpenFOAM/OpenFOAM-1.5/lib/darwinPpcDPOpt -lOpenFOAM -L/Users/seccarene/OpenFOAM/OpenFOAM-1.5/lib/darwinPpcDPOpt/openmpi-1.2.3 -lPstream -L/Users/seccarene/OpenFOAM/OpenFOAM-1.5/lib/darwinPpcDPOpt \
-lfiniteVolume -lOpenFOAM -lpthread -lm -o OpenFOAM.out
ld: library not found for -lstdc++
make: *** [OpenFOAM.out] Error 1

It is now looking for -lstdc++, have you any idea what I should do?

Where do you have gcc saved on your mac bernhard? Would you recommend usr/local/bin as a good location or should i redefine the paths to the compiler? Still don't know how the problem doesn't occur when running the tutorials?

Thank you !:)

Marc

gschaider April 7, 2010 11:51

Quote:

Originally Posted by mksca (Post 253423)
Greetings all,:)

First of all thank you very much for your help Bernhard/Wyldckat! I have Xcode 3.0 already installed on my machine and gcc versions 3.3, 4.0, 4.2.(Is that ridiculous, should i remove the older versions??:o) After bernhard's advice, I managed to convert my diskimage to a read/write one and have edited the wmake files as suggested by wyldckat previously. I copied gcc 4.2 into /usr/local/bin via the terminal as it wasn't in that directory previously. That allowed me to compile a little further with wmake and here's what i get:

g++-4.2 -DdarwinPpc -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-40 -I/Users/seccarene/OpenFOAM/OpenFOAM-1.5/src/finiteVolume/lnInclude -IlnInclude -I. -I/Users/seccarene/OpenFOAM/OpenFOAM-1.5/src/OpenFOAM/lnInclude -I/Users/seccarene/OpenFOAM/OpenFOAM-1.5/src/OSspecific/Unix/lnInclude -fPIC -Ddarwin -arch ppc -lpthread -L/Users/seccarene/OpenFOAM/OpenFOAM-1.5/lib/darwinPpcDPOpt -lOpenFOAM -L/Users/seccarene/OpenFOAM/OpenFOAM-1.5/lib/darwinPpcDPOpt/openmpi-1.2.3 -lPstream -L/Users/seccarene/OpenFOAM/OpenFOAM-1.5/lib/darwinPpcDPOpt \
-lfiniteVolume -lOpenFOAM -lpthread -lm -o OpenFOAM.out
ld: library not found for -lstdc++
make: *** [OpenFOAM.out] Error 1

It is now looking for -lstdc++, have you any idea what I should do?

Where do you have gcc saved on your mac bernhard? Would you recommend usr/local/bin as a good location or should i redefine the paths to the compiler? Still don't know how the problem doesn't occur when running the tutorials?

Thank you !:)

Marc

Hi Marc!

You copied g++-4.2 from where? Just copying is not a good idea because now it will probably look for standard-libraries in the /usr/local-hierarchy.
The compiler relies on a lot of other things (libraries, tools) so a simple copy won't help

My g++-4.2 is in /usr/bin. If yours was there why did you copy it in the first place?

Bernhard

ENKIME August 1, 2014 15:16

Good Day Bruno
Bother you with some issue similar to Mksca.
I'm trying to create my own library of bio diesel to make simulations using Openfoam 2.3.0 with the solver sprayFoam.
So when Im running the compiling of the library this is the error that was displayed:

-I/opt/openfoam230/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64GccDPOpt/C18H32O2.o
jar cfm /home/adolfo/OpenFOAM/adolfo-2.3.0/platforms/linux64GccDPOpt/lib/libmy_liqprop .jar -lthermophysicalFunctions -C Make/classes .
make: jar: Command not found
make: *** [/home/adolfo/OpenFOAM/adolfo-2.3.0/platforms/linux64GccDPOpt/lib/libmy_liqprop] Error 127


So the lib folder is empty and I can't compile without errors and also the new solver where I add that library doesn't use any of the fuel's in that folder I guess that maybe this is the reason.
Any clue would be appreciated.
Kind regards
Kind regars

wyldckat August 4, 2014 12:41

Greetings ENKIME,

It's asking about a "jar" executable? What was the exact command you used to try and build the library?
I ask this because "jar" is only needed for building Java applications.

And can you provide more information? It's really a strange error you're getting.

Best regards,
Bruno

ENKIME August 4, 2014 16:43

Hi Bruno
I already can compile the solver but I can't make it work, when I'm running the solver, already compiled and with out errors, doesn't use the new library and send me the error message that liquid is not in the src library when I already create a new library with that liquid, compiled and added to the new compiled solver.
Really that's the deal.
Thanks a lot for that quick answer.
Kind regards

wyldckat August 5, 2014 13:38

Quote:

Originally Posted by ENKIME (Post 504371)
I already can compile the solver but I can't make it work, when I'm running the solver, already compiled and with out errors, doesn't use the new library and send me the error message that liquid is not in the src library when I already create a new library with that liquid, compiled and added to the new compiled solver.
Really that's the deal.

:confused: Uhm... you're not providing much information :(.
It would make it a lot easier to diagnose the problem if you shared more details, namely:
  1. What were the exact steps you've taken to create the library?
  2. How exactly did you add it to the solver?
  3. How did you configure your case to use your new library?

ENKIME August 5, 2014 16:03

Sorry Bruno let me be more clear.
1. I copy and compile a new library of liquid properties:
From the src/thermophysicalmodels/properties/liquidProperties.. I copy only the properties of tri-decane to my user utilities using the bash commands for openFoam:
Steps:
a)
Code:

mkdir -p $WM_PROJECT_USER_DIR/applications
cp -r $FOAM_SRC/thermophysicalmodels/properties/liquidProperties/C13H28 $WM_PROJECT_USER_DIR/applications/myliquidproperties

with this I create the new folder with all the information of the tri-decane

b)I rename the new C13H28 folder and all the files in there, also using the command
Code:

sed i s/C13H28/C18H32O2/g C18H32O2.C
sed i s/C13H28/C18H32O2/g C18H32O2.H
sed i s/C13H28/C18H32O2/g C18H32O2I.H

For changing all the words with C13H28 for C18H32O2

b)Also copy all the liquidProperties solver the .C, .H and the I.H.
c) Using, in the main folder myliquidproperties, the next command:
Code:

mkdir Make
touch Make/files

Code:

liquidProperties/liquidProperties.C
C18H32O2/C18H32O2.C
LIB = $(FOAM_USER_LIBBIN)/libmyliquidProperties

Code:

touch Make/options
the contents of Make/options
Code:

EXE_INC = \
    -I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude

LIB_LIBS = \
    -lthermophysicalFunctions

c) Using wclean to remove all dependencies, and using wmake libso to compile the library
and then a lib folder was created with libmyliquidProperties.so

2. For adding to my new solver:
a) Using the same procedure I create a new solver called my_sprayFoam with the respectively pEqn.H, rhoEqn.H, UEqn.H, YEqn.H and EEqn.H.

b)In the make folder I modify the options file with the next line:
Code:

-I$(WM_PROJECT_USER_DIR)/applications/myliquidProperties/liquidProperties/lnInclude \
where I make the dependency to my new library.

c) Using wmake I compile the new solver with the new library in dependency

3. In this is the last step that is need to be done. In the controldic file at the end of the file is need to be added something like this:
Code:

libs
  (
    "libmyliquidProperties.so"
  );

When I finally add this line the simulation works and use the library that need to be.


I guess this is as far as I can go and there is no more solutions for the compilation problems.

Kind Regards

wyldckat August 17, 2014 13:34

Hi ENKIME,

Nice! This makes it a lot easier to diagnose what might have gone wrong.
I hope you don't mind, I've did a small edition to your post and added the "[CODE]" markers to make it easier to figure out which parts are code. An explanation on how this can be done is in one of the links in my signature below.

OK, there are a few details that stand out to me right away:
  1. Only adding this:
    Code:

    -I$(WM_PROJECT_USER_DIR)/applications/myliquidProperties/liquidProperties/lnInclude \
    to "Make/options" in the solver does not guarantee that the library will be used. Unless you use "#include" in the source code for including a particular header/source code file.
  2. It's not strictly necessary to include a header file from the new library in your solver, unless you need to explicitly use a new variable made up of the new class.
  3. Either way, using the "libs" in the case's "system/controlDict" file should work, but only if you have a single library being loaded. For example, this won't work:
    Code:

    libs    ("libgroovyBC.so");
    //...
    libs    ("libmyliquidProperties.so");

    In such a situation, it should be used this instead:
    Code:

    libs    ("libgroovyBC.so" "libmyliquidProperties.so");
    Or like this:
    Code:

    libs
      (
        "libgroovyBC.so"
        "libmyliquidProperties.so"
      );

  4. Sometimes it's possible to forcefully link the solver to a new library - and therefore not need to use "libs" in "controlDict" - simply by adding the corresponding line in the file "Make/options":
    Code:

    EXE_LIBS = \
        -lfiniteVolume \
        -lmeshTools \
        -lsampling \
    /* ... lots of libraries in sprayFoam ... */
        -lfvOptions \
        -lcombustionModels \
        -L$(FOAM_USER_LIBBIN) -lmyliquidProperties

Now, the details above do not make or break your situation, because you have proceeded very well so far. The remaining possible issue is that the new model in the library is not being loaded up to the look-up list.

Mmm... no, that's not it. After reviewing the steps you've given and the description I've given in this post, it looks like the problem is that even though you did properly modify this line in "Make/options":
Code:

-I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
to this:
Code:

-I$(WM_PROJECT_USER_DIR)/applications/myliquidProperties/liquidProperties/lnInclude \
you did not remove the line "-lliquidProperties" from the "EXE_LIBS". This means that you probably should have seen an error near the start of the solver stating that it was not possible to load your new library, due to object naming collision.
The missing step is very likely what I described in detail #4 and keep in mind to remove the line "-lliquidProperties".

Best regards,
Bruno

ENKIME August 18, 2014 22:26

1 Attachment(s)
Dear Bruno
Thanks a lot for your answer this post really help me to solve that issue that was driving me crazy.
I can run easily take a look.
The original liquid was tridecane and the new one is linoleic acid, the next step is to modify the constants for the liquid properties to complete a biodiesel-diesel blend.
Again my friend thanks a lot
Kind Regards


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