GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-602118adcc
n_parse_options.c
Go to the documentation of this file.
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 
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
20 #include <grass/glocale.h>
21 #include <grass/N_pde.h>
22 
23 /*!
24  * \brief Create standardised Option structure related to the gpde library.
25  *
26  * This function will create a standardised Option structure
27  * defined by parameter opt. A list of valid parameters can be found in N_pde.h.
28  * It allocates memory for the Option structure and returns a pointer to
29  * this memory (of <i>type struct Option *</i>).<br>
30  *
31  * If an invalid parameter was specified an empty Option structure will
32  * be returned (not NULL).
33  *
34  * This function is related to the gpde library, general standard options can be
35  * found in lib/gis/parser.c. These options are set with
36  * 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 = ("The type of solver which should solve the "
59  "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 = ("The type of solver which should solve the linear "
71  "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 = ("Maximum number of iteration used to solve the "
80  "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 = ("Error break criteria for iterative solver");
89  break;
90  case N_OPT_SOR_VALUE:
91  Opt->key = "relax";
92  Opt->type = TYPE_DOUBLE;
93  Opt->required = NO;
94  Opt->answer = "1";
95  Opt->guisection = "Solver";
96  Opt->description = ("The relaxation parameter used by the jacobi and "
97  "sor solver for speedup or stabilizing");
98  break;
99  case N_OPT_CALC_TIME:
100  Opt->key = "dtime";
101  Opt->type = TYPE_DOUBLE;
102  Opt->required = YES;
103  Opt->answer = "86400";
104  Opt->guisection = "Solver";
105  Opt->description = _("The calculation time in seconds");
106  break;
107  }
108 
109  return Opt;
110 }
@ N_OPT_MAX_ITERATIONS
Definition: N_pde.h:395
@ N_OPT_SOLVER_UNSYMM
Definition: N_pde.h:394
@ N_OPT_SOLVER_SYMM
Definition: N_pde.h:392
@ N_OPT_ITERATION_ERROR
Definition: N_pde.h:397
@ N_OPT_CALC_TIME
Definition: N_pde.h:401
@ N_OPT_SOR_VALUE
Definition: N_pde.h:399
struct Option * G_define_option(void)
Initializes an Option struct.
Definition: parser.c:211
#define TYPE_STRING
Definition: gis.h:186
#define YES
Definition: gis.h:187
#define TYPE_INTEGER
Definition: gis.h:184
#define NO
Definition: gis.h:188
#define TYPE_DOUBLE
Definition: gis.h:185
#define _(str)
Definition: glocale.h:10
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:557
const char * key
Definition: gis.h:558
const char * key_desc
Definition: gis.h:564
int type
Definition: gis.h:559
const char * description
Definition: gis.h:566
char * answer
Definition: gis.h:571
int required
Definition: gis.h:560
const char * options
Definition: gis.h:562
const char * guisection
Definition: gis.h:576