[GRASS-SVN] r41644 - in grass/branches/develbranch_6: lib/gpde
raster/r.gwflow
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Apr 1 05:57:18 EDT 2010
Author: huhabla
Date: 2010-04-01 05:57:18 -0400 (Thu, 01 Apr 2010)
New Revision: 41644
Modified:
grass/branches/develbranch_6/lib/gpde/N_gwflow.c
grass/branches/develbranch_6/lib/gpde/N_parse_options.c
grass/branches/develbranch_6/raster/r.gwflow/main.c
Log:
Use cell array in r.gwflow to store the boundary conditions,
Added GUI Secttions,
Use G_define_standard_option
Modified: grass/branches/develbranch_6/lib/gpde/N_gwflow.c
===================================================================
--- grass/branches/develbranch_6/lib/gpde/N_gwflow.c 2010-04-01 09:56:34 UTC (rev 41643)
+++ grass/branches/develbranch_6/lib/gpde/N_gwflow.c 2010-04-01 09:57:18 UTC (rev 41644)
@@ -154,7 +154,7 @@
data->phead = N_alloc_array_2d(cols, rows, 1, DCELL_TYPE);
data->phead_start = N_alloc_array_2d(cols, rows, 1, DCELL_TYPE);
- data->status = N_alloc_array_2d(cols, rows, 1, DCELL_TYPE);
+ data->status = N_alloc_array_2d(cols, rows, 1, CELL_TYPE);
data->hc_x = N_alloc_array_2d(cols, rows, 1, DCELL_TYPE);
data->hc_y = N_alloc_array_2d(cols, rows, 1, DCELL_TYPE);
data->q = N_alloc_array_2d(cols, rows, 1, DCELL_TYPE);
Modified: grass/branches/develbranch_6/lib/gpde/N_parse_options.c
===================================================================
--- grass/branches/develbranch_6/lib/gpde/N_parse_options.c 2010-04-01 09:56:34 UTC (rev 41643)
+++ grass/branches/develbranch_6/lib/gpde/N_parse_options.c 2010-04-01 09:57:18 UTC (rev 41644)
@@ -53,6 +53,7 @@
Opt->required = NO;
Opt->key_desc = "name";
Opt->answer = "cg";
+ Opt->guisection = "Solver";
Opt->options = "gauss,lu,cholesky,jacobi,sor,cg,bicgstab,pcg";
Opt->description =
_("The type of solver which should solve the symmetric linear equation system");
@@ -64,6 +65,7 @@
Opt->required = NO;
Opt->key_desc = "name";
Opt->answer = "bicgstab";
+ Opt->guisection = "Solver";
Opt->options = "gauss,lu,jacobi,sor,bicgstab";
Opt->description =
_("The type of solver which should solve the linear equation system");
@@ -73,6 +75,7 @@
Opt->type = TYPE_INTEGER;
Opt->required = NO;
Opt->answer = "100000";
+ Opt->guisection = "Solver";
Opt->description =
_("Maximum number of iteration used to solver the linear equation system");
break;
@@ -81,6 +84,7 @@
Opt->type = TYPE_DOUBLE;
Opt->required = NO;
Opt->answer = "0.0000000001";
+ Opt->guisection = "Solver";
Opt->description =
_("Error break criteria for iterative solvers (jacobi, sor, cg or bicgstab)");
break;
@@ -89,6 +93,7 @@
Opt->type = TYPE_DOUBLE;
Opt->required = NO;
Opt->answer = "1";
+ Opt->guisection = "Solver";
Opt->description =
_("The relaxation parameter used by the jacobi and sor solver for speedup or stabilizing");
break;
@@ -97,6 +102,7 @@
Opt->type = TYPE_DOUBLE;
Opt->required = YES;
Opt->answer = "86400";
+ Opt->guisection = "Solver";
Opt->description = _("The calculation time in seconds");
break;
}
Modified: grass/branches/develbranch_6/raster/r.gwflow/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.gwflow/main.c 2010-04-01 09:56:34 UTC (rev 41643)
+++ grass/branches/develbranch_6/raster/r.gwflow/main.c 2010-04-01 09:57:18 UTC (rev 41644)
@@ -45,91 +45,63 @@
N_les_callback_2d * call, const char *solver, int maxit,
double error);
+
/* ************************************************************************* */
/* Set up the arguments we are expecting ********************************** */
/* ************************************************************************* */
void set_params(void)
{
- param.phead = G_define_option();
+ param.phead = G_define_standard_option(G_OPT_R_INPUT);
param.phead->key = "phead";
- param.phead->type = TYPE_STRING;
- param.phead->required = YES;
- param.phead->gisprompt = "old,raster,raster";
param.phead->description = _("The initial piezometric head in [m]");
- param.status = G_define_option();
+ param.status = G_define_standard_option(G_OPT_R_INPUT);
param.status->key = "status";
- param.status->type = TYPE_STRING;
- param.status->required = YES;
- param.status->gisprompt = "old,raster,raster";
- param.status->description = _("Boundary condition status, 0-inactive, 1-active, 2-dirichlet");
+ param.status->description =
+ _("Boundary condition status, 0-inactive, 1-active, 2-dirichlet");
- param.hc_x = G_define_option();
+ param.hc_x = G_define_standard_option(G_OPT_R_INPUT);
param.hc_x->key = "hc_x";
- param.hc_x->type = TYPE_STRING;
- param.hc_x->required = YES;
- param.hc_x->gisprompt = "old,raster,raster";
param.hc_x->description =
_("X-part of the hydraulic conductivity tensor in [m/s]");
- param.hc_y = G_define_option();
+ param.hc_y = G_define_standard_option(G_OPT_R_INPUT);
param.hc_y->key = "hc_y";
- param.hc_y->type = TYPE_STRING;
- param.hc_y->required = YES;
- param.hc_y->gisprompt = "old,raster,raster";
param.hc_y->description =
_("Y-part of the hydraulic conductivity tensor in [m/s]");
- param.q = G_define_option();
+ param.q = G_define_standard_option(G_OPT_R_INPUT);
param.q->key = "q";
- param.q->type = TYPE_STRING;
- param.q->required = NO;
- param.q->gisprompt = "old,raster,raster";
param.q->description = _("Water sources and sinks in [m^3/s]");
- param.s = G_define_option();
+ param.s = G_define_standard_option(G_OPT_R_INPUT);
param.s->key = "s";
- param.s->type = TYPE_STRING;
- param.s->required = YES;
- param.s->gisprompt = "old,raster,raster";
param.s->description = _("Specific yield in [1/m]");
- param.r = G_define_option();
+ param.r = G_define_standard_option(G_OPT_R_INPUT);
param.r->key = "r";
- param.r->type = TYPE_STRING;
- param.r->required = NO;
- param.r->gisprompt = "old,raster,raster";
+ param.r->guisection = _("Recharge");
param.r->description =
_("Recharge map e.g: 6*10^-9 per cell in [m^3/s*m^2]");
- param.top = G_define_option();
+ param.top = G_define_standard_option(G_OPT_R_INPUT);
param.top->key = "top";
- param.top->type = TYPE_STRING;
- param.top->required = YES;
- param.top->gisprompt = "old,raster,raster";
param.top->description = _("Top surface of the aquifer in [m]");
- param.bottom = G_define_option();
+ param.bottom = G_define_standard_option(G_OPT_R_INPUT);
param.bottom->key = "bottom";
- param.bottom->type = TYPE_STRING;
- param.bottom->required = YES;
- param.bottom->gisprompt = "old,raster,raster";
param.bottom->description = _("Bottom surface of the aquifer in [m]");
- param.output = G_define_option();
+ param.output = G_define_standard_option(G_OPT_R_OUTPUT);
param.output->key = "output";
- param.output->type = TYPE_STRING;
- param.output->required = YES;
- param.output->gisprompt = "new,raster,raster";
- param.output->description = _("The map storing the numerical result [m]");
+ param.output->description = _("The map storing the numerical result [m]");
- param.vector = G_define_option();
+ param.vector = G_define_standard_option(G_OPT_R_OUTPUT);
param.vector->key = "velocity";
- param.vector->type = TYPE_STRING;
param.vector->required = NO;
- param.vector->gisprompt = "new,raster,raster";
- param.vector->description = _("Calculate the groundwater filter velocity vector field [m/s]\n"
- "and write the x, and y components to maps named name_[xy]");
+ param.vector->description =
+ _("Calculate the groundwater filter velocity vector field [m/s]\n"
+ "and write the x, and y components to maps named name_[xy]");
param.type = G_define_option();
param.type->key = "type";
@@ -140,52 +112,50 @@
param.type->description = _("The type of groundwater flow");
/*Variants of the cauchy boundary condition */
- param.river_bed = G_define_option();
+ param.river_bed = G_define_standard_option(G_OPT_R_INPUT);
param.river_bed->key = "river_bed";
- param.river_bed->type = TYPE_STRING;
+ param.river_bed->guisection = "River";
param.river_bed->required = NO;
- param.river_bed->gisprompt = "old,raster,raster";
- param.river_bed->description = _("The hight of the river bed in [m]");
+ param.river_bed->description = _("The height of the river bed in [m]");
- param.river_head = G_define_option();
+ param.river_head = G_define_standard_option(G_OPT_R_INPUT);
param.river_head->key = "river_head";
- param.river_head->type = TYPE_STRING;
+ param.river_head->guisection = "River";
param.river_head->required = NO;
- param.river_head->gisprompt = "old,raster,raster";
param.river_head->description =
_("Water level (head) of the river with leakage connection in [m]");
- param.river_leak = G_define_option();
+ param.river_leak = G_define_standard_option(G_OPT_R_INPUT);
param.river_leak->key = "river_leak";
- param.river_leak->type = TYPE_STRING;
+ param.river_leak->guisection = "River";
param.river_leak->required = NO;
- param.river_leak->gisprompt = "old,raster,raster";
param.river_leak->description =
_("The leakage coefficient of the river bed in [1/s].");
- param.drain_bed = G_define_option();
- param.drain_bed->key = "drain_bed";
- param.drain_bed->type = TYPE_STRING;
+ param.drain_bed = G_define_standard_option(G_OPT_R_INPUT);
+ param.drain_bed->key = "drain_bed";;
+ param.drain_bed->guisection = "Drainage";
param.drain_bed->required = NO;
- param.drain_bed->gisprompt = "old,raster,raster";
- param.drain_bed->description = _("The hight of the drainage bed in [m]");
+ param.drain_bed->description = _("The height of the drainage bed in [m]");
- param.drain_leak = G_define_option();
+ param.drain_leak = G_define_standard_option(G_OPT_R_INPUT);
param.drain_leak->key = "drain_leak";
- param.drain_leak->type = TYPE_STRING;
+ param.drain_leak->guisection = "Drainage";
param.drain_leak->required = NO;
- param.drain_leak->gisprompt = "old,raster,raster";
- param.drain_leak->description = _("The leakage coefficient of the drainage bed in [1/s]");
-
+ param.drain_leak->description =
+ _("The leakage coefficient of the drainage bed in [1/s]");
+
param.dt = N_define_standard_option(N_OPT_CALC_TIME);
param.maxit = N_define_standard_option(N_OPT_MAX_ITERATIONS);
param.error = N_define_standard_option(N_OPT_ITERATION_ERROR);
- param.solver = N_define_standard_option(N_OPT_SOLVER_SYMM);
+ param.solver = N_define_standard_option(N_OPT_SOLVER_SYMM);;
param.solver->options = "cg,pcg,cholesky";
param.sparse = G_define_flag();
param.sparse->key = 's';
- param.sparse->description = _("Use a sparse matrix, only available with iterative solvers");
+ param.sparse->guisection = "Solver";
+ param.sparse->description =
+ _("Use a sparse matrix, only available with iterative solvers");
}
@@ -225,7 +195,12 @@
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+ /* Make sure that the current projection is not lat/long */
+ if ((G_projection() == PROJECTION_LL))
+ G_fatal_error(_("Lat/Long location is not supported by %s. Please reproject map first."),
+ G_program_name());
+
/*Check the river parameters */
if (param.river_leak->answer == NULL && param.river_bed->answer == NULL &&
param.river_head->answer == NULL) {
@@ -344,7 +319,7 @@
/* Set the inactive values to zero, to assure a no flow boundary */
for (y = 0; y < geom->rows; y++) {
for (x = 0; x < geom->cols; x++) {
- stat = (int)N_get_array_2d_d_value(data->status, x, y);
+ stat = N_get_array_2d_c_value(data->status, x, y);
if (stat == N_CELL_INACTIVE) { /*only inactive cells */
N_put_array_2d_d_value(data->hc_x, x, y, 0);
N_put_array_2d_d_value(data->hc_y, x, y, 0);
@@ -354,7 +329,6 @@
}
}
-
/*assemble the linear equation system and solve it */
les = create_solve_les(geom, data, call, solver, maxit, error);
@@ -480,7 +454,7 @@
for (y = 0; y < rows; y++) {
G_percent(y, rows - 1, 10);
for (x = 0; x < cols; x++) {
- stat = (int)N_get_array_2d_d_value(status, x, y);
+ stat = N_get_array_2d_c_value(status, x, y);
if (stat == N_CELL_ACTIVE) { /*only active cells */
d1 = result[count];
val = (DCELL) d1;
More information about the grass-commit
mailing list