473,387 Members | 3,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

linking error when compiling CVOde in cygwin

have functions in my cell model calling CVODE for each time step.

When I build the application I get a number of link errors:

\cardiacsimulator.o Release\ccardiaccell.o Release\ccelldata.o
Release\cgapjunction.o Release\cheart2d.o Release\integrator.o -o
D:\kp\programs\cardiacsimulator\Release\cardiacsim ulator.exe
Release\integrator.o: In function `func_f':
/cygdrive/d/kp/programs/cardiacsimulator/integrator.cpp:70: multiple
definition of `_func_f'
Release\cardiacsimulator.o:/cygdrive/d/kp/programs/cardiacsimulator/integrator.cpp:70:
first defined here

What am I doing wrong? I am definitely not redefining any of the
functions!

This is the integrator file
)************************************************* **************************88
#include "CDFNCell.h"

/* ----------------------------------------------------

code to call CVode
starts here

----------------------------------------------------
*/

#include <sundialstypes.h /* definitions of types realtype and
*/
/* integertype, and the constant FALSE
*/
#include <cvode.h /* prototypes for CVodeMalloc, CVode, and
*/
/* CVodeFree, constants OPT_SIZE, BDF,
NEWTON, */
/* SV, SUCCESS, NST,NFE,NSETUPS, NNI,
NCFN, NETF */
#include <cvdense.h /* prototype for CVDense, constant
DENSE_NJE */
#include <nvector_serial.h /* definitions of type N_Vector and macro
*/
/* NV_Ith_S, prototypes for N_VNew,
N_VFree */
#include <dense.h /* definitions of type DenseMat, macro
DENSE_ELEM*/

/*
CVode specific functions

CVode is a stiff/non-stiff integrator written in C (not in
C++)
To work this code needs header files and a cvode library

*/
extern "C" {

static N_Vector cvode_y;
static void *cvode_mem;
static realtype reltol,abstol;
static N_Vector ew;
static double cvode_t;
M_Env MachEnv;

static realtype ropt[OPT_SIZE];
static long int iopt[OPT_SIZE];

}

// Call CVode
void CDFNCell::CVode_run(double h,double states[])
{
int flag=0,i;

// call CVode to solve ydot(t)=f(y,t) with y(0) given
flag = CVode(cvode_mem, start_time+h, cvode_y, &cvode_t,
NORMAL);

if (flag != SUCCESS) {
cerr<<"CVode failed, flag="<<flag<<"."<<endl;
}

// copy vector y to states which is returned to compute
for(i=0;i<statesize;i++)
states[i]=NV_Ith_S(cvode_y,i);

states[0]=y0[0];

}

// Extra function that acts as a front to CVode
extern "C" void func_f(long N, realtype time, N_Vector y, N_Vector
ydot, void *f_data)
{
cellptr->CVode_f(N, time, y, ydot, f_data);

}

// function f(t,y) for CVode, returns derivatives of variables to CVode
void CDFNCell::CVode_f(int N, double time, N_Vector y, N_Vector ydot,
void *f_data)
{
int z;
static double states2[MAXSTATES];
bool flag=true;

// copy vector y to states2
for(z=0;z<N;z++)
states2[z]=NV_Ith_S(y,z);

// send states2 to getF which uses it to produce derivatives
calDiff(time,states2,flag);

// copy derivatives to vector ydot which is returned to CVode
for(z=0;z<N;z++) {
NV_Ith_S(ydot,z)=Diff[z];
}

}

// Initializes CVode
void CDFNCell::CVodeInit(double states[],double timenow)
{
int i;

MachEnv = M_EnvInit_Serial((int)statesize);
if (MachEnv == NULL) {
cerr<<"Trouble with MachEnv in CVODE"<<endl;
exit(-3);
}

// Allocate memory for solution vector y(t)
cvode_y = N_VNew((int)statesize, MachEnv);
// Allocate memory for solution vector ew(t)
ew = N_VNew((int)statesize, MachEnv);

// rel tolerance of 10^-5 might be a good idea
reltol = tolerance_relative;
abstol = tolerance_absolute;

// initialize vector cvode_y with states
for(i=0;i<statesize;i++)
NV_Ith_S(cvode_y,i)=states[i];

// use default values for options
for(i=0;i<OPT_SIZE;i++) {
ropt[i]=0.0;
iopt[i]=0;
}
// except for these
ropt[HMAX]=step_max; // Largest step size
ropt[HMIN]=step_min; // Smallest step size
iopt[MXSTEP]=100000; // max internal step number for cvode

// scale tolerance based on maximum value of state
for(i=0;i<statesize;i++) {
NV_Ith_S(ew,i)=abstol/errweight[i];
}

/* CVodeMalloc sets up initial settings for CVode. See
CVODE
documentation.
Integration method is BDF(Backward Differential
Formula)
Other choice would be ADAMS but it is not as stable as
BDF */
#if 0
// This method of calling CVODE does not pass error
weights
cvode_mem = CVodeMalloc(statesize, func_f, timenow, cvode_y,
BDF,
NEWTON, SS, &reltol, &abstol,
NULL, NULL, TRUE, iopt, ropt, MachEnv);

//#else
// We wish to pass errorweight to CVODE
//cvode_mem = CVodeMalloc(statesize, func_f, timenow, cvode_y,
BDF,
NEWTON,
// SV, &reltol,
ew, NULL, NULL, TRUE, iopt, ropt, MachEnv);
#endif

if (cvode_mem == NULL) {
cerr<<"CVodeMalloc failed."<<endl;
exit(1);
}

/* CVDense is needed by Newton algorithm for solving linear
system
The second NULL tells the solver to compute an approximation
of the
Jacobian. */
CVDense(cvode_mem, NULL, NULL);

}

void CDFNCell::CVodeExit(void)
{
N_VFree(cvode_y);
CVodeFree(cvode_mem);
M_EnvFree_Serial(MachEnv);

}

************************************************** *********************
THis is the class definition:

#define CDFNCELL_H
#include <math.h>
#include <iostream>
#include "ccardiaccell.h"
#include <cvode.h /* prototypes for CVodeMalloc, CVode, and
CVodeFree, */
/* constants OPT_SIZE, BDF, NEWTON, SV, SUCCESS,
*/
/* NST, NFE, NSETUPS, NNI, NCFN, NETF
*/
#include <cvdense.h /* prototype for CVDense, constant DENSE_NJE
*/
#include <nvector.h /* definitions of type N_Vector and macro N_VIth,
*/
#include <nvector_serial.h /* definitions of type N_Vector and macro
N_VIth, */
/* prototypes for N_VNew, N_VFree
*/
#include <dense.h /* definitions of type DenseMat, macro DENSE_ELEM
*/
#include <vector>

using namespace std;
const int MAXSTATES = 16;

//Noble Cell Constants
class CDFNCell : public CCardiacCell {
private:
//double iteration;
double I_DFN;
//Membranne Potential
double Vm;
//stim current
double IStim;

void copy(const CDFNCell &);

void setDifferential();
void setState();

public:
CDFNCell();
~CDFNCell();
void initialize();
void simulate(double Iext);
void calDiff(double,double[],bool);
void returnParameterList(vector<string>&);
void returnParamaterValues(const vector<string>&
requestedParameters, vector<double>&);
inline double returnVolt(){return (Vm);};
inline double returnNa_i(){return (Na_i);};
inline double returnCa_i(){return (Ca_i);}; //repeat
function for m n
h
inline double returnK_i(){return (K_i);};
inline double returnK_o(){return (K_c);};

//CVOde functions
void CVode_f(int N, double time, N_Vector y, N_Vector ydot,
void
*f_data);
void CVodeInit(double[],double);
void CVodeExit(void);
void CVode_run(double h,double states[]);

int statesize;
bool success;
double start_time;
bool notdone;
double tr_error,errtmp;
double errweight[15];
double tolerance_relative,tolerance_absolute; // tolerances for
integrators
double tstep;
double step_min,step_max; // minimum and maximum step sizes for
integrators

//constants

int stateFlag; // Is state.txt written out
int currentFlag; // Is current.txt written out
int statederivsFlag; // Is Deriv.txt written out
int stimulusFlag; // Is stimulus used or not
double y0[15];
double States[MAXSTATES];
double Diff[MAXSTATES];

};

extern CDFNCell *cellptr;

#endif

Oct 4 '06 #1
0 1887

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Joonas Paalasmaa | last post by:
Hi, When compiling Sketch's streamfilter C extension the errors below are raised during linking. What could cause the errors? (Python 2.3, MinGw 1.1 with GCC 2.95.3-6, Windows 98) Here are...
0
by: Francisco J. Reyes | last post by:
I get an Internal complier error when compiling C# windows project that uses a custom Class add as reference to the project. The problem appears to be related to the ENUM type used in the class...
22
by: TuPLaD | last post by:
Hello, I just made a little C++ console application: #include "iostream" using namespace std; int main () { cout << "Hello Mars !"; return 0;
6
by: mihailsmilev | last post by:
Hello, let me first describe the situation: I am developing an application using Qt Designer 3.3.5 on OpenSuSE Linux for my mp3 player. So I need to get the id3 tags from the mp3 files, and I've...
2
by: etienne | last post by:
Hello, I'm trying to compile this C++ code with gcc 3.4.5 under Solaris/SPARC (from a complete application, the file is : FullLinkedList.hh) but the make fails (no problem when compiling under...
6
by: tony | last post by:
Hello! I have several projects where each one build a library.(class library or window control library). Now I get some strange compile error when building the *.exe file and doesn't...
3
by: B. | last post by:
We converted VC++ 6.0 to VS 2005 and tried to compile with /clr, however, we got few linking errors: MSVCMRTD.lib(mstartup.obj) : error LNK2022: metadata operation failed (8013118D) : Inconsistent...
16
by: Micko1 | last post by:
Hello there :) I have been using Visual Studio on a program which I have just completed, however I need to have it compiling using a unix based compiler, when I try in cygwin, I get the following...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.