TheBoussinesqModel
3.2.1
|
#include "turtle.h"
#include "t_alloc.h"
#include "linear_span.h"
#include "geometry.h"
#include "geometry_io.h"
#include "geometry_freememory.h"
#include "rw_maps.h"
#include "g_raster2plvector.h"
Go to the source code of this file.
Macros | |
#define | NO_ELEVATION 0.0 |
#define | LX_CENTER -0.5 |
#define | LY_CENTER 0.5 |
#define | TOP 1.0 |
#define | BOTTOM 0.0 |
#define | LEFT -1.0 |
#define | RIGHT 0.0 |
#define | IVERTEX 10000 |
#define | INIT_VALUE -999 |
#define | FLOATING_POINT_TYPE 0 |
#define | MAP_FORMAT 3 |
Functions | |
LONGBIN * | addresses (LONGMATRIX *lmask, long row_shift, long col_shift) |
long | index_pixel_from_a_bin (long r, long c, LONGVECTOR *s_index) |
LONGMATRIX * | m_indices_with_novalues (LONGBIN *laddresses, long nch, long novalue, long IBASE, long(*index_pixel_from_a_bin)(long r, long c, LONGVECTOR *s_index)) |
LONGMATRIX * | m_indices_from_mask (DOUBLEMATRIX *mask, long row_shift, long col_shift, long novalue, long IBASE, long(*index_pixel_from_a_bin)(long r, long c, LONGVECTOR *s_index), DOUBLEVECTOR *V, int(*check_novalues)(double x, DOUBLEVECTOR *V)) |
POINT * | new_point_from_raster (long r, long c, long nrh, long nch, double lx, double ly, double nsres, double ewres, double blc_x, double blc_y, long index) |
LINE * | new_horizontal_line_from_raster (long r, long c, long nrh, long nch, double nsres, double ewres, double blc_x, double blc_y, long iline, long ivertex1, long ivertex2) |
LINE * | new_vertical_line_from_raster (long r, long c, long nrh, long nch, double nsres, double ewres, double blc_x, double blc_y, long iline, long ivertex1, long ivertex2) |
LINEVECTOR * | get_linevector_from_raster_grid (LONGMATRIX *i_horizontal, LONGMATRIX *i_vertical, LONGMATRIX *i_vertex, double nsres, double ewres, double blc_x, double blc_y, long novalue) |
POLYGON * | new_pixel_from_raster (long index, long r, long c, LINEVECTOR *lines, LONGMATRIX *i_horizontal, LONGMATRIX *i_vertical, double nsres, double ewres, double blc_x, double blc_y, short print) |
POLYGONVECTOR * | get_polygonvector_from_raster (LINEVECTOR *lines, LONGMATRIX *i_pixels, LONGMATRIX *i_horizontal, LONGMATRIX *i_vertical, double nsres, double ewres, double blc_x, double blc_y, long novalue, short print) |
DOUBLEVECTOR * | get_doublevector_from_doublematrix (LONGMATRIX *indices, DOUBLEMATRIX *M, double novalue) |
DOUBLEMATRIX * | get_doublematrix_from_doublevector (DOUBLEVECTOR *v, LONGMATRIX *indices, DOUBLEMATRIX *Mref, double novalue) |
DOUBLEVECTOR * | read_doublevector_from_raster (short a, char *filename, DOUBLEMATRIX *Mref, T_INIT *UVref, LONGMATRIX *indices) |
int | write_raster_from_doublevector (char *filename, DOUBLEVECTOR *v, T_INIT *UVref, LONGMATRIX *indices, DOUBLEMATRIX *Mref) |
DOUBLEMATRIX * | get_doublematrix_from_mapseries (LONGMATRIX *indices, DOUBLETENSOR *mapseries, T_INIT *UVref) |
#define BOTTOM 0.0 |
Definition at line 49 of file g_raster2plvector.c.
Referenced by new_vertical_line_from_raster().
#define FLOATING_POINT_TYPE 0 |
Definition at line 57 of file g_raster2plvector.c.
Referenced by write_raster_from_doublevector().
#define INIT_VALUE -999 |
Definition at line 55 of file g_raster2plvector.c.
Referenced by get_doublematrix_from_doublevector(), and get_doublevector_from_doublematrix().
#define IVERTEX 10000 |
Definition at line 53 of file g_raster2plvector.c.
#define LEFT -1.0 |
Definition at line 50 of file g_raster2plvector.c.
Referenced by new_horizontal_line_from_raster(), and new_vertical_line_from_raster().
#define LX_CENTER -0.5 |
Definition at line 46 of file g_raster2plvector.c.
Referenced by new_pixel_from_raster().
#define LY_CENTER 0.5 |
Definition at line 47 of file g_raster2plvector.c.
Referenced by new_pixel_from_raster().
#define MAP_FORMAT 3 |
Definition at line 58 of file g_raster2plvector.c.
Referenced by write_raster_from_doublevector().
#define NO_ELEVATION 0.0 |
BGEOMETRY BUILDS THE MESH FROM A RASTER FOR THE BOUSSINESQ MODEL
KeyPalette Version 0.9375 KMackenzie
file g_raster2plvector.h
Copyright, 2009 Emanuele Cordano and Riccardo Rigon
This file is part of BGEOMETRY. BGEOMETRY is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
BGEOMETRY is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
These functions allow to use basin with a generic shape. WARNING: The mask is the raster which contains all the basin, the boundary of the basin must contain no-value elements.
right vertical line
Definition at line 45 of file g_raster2plvector.c.
Referenced by new_point_from_raster().
#define RIGHT 0.0 |
Definition at line 51 of file g_raster2plvector.c.
Referenced by new_horizontal_line_from_raster().
#define TOP 1.0 |
Definition at line 48 of file g_raster2plvector.c.
Referenced by new_horizontal_line_from_raster(), and new_vertical_line_from_raster().
LONGBIN* addresses | ( | LONGMATRIX * | lmask, |
long | row_shift, | ||
long | col_shift | ||
) |
V | (DOUBLEVECTOR *) - vector regarding the query appied (searching novalue) |
(* | check_novalue)(double x,DOUBLEVECTOR *V) (int) - query expressed as a function returning a long integer |
reply | - expected reply from the query to save the element addresses |
lmask | (DOUBLEMATRIX *) - matrix wth 0 or 1 values (if element is 1 the element is within the basin, 0 otherwise) |
row_shitf | (long) - integer parameters to be set for vertical line searching (-1: left vertical line searching, 0: pixel searching, 1: right vertical line searching) |
col_shift | (long) - integer parameters to be set for horizonttal line searching (-1: top horizontal line searching, 0: pixel searching, 1: bottom vertical line searching) |
Definition at line 78 of file g_raster2plvector.c.
References free_longvector(), LONGMATRIX::nch, LONGMATRIX::ncl, new_longbin(), new_longvector(), LONGVECTOR::nl, LONGMATRIX::nrh, and LONGMATRIX::nrl.
Referenced by m_indices_from_mask().
DOUBLEMATRIX* get_doublematrix_from_doublevector | ( | DOUBLEVECTOR * | v, |
LONGMATRIX * | indices, | ||
DOUBLEMATRIX * | Mref, | ||
double | novalue | ||
) |
v | - (DOUBLEVECTOR *) - vector which will be trasformed into a raster |
indices | (LONGVECTOR *) - matrix of indices |
Mref | - (DOUBLEMATRIX *) - reference raster |
novalue | - (double) - no value |
Definition at line 692 of file g_raster2plvector.c.
References INIT_VALUE, DOUBLEMATRIX::nch, LONGMATRIX::nch, DOUBLEMATRIX::ncl, new_doublematrix(), DOUBLEVECTOR::nh, DOUBLEVECTOR::nl, DOUBLEMATRIX::nrh, LONGMATRIX::nrh, and DOUBLEMATRIX::nrl.
Referenced by write_raster_from_doublevector(), and write_raster_from_doublevector_v2().
DOUBLEMATRIX* get_doublematrix_from_mapseries | ( | LONGMATRIX * | indices, |
DOUBLETENSOR * | mapseries, | ||
T_INIT * | UVref | ||
) |
printf ("loop %ld of %ld \n",l,mapseries->ndh); printf ("Values: %lf %lf \n",map->element[1][1],v->element[1]); stop_execution();
Definition at line 804 of file g_raster2plvector.c.
References extract_a_new_map(), free_doublematrix(), free_doublevector(), get_doublevector_from_doublematrix(), DOUBLEMATRIX::ncl, DOUBLETENSOR::ndh, DOUBLETENSOR::ndl, new_doublematrix(), DOUBLEVECTOR::nh, and T_INIT::V.
DOUBLEVECTOR* get_doublevector_from_doublematrix | ( | LONGMATRIX * | indices, |
DOUBLEMATRIX * | M, | ||
double | novalue | ||
) |
Functions which converts DOUBLEVECTOR and DOUBLEMATRIX according to a given function
indices | (LONGMATRIX *) - matrix of the indices; |
M | (DOUBLEMATRIX *) - matrix to be transformed into a vector; |
novalue | (double) - null value |
Definition at line 643 of file g_raster2plvector.c.
References INIT_VALUE, DOUBLEMATRIX::nch, LONGMATRIX::nch, DOUBLEMATRIX::ncl, new_doublevector(), DOUBLEVECTOR::nh, DOUBLEVECTOR::nl, DOUBLEMATRIX::nrh, LONGMATRIX::nrh, and DOUBLEMATRIX::nrl.
Referenced by get_doublematrix_from_mapseries(), get_doublevector_for_lines(), and read_doublevector_from_raster().
LINEVECTOR* get_linevector_from_raster_grid | ( | LONGMATRIX * | i_horizontal, |
LONGMATRIX * | i_vertical, | ||
LONGMATRIX * | i_vertex, | ||
double | nsres, | ||
double | ewres, | ||
double | blc_x, | ||
double | blc_y, | ||
long | novalue | ||
) |
i_horizontal | - (LONGMATRIX *) matrix for horizontal lines |
i_horizontal | - (LONGMATRIX *) matrix for vertical lines |
i_vertex | - |
lx | - (double) lx dimensionless x displacement for point location |
ly | - (double) ly dimensionless y displacement for point location |
nsres | - (double) north-south resolution |
ewres | - (double) east-west resolution |
blc_x | - (double) x coordinate for the bottom left corner |
blc_y | - (double) y coordinate for the bottom left corner |
novalue | - (long) null value |
\OCCORRE TENERE CONTO DEL NOVALUE!!!
Counting lines
VERTICA LINES
vertical lines at the left edge of the grid element
HORIZONTAL LINES
VERTICA LINES
horizontal lines at the upper limit of the grid element
verify of lines element
VERTICA LINES
vertical lines at the left edge of the grid element
HORIZONTAL LINES
VERTICA LINES
horizontal lines at the upper limit of the grid element
verify of lines element
Definition at line 421 of file g_raster2plvector.c.
References LINEVECTOR::element, LONGMATRIX::nch, LONGMATRIX::ncl, new_horizontal_line_from_raster(), new_linevector(), new_vertical_line_from_raster(), LINEVECTOR::nl, LONGMATRIX::nrh, and LONGMATRIX::nrl.
Referenced by get_square_grid().
POLYGONVECTOR* get_polygonvector_from_raster | ( | LINEVECTOR * | lines, |
LONGMATRIX * | i_pixels, | ||
LONGMATRIX * | i_horizontal, | ||
LONGMATRIX * | i_vertical, | ||
double | nsres, | ||
double | ewres, | ||
double | blc_x, | ||
double | blc_y, | ||
long | novalue, | ||
short | |||
) |
lines | (LINEVECTOR *) - array of lines |
i_pixels | (LONGMATRIX *) - matrix for pixel indices |
i_orizontal | (LONGMATRIX *) - matrix of indices for horizontal lines |
i_vertical | (LONGMATRIX *) - matrix of indices for vertical lines |
nsres | - (double) north-south resolution |
ewres | - (double) east-west resolution |
blc_x | - (double) x coordinate for the bottom left corner |
blc_y | - (double) y coordinate for the bottom left corner |
novalue | (long) NULL value |
- (short) it is a verbose modality if print==1 |
counter for the pixels within te basin
verify of polygonvector element
Definition at line 585 of file g_raster2plvector.c.
References POLYGONVECTOR::element, LONGMATRIX::ncl, new_pixel_from_raster(), new_polygonvector(), POLYGONVECTOR::nl, and LONGMATRIX::nrl.
Referenced by get_square_grid().
long index_pixel_from_a_bin | ( | long | r, |
long | c, | ||
LONGVECTOR * | s_index | ||
) |
lmask | (DOUBLEMATRIX *) - matrix with 0 or 1 values (if element is 1 the element is within the basin, 0 otherwise) |
row_shitf | (long) - integer parameters to be set for vertical line searching (-1: left vertical line searching, 0: pixel searching, 1: right vertical line searching) |
col_shift | (long) - integer parameters to be set for horizonttal line searching (-1: top horizontal line searching, 0: pixel searching, 1: bottom vertical line searching) |
- | (long) r row |
- | (long) c column |
- | (LONGVECTOR *) sum of the index of the bin |
Definition at line 146 of file g_raster2plvector.c.
Referenced by get_square_grid(), m_indices_from_mask(), main(), and read_square_grid().
LONGMATRIX* m_indices_from_mask | ( | DOUBLEMATRIX * | mask, |
long | row_shift, | ||
long | col_shift, | ||
long | novalue, | ||
long | IBASE, | ||
long(*)(long r, long c, LONGVECTOR *s_index) | index_pixel_from_a_bin, | ||
DOUBLEVECTOR * | V, | ||
int(*)(double x, DOUBLEVECTOR *V) | check_novalues | ||
) |
LONGMATRIX *m_indices_with_novalues(LONGBIN *addresses, long nch, long novalue, long IBASE, long (*index_pixel_from_a_bin)(long r, long c, LONGVECTOR *s_index)) LONGBIN *addresses(LONGMATRIX *lmask,long row_shift,long col_shift)
mask | (DOUBLEMATRIX *) - mask of the basin |
row_shitf | (long) - integer parameters to be set for vertical line searching (-1: left vertical line searching, 0: pixel searching, 1: right vertical line searching) |
col_shift | (long) - integer parameters to be set for horizonttal line searching (-1: top horizontal line searching, 0: pixel searching, 1: bottom vertical line searching) |
(long) | - integer values for NULL |
(long) | - IBASE base number |
(long) | - (*index_pixel_from_a_bin)(long r, long c, LONGVECTOR *s_index) - function which numbers the pixel inside the domain |
V | (DOUBLEVECTOR *)- vector containing novalue information |
int | (*check_novalues)(double x, DOUBLEVECTOR *V)) - |
Definition at line 235 of file g_raster2plvector.c.
References addresses(), free_longbin(), free_longmatrix(), index_pixel_from_a_bin(), m_indices_with_novalues(), DOUBLEMATRIX::nch, LONGMATRIX::nch, DOUBLEMATRIX::ncl, new_longmatrix(), DOUBLEMATRIX::nrh, LONGMATRIX::nrh, and DOUBLEMATRIX::nrl.
Referenced by get_square_grid(), and read_square_grid().
LONGMATRIX* m_indices_with_novalues | ( | LONGBIN * | laddresses, |
long | nch, | ||
long | novalue, | ||
long | IBASE, | ||
long(*)(long r, long c, LONGVECTOR *s_index) | index_pixel_from_a_bin | ||
) |
(LONGBIN | *) - the bin of the addresses of pixels inside the domain |
(long) | - number of columnus for the requested longmatrix |
(long) | - integer values for NULL |
(long) | - IBASE base number |
(long) | - (*index_pixel_from_a_bin)(long r, long c, LONGVECTOR *s_index) - function which numbers the pixel inside the domain |
It creates a longmatrix with cell index (for pixels inside the domain) and novalue (for pixels outside the domain)
Definition at line 179 of file g_raster2plvector.c.
References free_longvector(), LONGBIN::index, LONGMATRIX::ncl, new_longmatrix(), new_longvector(), LONGVECTOR::nh, LONGVECTOR::nl, and LONGMATRIX::nrl.
Referenced by m_indices_from_mask().
LINE* new_horizontal_line_from_raster | ( | long | r, |
long | c, | ||
long | nrh, | ||
long | nch, | ||
double | nsres, | ||
double | ewres, | ||
double | blc_x, | ||
double | blc_y, | ||
long | iline, | ||
long | ivertex1, | ||
long | ivertex2 | ||
) |
r | - (long) r row |
c | - (long) c column |
nrh | - number of rows |
nch | - number of columns |
lx | - (double) lx dimensionless x displacement for point location |
ly | - (double) ly dimensionless y displacement for point location |
nsres | - (double) north-south resolution |
ewres | - (double) east-west resolution |
blc_x | - (double) x coordinate for the bottom left corner |
blc_y | - (double) y coordinate for the bottom left corner |
iline | - (long) index number for line; |
ivertex1 | - (long) index number for the vertex 1 |
ivertex2 | - (long) index number for the vertex 2 |
Definition at line 329 of file g_raster2plvector.c.
References free_point(), LEFT, new_line_from_points(), new_point_from_raster(), RIGHT, and TOP.
Referenced by get_linevector_from_raster_grid().
POLYGON* new_pixel_from_raster | ( | long | index, |
long | r, | ||
long | c, | ||
LINEVECTOR * | lines, | ||
LONGMATRIX * | i_horizontal, | ||
LONGMATRIX * | i_vertical, | ||
double | nsres, | ||
double | ewres, | ||
double | blc_x, | ||
double | blc_y, | ||
short | |||
) |
index | (long) - index of the element |
r | (long) - row |
c | (long) - colums |
lines | (LINEVECTOR *) - array of lines |
i_orizontal | (LONGMATRIX *) - matrix of indices for horizontal lines |
i_vertical | (LONGMATRIX *) - matrix of indices for vertical lines |
nsres | - (double) north-south resolution |
ewres | - (double) east-west resolution |
blc_x | - (double) x coordinate for the bottom left corner |
blc_y | - (double) y coordinate for the bottom left corner |
- (short) it is a verbose modality if print==1 |
indices of the edge of the pixel
Definition at line 495 of file g_raster2plvector.c.
References extract_linvector_from_linevector(), free_linevector(), free_longvector(), free_point(), LX_CENTER, LY_CENTER, LONGMATRIX::nch, new_longvector(), new_point_from_raster(), new_polygon_from_a_linevector(), and LONGMATRIX::nrh.
Referenced by get_polygonvector_from_raster().
POINT* new_point_from_raster | ( | long | r, |
long | c, | ||
long | nrh, | ||
long | nch, | ||
double | lx, | ||
double | ly, | ||
double | nsres, | ||
double | ewres, | ||
double | blc_x, | ||
double | blc_y, | ||
long | index | ||
) |
r | - (long) r row |
c | - (long) c column |
nrh | - (long) number of rows |
nch | - (long) number of columns |
lx | - (double) lx dimensionless x displacement for point location |
ly | - (double) ly dimensionless y displacement for point location |
nsres | - (double) north-south resolution |
ewres | - (double) east-west resolution |
blc_x | - (double) x coordinate for the bottom left corner |
blc_y | - (double) y coordinate for the bottom left corner |
index | - (long) index of the point. |
Definition at line 294 of file g_raster2plvector.c.
References new_point(), and NO_ELEVATION.
Referenced by new_horizontal_line_from_raster(), new_pixel_from_raster(), and new_vertical_line_from_raster().
LINE* new_vertical_line_from_raster | ( | long | r, |
long | c, | ||
long | nrh, | ||
long | nch, | ||
double | nsres, | ||
double | ewres, | ||
double | blc_x, | ||
double | blc_y, | ||
long | iline, | ||
long | ivertex1, | ||
long | ivertex2 | ||
) |
r | - (long) r row |
c | - (long) c column |
nrh | - number of rows |
nch | - number of columns |
lx | - (double) lx dimensionless x displacement for point location |
ly | - (double) ly dimensionless y displacement for point location |
nsres | - (double) north-south resolution |
ewres | - (double) east-west resolution |
blc_x | - (double) x coordinate for the bottom left corner |
blc_y | - (double) y coordinate for the bottom left corner |
iline | - (long) index number for line; |
ivertex1 | - (long) index number for the vertex 1 |
ivertex2 | - (long) index number for the vertex 2 |
Definition at line 375 of file g_raster2plvector.c.
References BOTTOM, free_point(), LEFT, new_line_from_points(), new_point_from_raster(), and TOP.
Referenced by get_linevector_from_raster_grid().
DOUBLEVECTOR* read_doublevector_from_raster | ( | short | a, |
char * | filename, | ||
DOUBLEMATRIX * | Mref, | ||
T_INIT * | UVref, | ||
LONGMATRIX * | indices | ||
) |
a | (short) - flag about the use of the check with the reference map see read_map comment |
filename | (char *) name of the file |
Mref | - (DOUBLEMATRIX *) - reference map |
UVref | - (T_INIT *) T_IIT struct containg ewres and nwres information |
LONGMATRIX | *indices; |
it reads a doublematrix with "read_map" functions and it gets an re-ordered doublevector
see paramentes for "read_map"
Definition at line 745 of file g_raster2plvector.c.
References free_doublematrix(), get_doublevector_from_doublematrix(), read_map(), and T_INIT::V.
Referenced by get_dirichletsnode(), get_sources(), and main().
int write_raster_from_doublevector | ( | char * | filename, |
DOUBLEVECTOR * | v, | ||
T_INIT * | UVref, | ||
LONGMATRIX * | indices, | ||
DOUBLEMATRIX * | Mref | ||
) |
filename | (char *) name of the file |
v | - (DOUBLECTOR *) - vecto to be mapped |
UVref | - (T_INIT *) T_IIT struct containg ewres and nwres information |
indices | (LONGVECTOR *) - matrix of indices |
Mref | - (DOUBLEMATRIX *) - reference raster |
it writes a map from a vector using get_doublematrix_from_doublevecto and write_map (This function does not take into account the NOVALUE!!!)
Definition at line 775 of file g_raster2plvector.c.
References FLOATING_POINT_TYPE, free_doublematrix(), get_doublematrix_from_doublevector(), MAP_FORMAT, T_INIT::V, and write_map().
Referenced by write_map_results().