Droplet Lagrangian Transient One-dimensional Reacting Code Implementation of both liquid and gas phase governing equations.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

77 wiersze
1.5KB

  1. template<typename T>
  2. int parseNumber(FILE* input, const char* keyword, const size_t bufLen, T* n){
  3. char buf[bufLen];
  4. char buf1[bufLen];
  5. char comment[1];
  6. char *ret;
  7. while (fgets(buf,bufLen, input)!=NULL){
  8. comment[0]=buf[0];
  9. if(strncmp(comment,"#",1)==0){
  10. //printf("Comment!:%s\n",buf);
  11. }
  12. else{
  13. ret=strtok(buf,"=");
  14. if(strcmp(ret,keyword)==0){
  15. /*offset buf by keyword size + 1 for the "="*/
  16. strncpy (buf1, buf+strlen(keyword)+1, bufLen);
  17. printf("%30s: ",keyword);
  18. getFromString(buf1,n);
  19. rewind(input);
  20. return(0);
  21. }
  22. }
  23. }
  24. rewind(input);
  25. return(-1);
  26. }
  27. template<typename T>
  28. int parseArray(FILE* input, const char* keyword, const size_t bufLen,
  29. const size_t arrLen, T y[]){
  30. char buf[bufLen];
  31. char buf1[bufLen];
  32. char comment[1];
  33. char *ret;
  34. while (fgets(buf,bufLen, input)!=NULL){
  35. comment[0]=buf[0];
  36. if(strncmp(comment,"#",1)==0){
  37. //printf("Comment!:%s\n",buf);
  38. }
  39. else{
  40. ret=strtok(buf,"=");
  41. if(strcmp(ret,keyword)==0){
  42. /*offset buf by keyword size + 1 for the "="*/
  43. strncpy (buf1, buf+strlen(keyword)+1, bufLen);
  44. printf("%30s:\n",keyword);
  45. ret=strtok(buf1,",");
  46. size_t j=0;
  47. while(ret!=NULL){
  48. if(j<arrLen){
  49. //y[j]=atof(ret);
  50. getFromString(ret,&y[j]);
  51. }
  52. ret=strtok(NULL,",");
  53. j++;
  54. }
  55. rewind(input);
  56. if(j!=arrLen){
  57. printf("Check no: of values entered for %s\n",keyword);
  58. printf("%lu values required!\n",arrLen);
  59. return(-1);
  60. }
  61. else{
  62. return(0);
  63. }
  64. }
  65. }
  66. }
  67. rewind(input);
  68. return(-1);
  69. }