CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Problem while compiling modified simpleFoam solver

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

LinkBack Thread Tools Search this Thread Display Modes
Old   May 26, 2020, 20:01
Default Problem while compiling modified simpleFoam solver
New Member
Mattia Fabrizio Ciarlatani
Join Date: May 2020
Posts: 7
Rep Power: 6
mattiafc is on a distinguished road
Hi everyone,

I'm writing here because I'm having trouble to compile a modified version of simpleFoam pointing to a new turbulenceClass.

Since I need to add new members to the original openfoam turbulenceModel class, I implemented a new turbulenceModel class in OpenFOAM named turbulenceModelDSDL.
To do this, I copied the entire folder OpenFOAM-v1906/src/TurbulenceModels/incompressible and OpenFOAM-v1906/src/TurbulenceModels/turbulenceModels to my personal directory $WM_PROJECT_USER_DIR/src/turbulenceModels. After doing this, I renamed in every file every instance of turbulenceModel turbulenceModelDSDL, renamed turbolenceModel.* themselves, added the new members, and modified the incompressible/Make/* and turbulenceModels/Make/* as



/* Wall Functions */
wallFunctions = derivedFvPatchFields/wallFunctions

nutWallFunctions = $(wallFunctions)/nutWallFunctions

epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions

LIB = $(FOAM_USER_LIBBIN)/libDSDLTurbulenceModels

    -I$(LIB_SRC)/finiteVolume/lnInclude \

    -lfiniteVolume \


LIB = $(FOAM_USER_LIBBIN)/libDSDLincompressibleTurbulenceModels

    -I../turbulenceModels/lnInclude \
    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -lfiniteVolume \
    -lmeshTools \
-L$(FOAM_USER_LIBBIN) is needed in order to include the class turbulenceModelDSDL which is defined in $(FOAM_USER_LIBBIN)/libDSDLTurbulenceModels.

I also changed the name of the library turbulentTransportModel.H to turbulentTransportModelDSDL.H.
Once I did this, I compiled turbulenceModelDSDL.C, a number of wall functions belonging to this new class, incompressibleTurbulenceModel.C, and turbulenceTransportModelsDSDL.H, which contained a new turbulence model called RNGkEpsilonDSDL.
Up to this point, everything worked just fine: the compilation was successfull and OpenFOAM is able to see the new turbulence model, RNGkEpsilonDSDL, and the new wall functions.

Since I now need to use the RNGkEpsilonDSDL model with simpleFoam, and this model belongs to the class turbulenceModelDSDL, I need to modify the simpleFoam solver to correctly generate the pointer to the new turbulenceModelDSDL class.
To do this, I copied the simpleFoam folder, renamed it to DSDLsimpleFoam, included the new header turbulenceTransportModelDSDL.H in DSDLsimpleFoam.C


#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "turbulentTransportModelDSDL.H"
#include "simpleControl.H"
#include "fvOptions.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
I also modified the call to the turbulence model to
autoPtr<incompressible::turbulenceModelDSDL> turbulence
    incompressible::turbulenceModelDSDL::New(U, phi, laminarTransport)
Once i did this I modified DSDLsimpleFoam/Make/* to read the libraries in which turbulenceTransportModelsDSDL.H and turbulenceModelDSDL are defined




    -I$(LIB_SRC)/finiteVolume/lnInclude \
    -I$(LIB_SRC)/meshTools/lnInclude \
    -I$(LIB_SRC)/sampling/lnInclude \
    -I$$WM_PROJECT_USER_DIR/src/TurbulenceModels/incompressible/lnInclude \
    -I$$WM_PROJECT_USER_DIR/src/TurbulenceModels/turbulenceModels/lnInclude \
    -I$(LIB_SRC)/transportModels \

    -lfiniteVolume \
    -lfvOptions \
    -lmeshTools \
    -lsampling \
    -lincompressibleTransportModels \
-L$(FOAM_USER_LIBBIN) replaced () and includes the class turbulenceModelDSDL and which is defined in $(FOAM_USER_LIBBIN)/libDSDLincompressibleTurbulenceModels.

When I try to compile DSDLsimpleFoam I get the following error:

Making dependency list for source file DSDLsimpleFoam.C
g++ -std=c++11 -m64 -DOPENFOAM=1906 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -Wno-unknown-pragmas -O3  -DNoRepository -ftemplate-depth-100 -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/finiteVolume/lnInclude -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/meshTools/lnInclude -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/sampling/lnInclude -I$WM_PROJECT_USER_DIR/src/TurbulenceModels/incompressible/lnInclude -I$WM_PROJECT_USER_DIR/src/TurbulenceModels/turbulenceModels/lnInclude -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/transportModels -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/transportModels/incompressible/singlePhaseTransportModel -IlnInclude -I. -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/OpenFOAM/lnInclude -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/OSspecific/POSIX/lnInclude   -fPIC -c DSDLsimpleFoam.C -o Make/linux64GccDPInt32Opt/DSDLsimpleFoam.o
g++ -std=c++11 -m64 -DOPENFOAM=1906 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -Wno-unknown-pragmas -O3  -DNoRepository -ftemplate-depth-100 -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/finiteVolume/lnInclude -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/meshTools/lnInclude -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/sampling/lnInclude -I$WM_PROJECT_USER_DIR/src/TurbulenceModels/incompressible/lnInclude -I$WM_PROJECT_USER_DIR/src/TurbulenceModels/turbulenceModels/lnInclude -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/transportModels -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/transportModels/incompressible/singlePhaseTransportModel -IlnInclude -I. -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/OpenFOAM/lnInclude -I/home/mattia/OpenFOAM/OpenFOAM-v1906/src/OSspecific/POSIX/lnInclude   -fPIC -Xlinker --add-needed -Xlinker --no-as-needed Make/linux64GccDPInt32Opt/DSDLsimpleFoam.o -L/home/mattia/OpenFOAM/OpenFOAM-v1906/platforms/linux64GccDPInt32Opt/lib \
    -lfiniteVolume -lfvOptions -lmeshTools -lsampling -L/home/mattia/OpenFOAM/mattia-v1906/platforms/linux64GccDPInt32Opt/lib -lincompressibleTransportModels -latmosphericModels  -lOpenFOAM -ldl  \
     -lm -o /home/mattia/OpenFOAM/mattia-v1906/platforms/linux64GccDPInt32Opt/bin/DSDLsimpleFoam
Make/linux64GccDPInt32Opt/DSDLsimpleFoam.o: In function `main':
DSDLsimpleFoam.C:(.text.startup+0x1733): undefined reference to `Foam::turbulenceModelDSDL::propertiesName'
DSDLsimpleFoam.C:(.text.startup+0x403a): undefined reference to `Foam::turbulenceModelDSDL::propertiesName'
collect2: error: ld returned 1 exit status
/home/mattia/OpenFOAM/OpenFOAM-v1906/wmake/makefiles/general:140: recipe for target '/home/mattia/OpenFOAM/mattia-v1906/platforms/linux64GccDPInt32Opt/bin/DSDLsimpleFoam' failed
make: *** [/home/mattia/OpenFOAM/mattia-v1906/platforms/linux64GccDPInt32Opt/bin/DSDLsimpleFoam] Error 1
To try and ovrecome the problem I tried to repeat the process from the beginning and I still get the same error.

I included here DSDLsimpleFoam in case you want to take a look at it

Any help will be appreciated.

Thanks for your time,

P.S.: is the first time i write a post here so please tell me if there are mistakes on this thread


Hey guys, I have an update:

I was able to compile the solver by modifying the pointer definition to

autoPtr<incompressible::turbulenceModelDSDL> turbulence
    incompressible::turbulenceModelDSDL::New(U, phi, laminarTransport, "someRandomWord")

which means that the undefined reference was just asking to input some string as turbulenceProperties.

My question now is: why do I need to input something there while the normal simpleFoam does not require anything? In other words: what would happen if I defined the pointer in simpleFoam as

autoPtr<incompressible::turbulenceModel> turbulence
    incompressible::turbulenceModel::New(U, phi, laminarTransport, "someRandomWord")
Attached Files
File Type: gz DSDLsimpleFoam.tar.gz (6.1 KB, 5 views)

Last edited by mattiafc; May 27, 2020 at 13:20.
mattiafc is offline   Reply With Quote


compilation error, inheritance, linking, simplefoam, turbulencemodels

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[General] Extracting ParaView Data into Python Arrays Jeffzda ParaView 30 November 6, 2023 21:00
Problem in compiling a solver made for a different version (v2.0 ->v4.1) JLS OpenFOAM Programming & Development 2 July 9, 2019 14:03
diffusivity selection for modified displacementLaplacian solver for FSI problems zhaozhenkai OpenFOAM Running, Solving & CFD 2 November 11, 2016 05:41
Error in compiling a modified solver immortality OpenFOAM Running, Solving & CFD 3 March 29, 2013 00:29
Divergence problem Smaras FLUENT 13 February 21, 2013 05:03

All times are GMT -4. The time now is 12:05.