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