1.4.1
CCC
 
dbtools.cpp File Reference
#include "geoslib_define.h"
#include "geoslib_old_f.h"
#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 "Covariances/CovAniso.hpp"
#include "Model/Model.hpp"
#include "Model/CovInternal.hpp"
#include "Db/Db.hpp"
#include "Db/DbGrid.hpp"
#include "Db/DbHelper.hpp"
#include "Basic/Law.hpp"
#include "Basic/NamingConvention.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/String.hpp"
#include "Basic/VectorHelper.hpp"
#include "Basic/Grid.hpp"
#include "Basic/PolyLine2D.hpp"
#include "Polygon/Polygons.hpp"
#include "Tree/Ball.hpp"
#include "Basic/Memory.hpp"
#include "Core/Keypair.hpp"
#include "Core/io.hpp"
#include <math.h>
#include <string.h>

Functions

int surface (Db *db_point, DbGrid *db_grid, int, double dlim, double *dtab, double *gtab)
 
static void st_edit_display (Db *db, int nrdv, int nrds, int ivar, int iech)
 
static int st_edit_find (Db *db, int iech, int ivar, int orient, double vmin, double vmax)
 
static int st_edit_ask (int *item, int *rank, double *vmin, double *vmax)
 
int db_edit (Db *db, int *flag_valid)
 
void ut_trace_discretize (int nseg, const 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, const double *xp, const double *yp, const double *dd, double radius, int *ns_arg, double **xs_arg, double **ys_arg, int **rks_arg, int **lys_arg, int **typ_arg)
 
static VectorDouble st_point_init_homogeneous (int number, const VectorDouble &coormin, const VectorDouble &coormax, bool flag_repulsion, double range, double beta)
 
static VectorDouble st_point_init_inhomogeneous (int number, DbGrid *dbgrid, bool flag_repulsion, double range, double beta)
 
int db_resind (Db *db, int ivar, const VectorDouble &zcut)
 
static void st_gradient_normalize (Db *dbgrid)
 
int db_gradient_components (DbGrid *dbgrid)
 
static int st_is_undefined (Db *dbgrid, int iptr_grad, int iech)
 
static int st_is_zero (Db *dbgrid, int iptr_grad, int iech)
 
static int st_get_next (DbGrid *dbgrid, int iptr_grad, VectorDouble &coor, int *knd, double *surf)
 
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_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, const 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, bool flagAddSampleRank)
 
int db_proportion_estimate (Db *dbin, DbGrid *dbout, Model *model, int niter, bool verbose, const NamingConvention &namconv)
 

Function Documentation

◆ db_edit()

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'

◆ db_gradient_components()

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)

◆ db_grid2point_sampling()

int db_grid2point_sampling ( DbGrid dbgrid,
int  nvar,
int *  vars,
const 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

◆ db_point_init()

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,
bool  flagAddSampleRank 
)

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]flagAddSampleRanktrue if the Rank must be generated in the output Db
Remarks
Arguments 'extend' is only valid when 'dbgrid' is not defined

◆ db_proportion_estimate()

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_regularize()

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

◆ db_resind()

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

◆ db_smooth_vpc()

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

◆ db_streamline()

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

◆ st_edit_ask()

static int st_edit_ask ( int *  item,
int *  rank,
double *  vmin,
double *  vmax 
)
static

Ask for the next keyword in the Editor

Returns
Return code:
0 : A valid keyword has been found
1 : The 'stop' has been met
-1 : The 'quit' has been met
Parameters
[out]itemSelected item
[out]rankValue for the Shift
[out]vminValue for the lower bound
[out]vmaxValue for the upper bound

◆ st_edit_display()

static void st_edit_display ( Db db,
int  nrdv,
int  nrds,
int  ivar,
int  iech 
)
static

Print the Db contents

Parameters
[in]dbDb descriptor
[in]nrdvRadius of the variable display
[in]nrdsRadius of the sample display
[in]ivarRank of the Target Variable
[in]iechRank of the Target Sample

◆ st_edit_find()

static int st_edit_find ( Db db,
int  iech,
int  ivar,
int  orient,
double  vmin,
double  vmax 
)
static

Look for the next sample with a value within the interval

Returns
Rank of the next sample
Parameters
[in]dbDb descriptor
[in]iechRank of the current sample
[in]ivarRank of the current variable
[in]orientOrientation (1: downwards; -1: forwards)
[in]vminMinimum value
[in]vmaxMaximum value

◆ st_get_next()

static int st_get_next ( DbGrid dbgrid,
int  iptr_grad,
VectorDouble coor,
int *  knd,
double *  surf 
)
static

Get the next gradient-based data

Returns
1 Error return code
Parameters
[in]dbgridDb structure (grid organized)
[in]iptr_gradRank of the first gradient component
[in]coorArray of coordinates
[out]kndAbsolute index
[out]surfLocal value of the surface

◆ st_gradient_normalize()

static void st_gradient_normalize ( Db dbgrid)
static

Normalize the gradient components

Parameters
[in]dbgridDb structure (grid organized)

◆ st_is_undefined()

static int st_is_undefined ( Db dbgrid,
int  iptr_grad,
int  iech 
)
static

Check if one (at least) of the gradient components is undefined

Returns
1 If one component (at least) is undefined
Parameters
[in]dbgridDb structure (grid organized)
[in]iptr_gradRank of the first gradient component
[in]iechSample rank

◆ st_is_zero()

static int st_is_zero ( Db dbgrid,
int  iptr_grad,
int  iech 
)
static

Check if the gradient is null

Returns
1 If gradient is null
Parameters
[in]dbgridDb structure (grid organized)
[in]iptr_gradRank of the first gradient component
[in]iechSample rank

◆ st_point_init_homogeneous()

static VectorDouble st_point_init_homogeneous ( int  number,
const VectorDouble coormin,
const VectorDouble coormax,
bool  flag_repulsion,
double  range,
double  beta 
)
static

Create a set of samples according to a Poisson process

Returns
Array of returned values (or NULL)
Parameters
[in]numberNumber of samples to be generated
[in]coorminVector of minimum coordinates
[in]coormaxVector of maximum coordinates
[in]flag_repulsionTrue if the repulsion process is active
[in]rangeRepulsion range
[in]betaRepulsion beta coefficient

◆ st_point_init_inhomogeneous()

static VectorDouble st_point_init_inhomogeneous ( int  number,
DbGrid dbgrid,
bool  flag_repulsion,
double  range,
double  beta 
)
static

Create a set of samples according to a Poisson Regionalized process

Returns
Array of returned values (or NULL)
Parameters
[in]numberNumber of samples to be generated
[in]dbgridDescriptor of the Db grid parameters
[in]flag_repulsionTrue if the repulsion process is active
[in]rangeRepulsion range
[in]betaRepulsion beta coefficient
Remarks
Thinning can only be defined in 2-D.
If the thinning is regionalized, its parameters are stored
as NOSTAT variables: Range-1, Range-2 and Angle

◆ surface()

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)

◆ ut_trace_discretize()

void ut_trace_discretize ( int  nseg,
const 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

◆ ut_trace_sample()

void ut_trace_sample ( Db db,
const ELoc &  ptype,
int  np,
const double *  xp,
const double *  yp,
const 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