|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #include "solution.h"
- int allocateSolution(size_t neq,
- int nThreads,
- N_Vector *y,
- N_Vector *ydot,
- N_Vector *res,
- N_Vector *id,
- N_Vector *atolv,
- N_Vector *constraints){
-
-
- *y = N_VNew_OpenMP(neq,nThreads);
- if(*y==NULL){
- printf("Allocation Failed!\n");
- return(1);
- }
- N_VConst((realtype)(0.0e0), *y);
-
- *ydot = N_VNew_OpenMP(neq,nThreads);
- if(*ydot==NULL){
- printf("Allocation Failed!\n");
- return(1);
- }
- N_VConst((realtype)(0.0e0), *ydot);
-
- *res = N_VNew_OpenMP(neq,nThreads);
- if(*res==NULL){
- printf("Allocation Failed!\n");
- return(1);
- }
- N_VConst((realtype)(0.0e0), *res);
-
- *id = N_VNew_OpenMP(neq,nThreads);
- if(*id==NULL){
- printf("Allocation Failed!\n");
- return(1);
- }
- N_VConst((realtype)(1.0e0), *id);
-
- *atolv = N_VNew_OpenMP(neq,nThreads);
- if(*atolv==NULL){
- printf("Allocation Failed!\n");
- return(1);
- }
- N_VConst((realtype)(0.0e0), *atolv);
-
- *constraints = N_VNew_OpenMP(neq,nThreads);
- if(*constraints==NULL){
- printf("Allocation Failed!\n");
- return(1);
- }
- N_VConst((realtype)(0.0e0), *constraints);
-
- return(0);
- }
-
- void freeSolution(N_Vector *y,
- N_Vector *ydot,
- N_Vector *res,
- N_Vector *id,
- N_Vector *atolv,
- N_Vector *constraints){
-
- if(*y!=NULL){
- N_VDestroy_OpenMP(*y);
- printf("y Destroyed!\n");
- }
- if(*ydot!=NULL){
- N_VDestroy_OpenMP(*ydot);
- printf("ydot Destroyed!\n");
- }
- if(*res!=NULL){
- N_VDestroy_OpenMP(*res);
- printf("res Destroyed!\n");
- }
- if(*id!=NULL){
- N_VDestroy_OpenMP(*id);
- printf("id Destroyed!\n");
- }
- if(*atolv!=NULL){
- N_VDestroy_OpenMP(*atolv);
- printf("atolv Destroyed!\n");
- }
-
- if(*constraints!=NULL){
- N_VDestroy_OpenMP(*constraints);
- printf("constraints Destroyed!\n");
- }
- printf("\n\n");
- }
|