CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM (
-   -   Problem implementing CVODE ODE solver (

markusrehm August 9, 2007 11:53

Hello, I am trying to imple

I am trying to implement the CVODE stiff ode solver of the Sundials package to solve the chemistry with the reactingFoam solver.

I modified the EulerImplicit-files and put in the CVODE-stuff. Now that I'm almost ready I have a problem executing reactingFoam. Compilation of the works fine but the solver gives me an error when I want to execute it:

reactingFoam: symbol lookup error: /home/rem/OpenFOAM/OpenFOAM-1.4_devel/lib/linux64Gcc4DPDebug/libchemistryModel.s o: undefined symbol: _ZN4Foam5CVODE1fEdP17_generic_N_VectorS2_Pv

There must be something missing in the wmake rules which I don't understand very well. By the way: N_Vector is a data type used by CVODE.

I am using 64bit architecture and gcc4 (standard of OF 1.4).

Hoping for help, regards Markus.

gschaider August 13, 2007 06:04

Hi Markus! Can't help you o
Hi Markus!

Can't help you on your concrete problem. But you can use the c++filt-command to find out which C++-symbol is actually missing. Your symbol (_ZN4Foam5CVODE1fEdP17_generic_N_VectorS2_Pv) is for instance translated to Foam::CVODE::f(double, _generic_N_Vector*, _generic_N_Vector*, void*) (don't know if that helps)


markusrehm August 14, 2007 10:10

Thank you Bernhard, it help
Thank you Bernhard,

it helped me a bit to dig deeper into the problem. But anyway I need to ask again:
The thing is that I am able to compile the but when I want to compile the solver (reactingFoam) i get:

g++ -m64 -Dlinux64 -DDP -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O0 -fdefault-inline -ggdb3 -DFULLDEBUG -DNoRepository -ftemplate-depth-40 -I../XiFoam -I/home/rem/OpenFOAM/OpenFOAM-1.4_devel/src/finiteVolume/lnInclude -I/home/rem/OpenFOAM/OpenFOAM-1.4_devel/src/turbulenceModels -I/home/rem/OpenFOAM/OpenFOAM-1.4_devel/src/thermophysicalModels/specie/lnInclud e -I/home/rem/OpenFOAM/OpenFOAM-1.4_devel/src/thermophysicalModels/combustion/lnIn clude -I/home/rem/OpenFOAM/OpenFOAM-1.4_devel/src/thermophysicalModels/basic/lnInclude -I/home/rem/OpenFOAM/OpenFOAM-1.4_devel/src/thermophysicalModels/chemistryModel/ lnInclude -I/home/rem/OpenFOAM/OpenFOAM-1.4_devel/src/ODE/lnInclude -IlnInclude -I. -I/home/rem/OpenFOAM/OpenFOAM-1.4_devel/src/OpenFOAM/lnInclude -fPIC Make/linux64Gcc4DPDebug/reactingFoam.o -L/home/rem/OpenFOAM/OpenFOAM-1.4_devel/lib/linux64Gcc4DPDebug \
-lcompressibleTurbulenceModels -lcombustionThermophysicalModels -lfiniteVolume -lspecie -lbasicThermophysicalModels -lchemistryModel -lODE -lOpenFOAM -liberty -ldl -ggdb3 -DFULLDEBUG -lm -o /home/rem/OpenFOAM/OpenFOAM-1.4_devel/applications/bin/linux64Gcc4DPDebug/reacti ngFoam
/home/rem/OpenFOAM/OpenFOAM-1.4_devel/lib/linux64Gcc4DPDebug/libchemistryModel.s o: undefined reference to `CVDense'
/home/rem/OpenFOAM/OpenFOAM-1.4_devel/lib/linux64Gcc4DPDebug/libchemistryModel.s o: undefined reference to `CVodeSetMaxNumSteps'
/home/rem/OpenFOAM/OpenFOAM-1.4_devel/lib/linux64Gcc4DPDebug/libchemistryModel.s o: undefined reference to `CVodeMalloc'
/home/rem/OpenFOAM/OpenFOAM-1.4_devel/lib/linux64Gcc4DPDebug/libchemistryModel.s o: undefined reference to `CVode'
/home/rem/OpenFOAM/OpenFOAM-1.4_devel/lib/linux64Gcc4DPDebug/libchemistryModel.s o: undefined reference to `Foam::CVODE::f1(double, _generic_N_Vector*, _generic_N_Vector*, void*)'
/home/rem/OpenFOAM/OpenFOAM-1.4_devel/lib/linux64Gcc4DPDebug/libchemistryModel.s o: undefined reference to `CVDenseSetJacFn'
/home/rem/OpenFOAM/OpenFOAM-1.4_devel/lib/linux64Gcc4DPDebug/libchemistryModel.s o: undefined reference to `N_VNew_Serial'
/home/rem/OpenFOAM/OpenFOAM-1.4_devel/lib/linux64Gcc4DPDebug/libchemistryModel.s o: undefined reference to `CVodeFree'
/home/rem/OpenFOAM/OpenFOAM-1.4_devel/lib/linux64Gcc4DPDebug/libchemistryModel.s o: undefined reference to `CVodeCreate'
/home/rem/OpenFOAM/OpenFOAM-1.4_devel/lib/linux64Gcc4DPDebug/libchemistryModel.s o: undefined reference to `CVodeSetFdata'
/home/rem/OpenFOAM/OpenFOAM-1.4_devel/lib/linux64Gcc4DPDebug/libchemistryModel.s o: undefined reference to `N_VDestroy_Serial'
collect2: ld gab 1 als Ende-Status zurück
make: *** [/home/rem/OpenFOAM/OpenFOAM-1.4_devel/applications/bin/linux64Gcc4DPDebug/react ingFoam] Fehler 1

So the header files of the CVODE are found since chemistryModel can be compiled. CVODE is C-Code and there were more undefined references before I fixed warnings resulting from old-style casts.

I keep on digging. But help is appreciated anyway.

Have a nice day Markus.

gschaider August 15, 2007 12:40

Hi Marcus! Don't shoot me:
Hi Marcus!

Don't shoot me: this is a bit vague:
I assume that you added the files to Make/files. There may be an issue that your CV***-symbols are not found because in the *.o the C-compiler prepended an underscore to them (making them _CV***). Best way to check for that is to have a look with "objdump -t" at the *.o-file that is supposed to define them

(this may be totally wrong. I just remember having such a problem when mixing C/C++/Fortran)

david_h August 21, 2007 09:23

Marcus, I noticed that your

I noticed that your compilation line did not include the CVODE/Sundials libraries or paths.
Have you tried including these ?


stephan August 21, 2007 10:17

hi markus, i am pretty inte
hi markus,

i am pretty interested in your solver implementation so it would be very nice if you could share the source.

markusrehm August 21, 2007 10:55

Hello everyone, thanks for
Hello everyone,

thanks for helping and encouraging! Dave you are right, I included the libraries. It is still not running well and I am still thinking why.

I had a look at Cantera and for CVODE they use virtual C++ wrapper functions for all CVODE-functions. Is that necessary? - Maybe anyone knows.
I will keep you up to date about that thing (mostly posting problems, I'm afraid). But when it works I can share it.

Have a nice day. Markus

markusrehm August 24, 2007 05:10

Hello everyone, it works an
Hello everyone,

it works and it seems to be very stable.

I want to play around a bit more, make it more readible and check results before I post it.

Thanks to you. Markus

markusrehm January 4, 2008 08:57

Hello, I have worked with t

I have worked with that solver some time now and for my test-cases it gives the same results as EulerImplicit or the other solvers. The warnings I didn't get rid of up to now but in CVODE.C:198 there is an instruction missing:


Any further improvements and comments are welcome.

Regards Markus.

torvic April 7, 2008 21:05

Hi Markus ! I tried your CV
Hi Markus !

I tried your CVODE_solver and followed the instructions in the .txt file.It compiles, but when executing reactingFoam, i get many errors.

I installed again SUNDIALS, but noticed in the configure step this line:

checking dynamic linker characteristics... cat: /etc/*.conf: No such file or directory


and when executing reactingFoam i get (just a part of the message)

Solving chemistry
*** glibc detected *** reactingFoam: free(): invalid pointer: 0x0824ac00 ***
======= Backtrace: =========
/home/foam/OpenFOAM/OpenFOAM-1.4/lib/linuxGcc4DPOpt/ am14chemistryModel11derivativesEdRKNS_5FieldIdEERS 2_+0x6f)[0xb724e88f]
/home/foam/OpenFOAM/OpenFOAM-1.4/lib/linuxGcc4DPOpt/ m5CVODE2f2EdP17_generic_N_VectorS2_+0xb8)[0xb726a078]
/home/foam/OpenFOAM/OpenFOAM-1.4/lib/linuxGcc4DPOpt/ m5CVODE2f1EdP17_generic_N_VectorS2_Pv+0x26)[0xb7269df6]
/home/foam/OpenFOAM/OpenFOAM-1.4/lib/linuxGcc4DPOpt/ am5CVODE5solveERNS_5FieldIdEEdddd+0x275)[0xb726a955]
/home/foam/OpenFOAM/OpenFOAM-1.4/lib/linuxGcc4DPOpt/ m14chemistryModel5solveEdd+0x9fb)[0xb725049b]
reactingFoam(_ZN4Foam11regIOobject14readIfModified Ev+0x201)[0x8059741]
======= Memory map: ========
08048000-080dc000 r-xp 00000000 03:06 3434128 /home/foam/OpenFOAM/OpenFOAM-1.4/applications/bin/linuxGcc4DPOpt/reactingFoam
080dc000-080de000 r--p 00093000 03:06 3434128 /home/foam/OpenFOAM/OpenFOAM-1.4/applications/bin/linuxGcc4DPOpt/reactingFoam
080de000-080df000 rw-p 00095000 03:06 3434128 /home/foam/OpenFOAM/OpenFOAM-1.4/applications/bin/linuxGcc4DPOpt/reactingFoam
080df000-085f5000 rw-p 080df000 00:00 0 [heap]
b6300000-b6321000 rw-p b6300000 00:00 0

what do you suggest ?, i'm on opensuse 10.2 in OF 1.4

thanks in advance



markusrehm April 9, 2008 02:47

Hi Victor, I had similar er
Hi Victor,

I had similar errors and then I had something mixed up with the sundials libaries. So check options and files in the make-directory.

Actually better than what I explained in the text would be to introduce an environment variable $SUNDIALS_PATH and configure SUNDIALS with that like

./configure --enable-shared --prefix=$SUNDIALS_PATH

My options options-file looks like that:

-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/combustion/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/ODE/lnInclude \

-lbasicThermophysicalModels \
-lcombustionThermophysicalModels \
-lthermophysicalFunctions \
-lspecie \

Another error I recently found is this one:

Just replace the lines in the function f2 in CVODE.C before the first for-command (lines 220-223) by

int NEQ= chemistry_.Ns()+2;

Foam::scalarField ctemp(NEQ, 0.0);
Foam::scalarField dcdt(NEQ, 0.0);

Regards Markus.

torvic April 10, 2008 12:11

Hi Markus thanks for your
Hi Markus

thanks for your help and time.

I followed your suggestions and now it works ... thanks. One thing that I
didn't notice yesterday was a typing error in the options file.

the warnings i get in chemistryModel are these:

chemistrySolver/CVODE/CVODE.C: In member function 'virtual Foam::scalar
Foam::CVODE::solve(Foam::scalarField&, Foam::scalar, Foam::scalar,
Foam::scalar, Foam::scalar) const':
chemistrySolver/CVODE/CVODE.C:119: warning: use of old-style cast
chemistrySolver/CVODE/CVODE.C:120: warning: use of old-style cast
chemistrySolver/CVODE/CVODE.C:124: warning: use of old-style cast
chemistrySolver/CVODE/CVODE.C:125: warning: use of old-style cast
chemistrySolver/CVODE/CVODE.C:126: warning: use of old-style cast
chemistrySolver/CVODE/CVODE.C:127: warning: use of old-style cast
chemistrySolver/CVODE/CVODE.C:193: warning: use of old-style cast
chemistrySolver/CVODE/CVODE.C: In member function 'virtual void
Foam::CVODE::f2(realtype, _generic_N_Vector*, _generic_N_Vector*)':
chemistrySolver/CVODE/CVODE.C:223: warning: use of old-style cast
chemistrySolver/CVODE/CVODE.C:230: warning: use of old-style cast
chemistrySolver/CVODE/CVODE.C: In member function 'virtual void
Foam::CVODE::Jac2(long int, _DenseMat*, realtype, _generic_N_Vector*,
chemistrySolver/CVODE/CVODE.C:253: warning: use of old-style cast
chemistrySolver/CVODE/CVODE.C:258: warning: use of old-style cast


I'm really interested in CVODE since with FOAM's ODE SIBS, i get "step
size underflow" messages with the large heptane mechanism that comes with
FOAM (56 species, 290 reactions).. and my simulations stops.

thanks again



kalle August 9, 2009 09:13

Marcus, I've been searching for your CVODE-solver, but without success. Is it available for testing?


newToReactions August 26, 2009 16:20

Newbie questions
I am new to combustion. I need to model species transport with laminar finite rate. Can you suggest a good place to start reading the fundamentals (real basics)? When do I need CVODE solver?

Thanks in advance.


PS: Markus, I sent a PM to you earlier.

markusrehm September 6, 2009 23:42


you can try to run some demos in Cantera:

It uses CVODE and you don't have to care about it a lot.

To use it with OF have a look here

Theoretical basics you can learn from

title={{Theoretical and numerical combustion}},
author={Poinsot, T. and Veynante, D.},
publisher={RT Edwards, Inc.}

Regards, Markus

Aleksey_R April 5, 2010 11:12

Hello, colleagues!
I try to use CVODE in my OF program to solve ODE instead of standard OF solvers.
I managed to compile source code but when I start numerical simulation I get at first try to use CVODE solver the following:

#0 Foam::error::printStack(Foam::Ostream&) in "/home/Aleksey/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/"
#1 Foam::sigFpe::sigFpeHandler(int) in "/home/Aleksey/OpenFOAM/OpenFOAM-1.6/lib/linux64GccDPOpt/"
#2 ?? in "/lib64/"
#3 CVSetTqBDF at ~/OpenFOAM/ThirdParty-1.6/sundials-2.4.0/src/cvode/./cvode.c:2501
#4 CVode at ~/OpenFOAM/ThirdParty-1.6/sundials-2.4.0/src/cvode/./cvode.c:1386
#5 main in "/home/Aleksey/OpenFOAM/Aleksey-1.6/applications/bin/linux64GccDPOpt/coagulationTask"
#6 __libc_start_main in "/lib64/"
#7 _start at /usr/src/packages/BUILD/glibc-2.9/csu/../sysdeps/x86_64/elf/start.S:116
Исключение в операции с плавающей точкой

The last line means: "Floating point exception", sorry for Russian :-)

All CVODE-initialization procedures are successfully passed during program run.
Values that enter the solver are small (~1e-2) because it's only first step.

Please, help me with this problem.
Markus, I've been trying to find your CVODE implementation and I failed.
Please tell me, where can I find it.

Best regards, Aleksey.

arvind_arya April 8, 2010 21:55

cantera installation error
I am trying to install cantera-1.7.0 with sundials-2.3.0.But while executing make generates following error..
Please suggest me the way to solve this problem

n file included from CVodesIntegrator.cpp:9:
CVodesIntegrator.h:31:39: error: sundials/sundials_nvector.h: No such file or directory
CVodesIntegrator.cpp:29:37: error: sundials/sundials_types.h: No such file or directory
CVodesIntegrator.cpp:30:36: error: sundials/sundials_math.h: No such file or directory
CVodesIntegrator.cpp:32:36: error: nvector/nvector_serial.h: No such file or directory
CVodesIntegrator.cpp:33:27: error: cvodes/cvodes.h: No such file or directory
CVodesIntegrator.cpp:34:33: error: cvodes/cvodes_dense.h: No such file or directory
CVodesIntegrator.cpp:35:32: error: cvodes/cvodes_diag.h: No such file or directory
CVodesIntegrator.cpp:36:33: error: cvodes/cvodes_spgmr.h: No such file or directory
CVodesIntegrator.cpp:37:32: error: cvodes/cvodes_band.h: No such file or directory


markusrehm April 9, 2010 04:30

Hi Arvind,

please specify your problem more precisely.

Do you want to install the alternateChemistry library? (described here )

Then the post is a bit off-topic.

Regards, Markus.

arvind_arya April 9, 2010 05:31

Thank you for reply....Yes i want to use alternateReactingfoam. I understood, it requires sundials(CVODE) and cantera after reading your previous postings.I am following your wiki guide instructions.I have installed sundials-2.3.0 in thirdparty.Then i tried to install cantera-1.7...while executing "make" i got earlier mentioned error.I am using OpenFOAM-1.5-dev installed on mandriva-2010.


markusrehm April 9, 2010 05:38


you should use cantera-1.8 from the google-code repository as described in the wiki. I also had some problems with the old version.


All times are GMT -4. The time now is 00:04.