A low Mach, 1D, reacting flow code.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

91 líneas
1.8KB

  1. #include "solution.h"
  2. int allocateSolution(size_t neq,
  3. int nThreads,
  4. N_Vector *y,
  5. N_Vector *ydot,
  6. N_Vector *res,
  7. N_Vector *id,
  8. N_Vector *atolv,
  9. N_Vector *constraints){
  10. *y = N_VNew_OpenMP(neq,nThreads);
  11. if(*y==NULL){
  12. printf("Allocation Failed!\n");
  13. return(1);
  14. }
  15. N_VConst((realtype)(0.0e0), *y);
  16. *ydot = N_VNew_OpenMP(neq,nThreads);
  17. if(*ydot==NULL){
  18. printf("Allocation Failed!\n");
  19. return(1);
  20. }
  21. N_VConst((realtype)(0.0e0), *ydot);
  22. *res = N_VNew_OpenMP(neq,nThreads);
  23. if(*res==NULL){
  24. printf("Allocation Failed!\n");
  25. return(1);
  26. }
  27. N_VConst((realtype)(0.0e0), *res);
  28. *id = N_VNew_OpenMP(neq,nThreads);
  29. if(*id==NULL){
  30. printf("Allocation Failed!\n");
  31. return(1);
  32. }
  33. N_VConst((realtype)(1.0e0), *id);
  34. *atolv = N_VNew_OpenMP(neq,nThreads);
  35. if(*atolv==NULL){
  36. printf("Allocation Failed!\n");
  37. return(1);
  38. }
  39. N_VConst((realtype)(0.0e0), *atolv);
  40. *constraints = N_VNew_OpenMP(neq,nThreads);
  41. if(*constraints==NULL){
  42. printf("Allocation Failed!\n");
  43. return(1);
  44. }
  45. N_VConst((realtype)(0.0e0), *constraints);
  46. return(0);
  47. }
  48. void freeSolution(N_Vector *y,
  49. N_Vector *ydot,
  50. N_Vector *res,
  51. N_Vector *id,
  52. N_Vector *atolv,
  53. N_Vector *constraints){
  54. if(*y!=NULL){
  55. N_VDestroy_OpenMP(*y);
  56. printf("y Destroyed!\n");
  57. }
  58. if(*ydot!=NULL){
  59. N_VDestroy_OpenMP(*ydot);
  60. printf("ydot Destroyed!\n");
  61. }
  62. if(*res!=NULL){
  63. N_VDestroy_OpenMP(*res);
  64. printf("res Destroyed!\n");
  65. }
  66. if(*id!=NULL){
  67. N_VDestroy_OpenMP(*id);
  68. printf("id Destroyed!\n");
  69. }
  70. if(*atolv!=NULL){
  71. N_VDestroy_OpenMP(*atolv);
  72. printf("atolv Destroyed!\n");
  73. }
  74. if(*constraints!=NULL){
  75. N_VDestroy_OpenMP(*constraints);
  76. printf("constraints Destroyed!\n");
  77. }
  78. printf("\n\n");
  79. }