本文整理汇总了C++中N_VDestroy_Serial函数的典型用法代码示例。如果您正苦于以下问题:C++ N_VDestroy_Serial函数的具体用法?C++ N_VDestroy_Serial怎么用?C++ N_VDestroy_Serial使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了N_VDestroy_Serial函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: N_VDestroy_Serial
OpenSMOKE_CVODE_Sundials<T>::~OpenSMOKE_CVODE_Sundials(void)
{
/* Free vectors */
N_VDestroy_Serial(y0Sundials_);
N_VDestroy_Serial(ySundials_);
/* Free integrator memory */
CVodeFree(&cvode_mem_);
SUNLinSolFree(LS);
SUNMatDestroy(A);
delete[] this->y0_;
delete[] this->y_;
}
开发者ID:acuoci,项目名称:laminarSMOKE,代码行数:14,代码来源:OpenSMOKE_CVODE_Sundials.hpp
示例2: CVodeSensFree
CVodesIntegrator::~CVodesIntegrator()
{
if (m_cvode_mem) {
if (m_np > 0) {
CVodeSensFree(m_cvode_mem);
}
CVodeFree(&m_cvode_mem);
}
if (m_y) {
N_VDestroy_Serial(m_y);
}
if (m_abstol) {
N_VDestroy_Serial(m_abstol);
}
}
开发者ID:thomasfiala,项目名称:cantera,代码行数:15,代码来源:CVodesIntegrator.cpp
示例3: N_VNew_Serial
void CVodesIntegrator::sensInit(double t0, FuncEval& func)
{
m_np = func.nparams();
m_sens_ok = false;
N_Vector y = N_VNew_Serial(static_cast<sd_size_t>(func.neq()));
m_yS = N_VCloneVectorArray_Serial(static_cast<sd_size_t>(m_np), y);
for (size_t n = 0; n < m_np; n++) {
N_VConst(0.0, m_yS[n]);
}
N_VDestroy_Serial(y);
int flag = CVodeSensInit(m_cvode_mem, static_cast<sd_size_t>(m_np),
CV_STAGGERED, CVSensRhsFn(0), m_yS);
if (flag != CV_SUCCESS) {
throw CanteraError("CVodesIntegrator::sensInit", "Error in CVodeSensInit");
}
vector_fp atol(m_np);
for (size_t n = 0; n < m_np; n++) {
// This scaling factor is tuned so that reaction and species enthalpy
// sensitivities can be computed simultaneously with the same abstol.
atol[n] = m_abstolsens / func.m_paramScales[n];
}
flag = CVodeSensSStolerances(m_cvode_mem, m_reltolsens, atol.data());
}
开发者ID:Niemeyer-Research-Group,项目名称:cantera,代码行数:26,代码来源:CVodesIntegrator.cpp
示例4: IntegratorInstance_freeIDASpecSolverStructures
/* frees only sensitivity structure, not used at the moment */
static void
IntegratorInstance_freeIDASpecSolverStructures(integratorInstance_t *engine)
{
/* Free sensitivity vector yS */
N_VDestroy_Serial(engine->solver->dy);
engine->solver->dy = NULL;
}
开发者ID:raim,项目名称:SBML_odeSolver,代码行数:8,代码来源:daeSolver.c
示例5: cvode_free
int cvode_free(solver_props *props){
unsigned int modelid;
/* // Debug code
long int count;
for(modelid=0; modelid<mem[0].props->num_models; modelid++){
PRINTF( "Model number: %d\n", modelid);
if (CVodeGetNumSteps(mem->cvmem, &count) == CV_SUCCESS)
PRINTF( " Total Number of steps: %ld\n", count);
if (CVodeGetNumRhsEvals(mem->cvmem, &count) == CV_SUCCESS)
PRINTF( " RHS Evals: %ld\n", count);
if (CVodeGetNumErrTestFails(mem->cvmem, &count) == CV_SUCCESS)
PRINTF( " Num of step errors: %ld\n", count);
}
*/
// Cleanup
cvode_mem *mem = props->mem;
for(modelid = 0; modelid<props->num_models; modelid++){
N_VDestroy_Serial(((N_Vector)(mem[modelid].y0)));
CVodeFree(&(mem[modelid].cvmem));
}
free(mem);
return 0;
}
开发者ID:joshuaecook,项目名称:simengine,代码行数:25,代码来源:cvode.c
示例6: N_VDestroy_Serial
IdaSolver::~IdaSolver()
{
if (!mSolver)
// The solver hasn't been initialised, so...
return;
// Delete some internal objects
N_VDestroy_Serial(mStatesVector);
N_VDestroy_Serial(mRatesVector);
IDAFree(&mSolver);
delete mUserData;
}
开发者ID:nickerso,项目名称:original-opencor,代码行数:16,代码来源:idasolver.cpp
示例7: N_VClone_Serial
N_Vector N_VClone_Serial(N_Vector w)
{
N_Vector v;
realtype *data;
long int length;
v = NULL;
v = N_VCloneEmpty_Serial(w);
if (v == NULL) return(NULL);
length = NV_LENGTH_S(w);
/* Create data */
if (length > 0) {
/* Allocate memory */
data = NULL;
data = (realtype *) malloc(length * sizeof(realtype));
if(data == NULL) { N_VDestroy_Serial(v); return(NULL); }
/* Attach data */
NV_OWN_DATA_S(v) = TRUE;
NV_DATA_S(v) = data;
}
return(v);
}
开发者ID:A1kmm,项目名称:modml-solver,代码行数:28,代码来源:nvector_serial.c
示例8: Problem2
static void Problem2(void)
{
void *fct;
void *cpode_mem;
N_Vector y, yp;
realtype reltol=RTOL, abstol=ATOL, t, tout, erm, hu;
int flag, iout, qu;
y = NULL;
yp = NULL;
cpode_mem = NULL;
y = N_VNew_Serial(P2_NEQ);
N_VConst(ZERO, y);
NV_Ith_S(y,0) = ONE;
yp = N_VNew_Serial(P2_NEQ);
if (ODE == CP_EXPL) {
fct = (void *)f2;
} else {
fct = (void *)res2;
f2(P2_T0, y, yp, NULL);
}
cpode_mem = CPodeCreate(ODE, CP_ADAMS, CP_FUNCTIONAL);
/* flag = CPodeSetInitStep(cpode_mem, 2.0e-9);*/
flag = CPodeInit(cpode_mem, fct, NULL, P2_T0, y, yp, CP_SS, reltol, &abstol);
printf("\n t max.err qu hu \n");
for(iout=1, tout=P2_T1; iout <= P2_NOUT; iout++, tout*=P2_TOUT_MULT) {
flag = CPode(cpode_mem, tout, &t, y, yp, CP_NORMAL);
if (flag != CP_SUCCESS) break;
erm = MaxError(y, t);
flag = CPodeGetLastOrder(cpode_mem, &qu);
flag = CPodeGetLastStep(cpode_mem, &hu);
printf("%10.3f %12.4le %2d %12.4le\n", t, erm, qu, hu);
}
PrintFinalStats(cpode_mem);
CPodeFree(&cpode_mem);
N_VDestroy_Serial(y);
N_VDestroy_Serial(yp);
return;
}
开发者ID:thomasklau,项目名称:simbody,代码行数:47,代码来源:cpsadamsx.c
示例9: main
int main()
{
void *fct;
void *cpode_mem;
N_Vector y, yp;
realtype reltol=RTOL, abstol=ATOL, t, tout, hu;
int flag, iout, qu;
y = NULL;
yp = NULL;
cpode_mem = NULL;
y = N_VNew_Serial(P1_NEQ);
NV_Ith_S(y,0) = TWO;
NV_Ith_S(y,1) = ZERO;
yp = N_VNew_Serial(P1_NEQ);
if (ODE == CP_EXPL) {
fct = (void *)f;
} else {
fct = (void *)res;
f(P1_T0, y, yp, NULL);
}
cpode_mem = CPodeCreate(ODE, CP_ADAMS, CP_FUNCTIONAL);
/* flag = CPodeSetInitStep(cpode_mem, 4.0e-9);*/
flag = CPodeInit(cpode_mem, fct, NULL, P1_T0, y, yp, CP_SS, reltol, &abstol);
printf("\n t x xdot qu hu \n");
for(iout=1, tout=P1_T1; iout <= P1_NOUT; iout++, tout += P1_DTOUT) {
flag = CPode(cpode_mem, tout, &t, y, yp, CP_NORMAL);
if (flag != CP_SUCCESS) break;
flag = CPodeGetLastOrder(cpode_mem, &qu);
flag = CPodeGetLastStep(cpode_mem, &hu);
printf("%10.5f %12.5le %12.5le %2d %6.4le\n", t, NV_Ith_S(y,0), NV_Ith_S(y,1), qu, hu);
}
PrintFinalStats(cpode_mem);
CPodeFree(&cpode_mem);
N_VDestroy_Serial(y);
N_VDestroy_Serial(yp);
return 0;
}
开发者ID:AyMaN-GhOsT,项目名称:simbody,代码行数:46,代码来源:cpsVanDPol_non.c
示例10: N_VDestroy_Serial
void ViCaRS::cleanup(void) {
unsigned int i;
// Free y and abstol vectors
N_VDestroy_Serial(_vars);
for (i=0;i<_solvers.size();++i) delete _solvers[i];
}
开发者ID:eheien,项目名称:vicars,代码行数:8,代码来源:RateState.cpp
示例11: N_VDestroyVectorArray_Serial
void N_VDestroyVectorArray_Serial(N_Vector *vs, int count)
{
int j;
for (j = 0; j < count; j++) N_VDestroy_Serial(vs[j]);
free(vs);
}
开发者ID:bhache,项目名称:pkg-neuron,代码行数:8,代码来源:nvector_serial.c
示例12: CVodeSensFree
CVodesIntegrator::~CVodesIntegrator()
{
if (m_cvode_mem) {
if (m_np > 0) {
CVodeSensFree(m_cvode_mem);
}
CVodeFree(&m_cvode_mem);
}
if (m_y) {
N_VDestroy_Serial(m_y);
}
if (m_abstol) {
N_VDestroy_Serial(m_abstol);
}
if (m_yS) {
N_VDestroyVectorArray_Serial(m_yS, static_cast<sd_size_t>(m_np));
}
}
开发者ID:Niemeyer-Research-Group,项目名称:cantera,代码行数:18,代码来源:CVodesIntegrator.cpp
示例13: ode_solver_free
void ode_solver_free(ode_solver* solver){
free(solver->params);
CVodeFree(&(solver->cvode_mem));
if (solver->yS != 0) {
N_VDestroyVectorArray_Serial(solver->yS, solver->odeModel->P);
}
N_VDestroy_Serial(solver->y);
free(solver);
}
开发者ID:BioinformaticsArchive,项目名称:mcmc_clib,代码行数:9,代码来源:ode_model.c
示例14: N_VDestroy_Serial
Ida::~Ida()
{
if (_z)
delete[] _z;
if (_zInit)
delete[] _zInit;
if (_zeroSign)
delete[] _zeroSign;
if (_absTol)
delete[] _absTol;
if (_zWrite)
delete[] _zWrite;
if (_ida_initialized)
{
N_VDestroy_Serial(_CV_y0);
N_VDestroy_Serial(_CV_y);
N_VDestroy_Serial(_CV_yp);
N_VDestroy_Serial(_CV_yWrite);
N_VDestroy_Serial(_CV_absTol);
IDAFree(&_idaMem);
}
if (_colorOfColumn)
delete [] _colorOfColumn;
if(_delta)
delete [] _delta;
if(_deltaInv)
delete [] _deltaInv;
if(_ysave)
delete [] _ysave;
#ifdef RUNTIME_PROFILING
if(measuredFunctionStartValues)
delete measuredFunctionStartValues;
if(measuredFunctionEndValues)
delete measuredFunctionEndValues;
if(solveFunctionStartValues)
delete solveFunctionStartValues;
if(solveFunctionEndValues)
delete solveFunctionEndValues;
if(solverValues)
delete solverValues;
#endif
}
开发者ID:AntonDV235,项目名称:OMCompiler,代码行数:44,代码来源:IDA.cpp
示例15: FreeUserData
static void FreeUserData(WebData wdata)
{
int i, ngrp;
ngrp = wdata->ngrp;
for(i=0; i < ngrp; i++) {
destroyMat((wdata->P)[i]);
destroyArray((wdata->pivot)[i]);
}
N_VDestroy_Serial(wdata->rewt);
free(wdata);
}
开发者ID:aragilar,项目名称:debian-packaging-sundials,代码行数:12,代码来源:cvsKrylovDemo_prec.c
示例16: setTolerances
void CVodesIntegrator::setTolerances(double reltol, int n, double* abstol) {
m_itol = CV_SV;
m_nabs = n;
if (n != m_neq) {
if (m_abstol) N_VDestroy_Serial(nv(m_abstol));
m_abstol = reinterpret_cast<void*>(N_VNew_Serial(n));
}
for (int i=0; i<n; i++) {
NV_Ith_S(nv(m_abstol), i) = abstol[i];
}
m_reltol = reltol;
}
开发者ID:anujg1991,项目名称:cantera,代码行数:12,代码来源:CVodesIntegrator.cpp
示例17: main
int main(void)
{
realtype dx, dy, reltol, abstol, t, tout, umax;
N_Vector u, up;
UserData data;
void *cvode_mem;
int iout, flag;
long int nst;
u = NULL;
data = NULL;
cvode_mem = NULL;
u = N_VNew_Serial(NEQ);
up = N_VNew_Serial(NEQ);
reltol = ZERO;
abstol = ATOL;
data = (UserData) malloc(sizeof *data);
dx = data->dx = XMAX/(MX+1);
dy = data->dy = YMAX/(MY+1);
data->hdcoef = ONE/(dx*dx);
data->hacoef = HALF/(TWO*dx);
data->vdcoef = ONE/(dy*dy);
SetIC(u, data);
cvode_mem = CPodeCreate(CP_EXPL, CP_BDF, CP_NEWTON);
flag = CPodeInit(cvode_mem, (void *)f, data, T0, u, NULL, CP_SS, reltol, &abstol);
flag = CPLapackBand(cvode_mem, NEQ, MY, MY);
flag = CPDlsSetJacFn(cvode_mem, (void *)Jac, data);
/* In loop over output points: call CPode, print results, test for errors */
umax = N_VMaxNorm(u);
PrintHeader(reltol, abstol, umax);
for(iout=1, tout=T1; iout <= NOUT; iout++, tout += DTOUT) {
flag = CPode(cvode_mem, tout, &t, u, up, CP_NORMAL);
umax = N_VMaxNorm(u);
flag = CPodeGetNumSteps(cvode_mem, &nst);
PrintOutput(t, umax, nst);
}
PrintFinalStats(cvode_mem);
N_VDestroy_Serial(u);
CPodeFree(&cvode_mem);
free(data);
return(0);
}
开发者ID:BrianZ1,项目名称:simbody,代码行数:52,代码来源:cpsbanx_lap.c
示例18: DestroyIntegrator
int DestroyIntegrator(struct Integrator** integrator)
{
struct Integrator* intg = *integrator;
if (intg)
{
if (intg->y) N_VDestroy_Serial(intg->y);
if (intg->cvode_mem) CVodeFree(&(intg->cvode_mem));
if (intg->simulation) DestroySimulation(&(intg->simulation));
free(intg);
}
*integrator = NULL;
return(OK);
}
开发者ID:chrispbradley,项目名称:csim,代码行数:13,代码来源:integrator.cpp
示例19: main
//main
int main(int argc, char **argv){
int i, j, n, pv=0;
char* file_name;
cs *jac;
N_Vector u;
Gen *gens;
double *u0;
//load ps file, populate ps, and grab some data
if(argc > 1)
file_name = argv[1];
else{
printf("Please specify PS data file.");
return 1;
}
PS ps=GetPS(file_name);
if(ps==NULL){
printf("Unable to build PS data.\n");
return 1;
}
n=(ps->num_buses-1)<<1;
gens=ps->gens;
u=N_VNew_Serial(n);
u0=NV_DATA_S(u);
//create an initial condition
if(gens[pv].index==ps->swing_bus)pv++;
for(i=0;i<ps->ybus->n;i++){
if(i==ps->swing_bus) continue;
j=(i>ps->swing_bus?(i-1)<<1:i<<1);
if(gens[pv].index==i){
u0[j]=0.1;
u0[j+1]=0.1;
pv++;
if(pv<ps->num_gens&&gens[pv].index==ps->swing_bus)pv++;
continue;
}
u0[j]=1.0; u0[j+1]=0.1;
}
//numerically evaluate the jacobian at initial condition
jac=CheckDerivativeN(n, n, ComputeF, u, (void*)ps);
cs_di_print(jac, 0);
//free memory and return
N_VDestroy_Serial(u);
return 0;
}
开发者ID:phines,项目名称:cosmic,代码行数:51,代码来源:sandbox.c
示例20: N_VDestroy_Serial
void CVodesIntegrator::setTolerances(double reltol, size_t n, double* abstol)
{
m_itol = CV_SV;
m_nabs = n;
if (n != m_neq) {
if (m_abstol) {
N_VDestroy_Serial(m_abstol);
}
m_abstol = N_VNew_Serial(static_cast<sd_size_t>(n));
}
for (size_t i=0; i<n; i++) {
NV_Ith_S(m_abstol, i) = abstol[i];
}
m_reltol = reltol;
}
开发者ID:thomasfiala,项目名称:cantera,代码行数:15,代码来源:CVodesIntegrator.cpp
注:本文中的N_VDestroy_Serial函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论