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

Error trying to compile new solver.C

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

Like Tree1Likes
  • 1 Post By floquation

Reply
 
LinkBack Thread Tools Display Modes
Old   June 20, 2017, 10:11
Default Error trying to compile new solver.C
  #1
Member
 
Join Date: May 2017
Posts: 40
Rep Power: 2
LThomes is on a distinguished road
Hello,
I'm trying to control the Courrant number and my ajustTimeStep is not working. So I think i have to modify the icoFoam.C to be able to make it work. However, I'm facing some trouble.
I'm following this tutorial http://www.tfd.chalmers.se/~hani/kur...tersReport.pdf to create a new solver "myIcoFoam".
So I've done these steps:
_____________________________________
Code:
sol
cp -r incompressible/icoFoam/ $WM_PROJECT_USER_DIR/applications/solvers/
cd $WM_PROJECT_USER_DIR/applications/solvers
mv icoFoam myIcoFoam
cd myIcoFoam
mv icoFoam.C myIcoFoam.C
sed -i s/icoFoam/myIcoFoam/g myIcoFoam.C
sed -i s/icoFoam/myIcoFoam/g Make/files
To set the library path right, do following change in Make/files:
change
EXE = $(FOAM_APPBIN)/icoFoam
to
EXE = $(FOAM_USER_APPBIN)/myIcoFoam
And also change in Make/options:
-I../dieselEngineFoam \
to
-I$(LIB_SRC)/../applications/solvers/combustion/dieselEngineFoam \
____________________________________________

I did not understand this last step very well, so I wrote this:
Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/applications/solvers/lnInclude \
    -I$(LIB_SRC)/meshTools/applications/solvers/lnInclude

EXE_LIBS = \
    -lfiniteVolume \
    -lmeshTools
The previous "options" was:
Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude

EXE_LIBS = \
    -lfiniteVolume \
    -lmeshTools
Finally, I'm getting the following error:
Code:
[ofuser@default myIcoFoam]$ wmake
Making dependency list for source file myIcoFoam.C
could not open file fvCFD.H for source file myIcoFoam.C due to No such file or directory
could not open file pisoControl.H for source file myIcoFoam.C due to No such file or directory
could not open file createPhi.H for source file myIcoFoam.C due to No such file or directory
could not open file initContinuityErrs.H for source file myIcoFoam.C due to No such file or directory
could not open file CourantNo.H for source file myIcoFoam.C due to No such file or directory
could not open file continuityErrs.H for source file myIcoFoam.C due to No such file or directory
g++ -std=c++11 -m64 -DOPENFOAM_PLUS=1612 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3  -DNoRepository -ftemplate-depth-100 -I/opt/OpenFOAM/OpenFOAM-v1612+/src/finiteVolume/applications/solvers/lnInclude -I/opt/OpenFOAM/OpenFOAM-v1612+/src/meshTools/applications/solvers/lnInclude -IlnInclude -I. -I/opt/OpenFOAM/OpenFOAM-v1612+/src/OpenFOAM/lnInclude -I/opt/OpenFOAM/OpenFOAM-v1612+/src/OSspecific/POSIX/lnInclude   -fPIC -c myIcoFoam.C -o Make/linux64GccDPInt32Opt/myIcoFoam.o
myIcoFoam.C:63:19: fatal error: fvCFD.H: No such file or directory
 #include "fvCFD.H"
Can anybody help me? I'm using OpenFOAM for Windows, so I'm fiding it a little bit difficult to modify these things
LThomes is offline   Reply With Quote

Old   June 20, 2017, 10:31
Default
  #2
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 241
Rep Power: 12
floquation will become famous soon enough
Quote:
Originally Posted by LThomes View Post
I did not understand this last step very well, so I wrote this:
That's why it goes wrong there.

Quote:
Originally Posted by LThomes View Post
Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/applications/solvers/lnInclude \
    -I$(LIB_SRC)/meshTools/applications/solvers/lnInclude

EXE_LIBS = \
    -lfiniteVolume \
    -lmeshTools
The previous "options" was:
Code:
EXE_INC = \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude

EXE_LIBS = \
    -lfiniteVolume \
    -lmeshTools
Clearly, the directory I put in bold does not exist, so you are bound to get an error!
The -I option should link to the directory that contains some common OF headers... This should be exactly the same for both icoFoam and my_icoFoam, so it is very simple what you need to do there: don't touch anything.

This replacement:
Code:
-I../dieselEngineFoam \
to
-I$(LIB_SRC)/../applications/solvers/combustion/dieselEngineFoam \
links your copied solver to the original solver, allowing you to use its header files, rather than copying them.
Clearly, this is a nicer thing to do (as you don't have to duplicate unnecessary things), but I recommend you don't do so, as you are not yet comfortable with making those judgment calls.

Quote:
Originally Posted by LThomes View Post
Can anybody help me? I'm using OpenFOAM for Windows, so I'm fiding it a little bit difficult to modify these things
Disclaimer: I don't know about using OpenFOAM on Windows.
Whereas I like Windows for the "normal" things, Linux beats Windows by far when we talk about software development.
LThomes likes this.
floquation is offline   Reply With Quote

Old   June 21, 2017, 09:29
Default
  #3
Member
 
Join Date: May 2017
Posts: 40
Rep Power: 2
LThomes is on a distinguished road
floquation,
Thanks for your prompt reply. But if I don't touch anything in the "options", I have the following error:
Code:
[ofuser@default myIcoFoam]$ wmake
Making dependency list for source file myIcoFoam.C
g++ -std=c++11 -m64 -DOPENFOAM_PLUS=1612 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3  -DNoRepository -ftemplate-depth-100 -I/opt/OpenFOAM/OpenFOAM-v1612+/src/finiteVolume/lnInclude -I/opt/OpenFOAM/OpenFOAM-v1612+/src/meshTools/lnInclude -IlnInclude -I. -I/opt/OpenFOAM/OpenFOAM-v1612+/src/OpenFOAM/lnInclude -I/opt/OpenFOAM/OpenFOAM-v1612+/src/OSspecific/POSIX/lnInclude   -fPIC -c myIcoFoam.C -o Make/linux64GccDPInt32Opt/myIcoFoam.o
g++ -std=c++11 -m64 -DOPENFOAM_PLUS=1612 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3  -DNoRepository -ftemplate-depth-100 -I/opt/OpenFOAM/OpenFOAM-v1612+/src/finiteVolume/lnInclude -I/opt/OpenFOAM/OpenFOAM-v1612+/src/meshTools/lnInclude -IlnInclude -I. -I/opt/OpenFOAM/OpenFOAM-v1612+/src/OpenFOAM/lnInclude -I/opt/OpenFOAM/OpenFOAM-v1612+/src/OSspecific/POSIX/lnInclude   -fPIC -Xlinker --add-needed -Xlinker --no-as-needed Make/linux64GccDPInt32Opt/myIcoFoam.o -L/opt/OpenFOAM/OpenFOAM-v1612+/platforms/linux64GccDPInt32Opt/lib \
            -lfiniteVolume -lmeshTools -lOpenFOAM -ldl  \
             -lm -o /home/ofuser/OpenFOAM/ofuser-v1612+/platforms/linux64GccDPInt32Opt/bin/myIcoFoam
Quote:
Whereas I like Windows for the "normal" things, Linux beats Windows by far when we talk about software development.
It's not my choice to use Windows xD
LThomes is offline   Reply With Quote

Old   June 21, 2017, 10:16
Default
  #4
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 241
Rep Power: 12
floquation will become famous soon enough
That's not an error.

When a compiler is called, it shows you the entire command. That's what the Makefile does.

The three lines you see right there do the following:
  1. It finds the dependencies of myIcoFoam, such that it can compile the dependencies before compiling myIcoFoam. You have no dependencies that need compilation, so it then proceeds with:
  2. It compiles myIcoFoam.C to Make/.../myIcoFoam.o
  3. It links Make/.../myIcoFoam.o, which gives you the executable myIcoFoam in $FOAM_USER_APPBIN
If you'd now type "wmake" again, it will show you "myIcoFoam is up to date", which indicates that everything was successful.
floquation is offline   Reply With Quote

Old   June 22, 2017, 07:04
Default
  #5
Member
 
Join Date: May 2017
Posts: 40
Rep Power: 2
LThomes is on a distinguished road
Thank you so much. I'm so used to getting error messages, that I thought it was another one

Last edited by LThomes; June 23, 2017 at 06:25.
LThomes is offline   Reply With Quote

Old   June 22, 2017, 07:23
Default
  #6
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,254
Rep Power: 23
akidess will become famous soon enough
Did you go through all these hoops just to control the time step? Why not use pimpleFoam?
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
akidess is offline   Reply With Quote

Old   June 23, 2017, 06:24
Default
  #7
Member
 
Join Date: May 2017
Posts: 40
Rep Power: 2
LThomes is on a distinguished road
Quote:
Originally Posted by akidess View Post
Did you go through all these hoops just to control the time step? Why not use pimpleFoam?
I didn't know that the ajustTimeStep would work with pimpleFoam, if it works it's a great idea indeed. Thank you.
LThomes is offline   Reply With Quote

Old   June 23, 2017, 10:24
Default
  #8
Member
 
Join Date: May 2017
Posts: 40
Rep Power: 2
LThomes is on a distinguished road
Hello again,
Now I'm trying to modify the myIcoFoam.C file to enable the ajustTimeStep. This is what I did:
Code:
int main(int argc, char *argv[])
{
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"

    pisoControl piso(mesh);

    #include "createFields.H"
    #include "initContinuityErrs.H"
	

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    Info<< "\nStarting time loop\n" << endl;

    //while (runTime.loop())	// dropped
	while (runTime.run())       // added
    {
		#include "readTimeControls.H"	// added
		#include "setDeltaT.H" // added

        runTime++;            // added
		
        Info<< "Time = " << runTime.timeName() << nl << endl;
		

        #include "CourantNo.H"

        // Momentum predictor

        fvVectorMatrix UEqn
        (
             .
             .
             .
But when I try to compile it, this message appears:
Code:
[ofuser@default myPisoFoam]$ wmake
g++ -std=c++11 -m64 -DOPENFOAM_PLUS=1612 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3  -DNoRepository -ftemplate-depth-100 -I/opt/OpenFOAM/OpenFOAM-v1612+/src/TurbulenceModels/turbulenceModels/lnInclude -I/opt/OpenFOAM/OpenFOAM-v1612+/src/TurbulenceModels/incompressible/lnInclude -I/opt/OpenFOAM/OpenFOAM-v1612+/src/transportModels -I/opt/OpenFOAM/OpenFOAM-v1612+/src/transportModels/incompressible/singlePhaseTransportModel -I/opt/OpenFOAM/OpenFOAM-v1612+/src/finiteVolume/lnInclude -I/opt/OpenFOAM/OpenFOAM-v1612+/src/meshTools/lnInclude -I/opt/OpenFOAM/OpenFOAM-v1612+/src/sampling/lnInclude -IlnInclude -I[ofuser@default myIcoFoam]$ wmake
Making dependency list for source file myIcoFoam.C
g++ -std=c++11 -m64 -DOPENFOAM_PLUS=1612 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3  -DNoRepository -ftemplate-depth-100 -I/opt/OpenFOAM/OpenFOAM-v1612+/src/finiteVolume/lnInclude -I/opt/OpenFOAM/OpenFOAM-v1612+/src/meshTools/lnInclude -IlnInclude -I. -I/opt/OpenFOAM/OpenFOAM-v1612+/src/OpenFOAM/lnInclude -I/opt/OpenFOAM/OpenFOAM-v1612+/src/OSspecific/POSIX/lnInclude   -fPIC -c myIcoFoam.C -o Make/linux64GccDPInt32Opt/myIcoFoam.o
In file included from myIcoFoam.C:79:0:
/opt/OpenFOAM/OpenFOAM-v1612+/src/finiteVolume/lnInclude/readTimeControls.H: In function ‘int main(int, char**)’:
/opt/OpenFOAM/OpenFOAM-v1612+/src/finiteVolume/lnInclude/readTimeControls.H:32:1: error: ‘adjustTimeStep’ was not declared in this scope
 adjustTimeStep =
 ^
/opt/OpenFOAM/OpenFOAM-v1612+/src/finiteVolume/lnInclude/readTimeControls.H:35:1: error: ‘maxCo’ was not declared in this scope
 maxCo =
 ^
/opt/OpenFOAM/OpenFOAM-v1612+/src/finiteVolume/lnInclude/readTimeControls.H:38:1: error: ‘maxDeltaT’ was not declared in this scope
 maxDeltaT =
 ^
In file included from myIcoFoam.C:90:0:
/opt/OpenFOAM/OpenFOAM-v1612+/src/finiteVolume/lnInclude/setDeltaT.H:36:35: error: ‘CoNum’ was not declared in this scope
     scalar maxDeltaTFact = maxCo/(CoNum + SMALL);
                                   ^
make: *** [Make/linux64GccDPInt32Opt/myIcoFoam.o] Error 1
The readTimeControls.H has the following lines:
Code:
adjustTimeStep =
    runTime.controlDict().lookupOrDefault("adjustTimeStep", false);

maxCo =
    runTime.controlDict().lookupOrDefault<scalar>("maxCo", 1.0);

maxDeltaT =
    runTime.controlDict().lookupOrDefault<scalar>("maxDeltaT", GREAT);
Could anybody help me fix this error?
LThomes is offline   Reply With Quote

Old   June 23, 2017, 10:29
Default
  #9
Senior Member
 
floquation's Avatar
 
Kevin van As
Join Date: Sep 2014
Location: TU Delft, The Netherlands
Posts: 241
Rep Power: 12
floquation will become famous soon enough
You are missing
Code:
    #include "createTimeControls.H"
next to createTime.H etc.

You can easily figure that out by opening a solver that supports this, like pimpleFoam or interFoam.
floquation is offline   Reply With Quote

Old   June 26, 2017, 08:44
Default
  #10
Member
 
Join Date: May 2017
Posts: 40
Rep Power: 2
LThomes is on a distinguished road
Quote:
You can easily figure that out by opening a solver that supports this, like pimpleFoam or interFoam.
I actually did that, I can't believe I missed that line, I'm sorry >.< . Thank you very much for your patience.
LThomes is offline   Reply With Quote

Reply

Tags
compile, error, openfoam, solver, windows

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
ATTN ALL: SOLUTON TO UDF COMPILE PROBLEM Rizwan Fluent UDF and Scheme Programming 39 June 29, 2017 19:04
How to compile OpenFOAM-1.7.x on CrunchBang linux 10 gwierink OpenFOAM Installation 0 April 5, 2011 04:38
PV3FoamReader compile error.... PEM_GUY OpenFOAM Installation 6 April 5, 2010 17:22
Error compile file udf czfluent Fluent UDF and Scheme Programming 24 September 26, 2009 13:24
Can someone PLEASE document the development version installation bernd OpenFOAM Installation 76 November 14, 2008 22:51


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