1.1.0
CCC
 
dbtools.cpp File Reference
#include "geoslib_f.h"
#include "geoslib_old_f.h"
#include "geoslib_f_private.h"
#include "Enum/EJustify.hpp"
#include "Mesh/MeshETurbo.hpp"
#include "LinearOp/ShiftOpCs.hpp"
#include "LinearOp/PrecisionOp.hpp"
#include "LinearOp/ProjMatrix.hpp"
#include "LinearOp/OptimCostColored.hpp"
#include "Stats/Classical.hpp"
#include "Morpho/Morpho.hpp"
#include "Covariances/CovAniso.hpp"
#include "Model/ANoStat.hpp"
#include "Model/NoStatArray.hpp"
#include "Model/Model.hpp"
#include "Model/CovInternal.hpp"
#include "Db/Db.hpp"
#include "Db/DbHelper.hpp"
#include "Basic/Law.hpp"
#include "Basic/NamingConvention.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/String.hpp"
#include "Basic/File.hpp"
#include "Basic/VectorHelper.hpp"
#include "Basic/PolyLine2D.hpp"
#include "Basic/OptDbg.hpp"
#include "Polygon/Polygons.hpp"
#include "Skin/ISkinFunctions.hpp"
#include "Skin/Skin.hpp"
#include "Geometry/GeometryHelper.hpp"
#include "Tree/Ball.hpp"
#include "Tree/KNN.hpp"
#include <math.h>
#include <string.h>

Functions

int surface (Db *db_point, DbGrid *db_grid, int, double dlim, double *dtab, double *gtab)
 
int db_edit (Db *db, int *flag_valid)
 
void ut_trace_discretize (int nseg, double *trace, double disc, int *np_arg, double **xp_arg, double **yp_arg, double **dd_arg, double **del_arg, double *dist_arg)
 
void ut_trace_sample (Db *db, const ELoc &ptype, int np, double *xp, double *yp, double *dd, double radius, int *ns_arg, double **xs_arg, double **ys_arg, int **rks_arg, int **lys_arg, int **typ_arg)
 
int db_resind (Db *db, int ivar, const VectorDouble &zcut)
 
int db_gradient_components (DbGrid *dbgrid)
 
int db_streamline (DbGrid *dbgrid, Db *dbpoint, int niter, double step, int flag_norm, int use_grad, int save_grad, int *nbline_loc, int *npline_loc, double **line_loc)
 
int db_model_nostat (Db *db, Model *model, int icov, const NamingConvention &namconv)
 
int db_smooth_vpc (DbGrid *db, int width, double range)
 
Dbdb_regularize (Db *db, DbGrid *dbgrid, int flag_center)
 
int db_grid2point_sampling (DbGrid *dbgrid, int nvar, int *vars, int *npacks, int npcell, int nmini, int *nech_ret, double **coor_ret, double **data_ret)
 
Dbdb_point_init (int nech, const VectorDouble &coormin, const VectorDouble &coormax, DbGrid *dbgrid, bool flag_exact, bool flag_repulsion, double range, double beta, double extend, int seed, int flag_add_rank)
 
int db_proportion_estimate (Db *dbin, DbGrid *dbout, Model *model, int niter, bool verbose, const NamingConvention &namconv)
 

Function Documentation

int db_edit ( Db db,
int *  flag_valid 
)

Edit the Data Base Db

Returns
Error return code
Parameters
[in]dbDb descriptor
[out]flag_valid1 for 'stop' and 0 for 'quit'
int db_gradient_components ( DbGrid dbgrid)

Calculate the gradient over a grid

Returns
Rank of the newly created variables (or -1)
Parameters
[in]dbgridDb structure (grid organized)
int db_grid2point_sampling ( DbGrid dbgrid,
int  nvar,
int *  vars,
int *  npacks,
int  npcell,
int  nmini,
int *  nech_ret,
double **  coor_ret,
double **  data_ret 
)

Sampling a fine grid in a coarser set of cells

Returns
Error returned code
Parameters
[in]dbgridreference Grid
[in]nvarNumber of variables
[in]varsArray of variable ranks
[in]npacksVector of packing factors
[in]npcellNumber of samples per cell
[in]nminiMinimum number of nodes before drawing
[out]nech_retNumber of selected samples
[out]coor_retArray of coordinates
[out]data_retArray of variables
Remarks
The returned arrays 'coor' and 'data' must be freed by
the calling function
int db_model_nostat ( Db db,
Model model,
int  icov,
const NamingConvention namconv 
)

Calculate and store new variables in the Db which contain the non-stationary Model component

Returns
Distance value
Parameters
[in]dbDb structure
[in]modelModel structure
[in]icovRank of the Basic structure
[in]namconvNaming convention
Remarks
This procedure automatically creates several fields:
ndim fields for storing the ranges
ndim fields for storing the angles
1 field for storing the sill
Db* db_point_init ( int  nech,
const VectorDouble coormin,
const VectorDouble coormax,
DbGrid dbgrid,
bool  flag_exact,
bool  flag_repulsion,
double  range,
double  beta,
double  extend,
int  seed,
int  flag_add_rank 
)

Create a new Data Base with points generated at random

Returns
Pointer for the new Db structure
Parameters
[in]nechExpected number of samples
[in]coorminVector of lower coordinates
[in]coormaxVector of upper coordinates
[in]dbgridDescriptor of the Db grid parameters
[in]flag_exactTrue if the number of samples is dran from Poisson
[in]flag_repulsionUse repulsion (need: 'range' and 'beta')
[in]rangeRepulsion range
[in]betaBending coefficient
[in]extendExtension of the bounding box (when positive)
[in]seedSeed for the random number generator
[in]flag_add_rank1 if the Rank must be generated in the output Db
Remarks
Arguments 'extend' is only valid when 'dbgrid' is not defined
int db_proportion_estimate ( Db dbin,
DbGrid dbout,
Model model,
int  niter,
bool  verbose,
const NamingConvention namconv 
)

Standard Kriging

Returns
Error return code
Parameters
[in]dbinInput Db structure
[in]dboutOutput Db structure
[in]modelModel structure
[in]niterNumber of iterations
[in]verboseVerbose flag
[in]namconvNaming convention
Remarks
The procedure uses the FIRST covariance of the Model
to describe the spatial structure
Db* db_regularize ( Db db,
DbGrid dbgrid,
int  flag_center 
)

Regularize variables along vertical wells

Returns
Pointer to the newly created Db
Parameters
[in]dbInitial Db
[in]dbgridReference Grid
[in]flag_centerWhen TRUE, the sample is centered in the layer to which it belongs
Remarks
This function requires the input well ('db') and the grid to be
defined in space >= 3D
It requires a CODE variable to be defined in the input 'db'
This function regularizes all the variables marked with a Z-locator
This function takes a sample into account only if isotopic
int db_resind ( Db db,
int  ivar,
const VectorDouble zcut 
)

Create indicator residual variables

Returns
Error returned code
Parameters
[in]dbDb structure
[in]ivarIndex of the target variable
[in]zcutArray containing the cutoffs
Remarks
The array 'zcut' must be provided in increasing order
int db_smooth_vpc ( DbGrid db,
int  width,
double  range 
)

Smooth out the VPC

Returns
Distance value
Parameters
[in]db3-D Db structure containing the VPCs
[in]widthWidth of the Filter
[in]rangeRange of the Gaussian Weighting Function
Remarks
Work is performed IN PLACE
int db_streamline ( DbGrid dbgrid,
Db dbpoint,
int  niter,
double  step,
int  flag_norm,
int  use_grad,
int  save_grad,
int *  nbline_loc,
int *  npline_loc,
double **  line_loc 
)

Calculate the streamlines

Returns
Error return code
Parameters
[in]dbgridDb structure (grid organized)
[in]dbpointDb structure for control points
[in]niterMaximum number of iterations
[in]stepProgress step
[in]flag_norm1 if the gradients must be normalized
[in]use_grad1 if the existing gradients must be used 0 the gradients must be calculated here
[in]save_grad1 save the gradients generated in this function 0 delete gradients when calculated here
[out]nbline_locNumber of streamline steps
[out]npline_locNumber of values per line vertex
[out]line_locArray of streamline steps (Dimension: 5 * nbline)
Remarks
The returned array 'line_loc' must be freed by the calling function
Use get_keypone("Streamline_Skip",1) to define the skipping ratio
int surface ( Db db_point,
DbGrid db_grid,
int  ,
double  dlim,
double *  dtab,
double *  gtab 
)

Calculate the (discretized) surface of influence

Returns
Error returned code
Parameters
[in]db_pointDb containing the data points
[in]db_gridDb containing the discretization grid
[in]dlimMaximum distance (TEST if not defined)
[out]dtabArray containing the surface of influence (Dimension = Number of samples in db_point)
[out]gtabArray containing the surface of influence of the polygon to which it belongs (or TEST) (Dimension = Number of samples in db_grid)
void ut_trace_discretize ( int  nseg,
double *  trace,
double  disc,
int *  np_arg,
double **  xp_arg,
double **  yp_arg,
double **  dd_arg,
double **  del_arg,
double *  dist_arg 
)

Generates the discretized points along the trace

Parameters
[in]nsegNumber of vertices along the trace
[in]traceArray defining the trace (Dimension: 2 * nseg)
[in]discDiscretization distance
[out]np_argNumber of discretized points
[out]xp_argArray of first coordinates
[out]yp_argArray of second coordinates
[out]dd_argArray of distances between discretized points
[out]del_argArray of distances between vertices
[out]dist_argTotal distance of the trace
void ut_trace_sample ( Db db,
const ELoc &  ptype,
int  np,
double *  xp,
double *  yp,
double *  dd,
double  radius,
int *  ns_arg,
double **  xs_arg,
double **  ys_arg,
int **  rks_arg,
int **  lys_arg,
int **  typ_arg 
)

Sample the point Db close to discretized points of the trace

Parameters
[in]dbDb to be sampled
[in]ptypeType of locator
[in]npNumber of discretized points
[in]xpArray of first coordinates
[in]ypArray of second coordinates
[in]ddArray of distances
[in]radiusNeighborhood radius
[out]ns_argNumber of sampled points
[out]xs_argArray of first coordinates of sampled points
[out]ys_argArray of second coordinates of sampled points
[out]rks_argArray of sample indices (starting from 1)
[out]lys_argArray of layer indices of sampled points
[out]typ_argArray of data type 1 for hard data in Z or TIME 2 for lower bound 3 for upper bound