n_parse_options.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*****************************************************************************
  2. *
  3. * MODULE: Grass PDE Numerical Library
  4. * AUTHOR(S): Soeren Gebbert, Berlin (GER) Dec 2006
  5. * soerengebbert <at> gmx <dot> de
  6. *
  7. * PURPOSE: standard parser option for the numerical pde library
  8. *
  9. * COPYRIGHT: (C) 2000 by the GRASS Development Team
  10. *
  11. * This program is free software under the GNU General Public
  12. * License (>=v2). Read the file COPYING that comes with GRASS
  13. * for details.
  14. *
  15. *****************************************************************************/
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <grass/glocale.h>
  20. #include <grass/N_pde.h>
  21. /*!
  22. * \brief Create standardised Option structure related to the gpde library.
  23. *
  24. * This function will create a standardised Option structure
  25. * defined by parameter opt. A list of valid parameters can be found in N_pde.h.
  26. * It allocates memory for the Option structure and returns a pointer to
  27. * this memory (of <i>type struct Option *</i>).<br>
  28. *
  29. * If an invalid parameter was specified an empty Option structure will
  30. * be returned (not NULL).
  31. *
  32. * This function is related to the gpde library, general standard options can be
  33. * found in lib/gis/parser.c. These options are set with G_define_standard_option ();
  34. *
  35. * \param[in] opt Type of Option struct to create
  36. * \return Option * Pointer to an Option struct
  37. *
  38. * */
  39. struct Option *N_define_standard_option(int opt)
  40. {
  41. struct Option *Opt;
  42. Opt = G_define_option();
  43. switch (opt) {
  44. /*solver for symmetric, positive definite linear equation systems */
  45. case N_OPT_SOLVER_SYMM:
  46. Opt->key = "solver";
  47. Opt->type = TYPE_STRING;
  48. Opt->required = NO;
  49. Opt->key_desc = "name";
  50. Opt->answer = "cg";
  51. Opt->options = "gauss,lu,cholesky,jacobi,sor,cg,bicgstab,pcg";
  52. Opt->guisection = "Solver";
  53. Opt->description =
  54. ("The type of solver which should solve the symmetric linear equation system");
  55. break;
  56. /*solver for unsymmetric linear equation systems */
  57. case N_OPT_SOLVER_UNSYMM:
  58. Opt->key = "solver";
  59. Opt->type = TYPE_STRING;
  60. Opt->required = NO;
  61. Opt->key_desc = "name";
  62. Opt->answer = "bicgstab";
  63. Opt->options = "gauss,lu,jacobi,sor,bicgstab";
  64. Opt->guisection = "Solver";
  65. Opt->description =
  66. ("The type of solver which should solve the linear equation system");
  67. break;
  68. case N_OPT_MAX_ITERATIONS:
  69. Opt->key = "maxit";
  70. Opt->type = TYPE_INTEGER;
  71. Opt->required = NO;
  72. Opt->answer = "10000";
  73. Opt->guisection = "Solver";
  74. Opt->description =
  75. ("Maximum number of iteration used to solve the linear equation system");
  76. break;
  77. case N_OPT_ITERATION_ERROR:
  78. Opt->key = "error";
  79. Opt->type = TYPE_DOUBLE;
  80. Opt->required = NO;
  81. Opt->answer = "0.000001";
  82. Opt->guisection = "Solver";
  83. Opt->description =
  84. ("Error break criteria for iterative solver");
  85. break;
  86. case N_OPT_SOR_VALUE:
  87. Opt->key = "relax";
  88. Opt->type = TYPE_DOUBLE;
  89. Opt->required = NO;
  90. Opt->answer = "1";
  91. Opt->guisection = "Solver";
  92. Opt->description =
  93. ("The relaxation parameter used by the jacobi and sor solver for speedup or stabilizing");
  94. break;
  95. case N_OPT_CALC_TIME:
  96. Opt->key = "dtime";
  97. Opt->type = TYPE_DOUBLE;
  98. Opt->required = YES;
  99. Opt->answer = "86400";
  100. Opt->guisection = "Solver";
  101. Opt->description = _("The calculation time in seconds");
  102. break;
  103. }
  104. return Opt;
  105. }