1.4.0
CCC
 
potential.cpp File Reference
#include "geoslib_old_f.h"
#include "Basic/Utilities.hpp"
#include "Basic/Law.hpp"
#include "Basic/OptDbg.hpp"
#include "Core/Potential.hpp"
#include "Covariances/CovAniso.hpp"
#include "Covariances/CovLMGradient.hpp"
#include "Drifts/DriftList.hpp"
#include "Db/Db.hpp"
#include "Db/DbGrid.hpp"
#include "Db/DbHelper.hpp"
#include "Model/Model.hpp"
#include "Neigh/ANeigh.hpp"
#include "Matrix/MatrixFactory.hpp"
#include "Simulation/CalcSimuTurningBands.hpp"
#include "Basic/Memory.hpp"
#include <math.h>
#include <string.h>

Functions

static void st_potenv_define (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, Db *dbout)
 
static int GRX (int i)
 
static int GRY (int i)
 
static int GRZ (int i)
 
static int TGT (int i)
 
static int ISC (int ic, int i)
 
static int IAD_GRD (int ig)
 
static void set_IAD_GRD (int ig, int value)
 
static int IAD_TGT (int it)
 
static void set_IAD_TGT (int it, int value)
 
static double IAD_ISO (int ic, int i)
 
static double TGT_COO (int it, int i)
 
static double TGT_VAL (int it, int idim)
 
static double GRD_COO (int ig, int idim)
 
static double GRD_VAL (int ig, int idim)
 
static double ISO_COO (int ic, int j, int idim)
 
static int EXT (int iext)
 
static int st_model_invalid (Model *model)
 
static void st_cov (Model *model, bool flag_grad, double dx, double dy, double dz, double &covar, VectorDouble &covGp, VectorDouble &covGG)
 
static int st_extdrift_create_db (DbGrid *dbout, Pot_Ext *pot_ext)
 
static int st_extdrift_create_model (Pot_Ext *pot_ext)
 
static MatrixRectangular st_extdrift_establish (Pot_Ext *pot_ext, int number)
 
static int st_extdrift_calc_init (DbGrid *dbout, Pot_Ext *pot_ext)
 
static int st_potext_manage (int mode, Pot_Ext *pot_ext, int nring, double range, DbGrid *dbout)
 
bool st_potenv_valid (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbout, Model *model, ANeigh *neigh)
 
static void st_potenv_manage (Pot_Env *pot_env, bool flag_pot, bool flag_grad, bool flag_trans, int opt_part, bool verbose)
 
static int st_update_isopot (Db *dbiso, Pot_Env *pot_env)
 
static int st_update_gradient (Db *dbgrd, Pot_Env *pot_env)
 
static int st_update_tangent (Db *dbtgt, Pot_Env *pot_env)
 
static int st_update_model (Model *model, Pot_Env *pot_env)
 
static int st_update_final (Model *model, Pot_Env *pot_env)
 
static double setMatUV (int ndim, double ux, double uy, double uz, double vx, double vy, double vz)
 
static double setMatUAV (int ndim, const double *a, double ux, double uy, double uz, double vx, double vy, double vz)
 
static void setRhs (MatrixRectangular &rhs, int i, int isol, double value)
 
static void setLhs (MatrixSquareSymmetric &lhs, int i, int j, double value)
 
static double getLhs (MatrixSquareSymmetric &lhs, int i, int j)
 
static int st_extdrift_neigh (DbGrid *dbgrid, Pot_Ext *pot_ext)
 
static int st_extdrift_eval (const char *target, double x0, double y0, double z0, DbGrid *dbgrid, Pot_Ext *pot_ext, double *extval, VectorDouble &extgrd)
 
static int st_build_lhs (Pot_Env *pot_env, Pot_Ext *pot_ext, DbGrid *dbout, Model *model, double nugget_grd, double nugget_tgt, MatrixSquareSymmetric &lhs)
 
static void st_fill_dual (Pot_Env *pot_env, VectorDouble &zval)
 
static void st_fill_dual_simulation (Pot_Env *pot_env, Db *dbiso, Db *dbgrd, Db *dbtgt, int nbsimu, MatrixRectangular &zvals)
 
static void st_rhs_part (Pot_Env *pot_env, MatrixRectangular &rhs)
 
static void st_build_rhs (Pot_Env *pot_env, Pot_Ext *pot_ext, bool flag_grad, DbGrid *dbgrid, Model *model, VectorDouble &coor, MatrixRectangular &rhs)
 
static void st_calc_point (Pot_Env *pot_env, Pot_Ext *pot_ext, bool flag_grad, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbgrid, Model *model, VectorDouble &zdual, MatrixRectangular &rhs, Db *db_target, int iech0, VectorDouble &result)
 
static void st_potential_to_layer (Pot_Env *pot_env, int isimu, const double *potval, VectorDouble &result)
 
static void st_estimate_result (Pot_Env *pot_env, Pot_Ext *pot_ext, bool flag_grad, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbout, Model *model, double refpot, VectorDouble &zdual, MatrixRectangular &rhs, double *potval)
 
static void st_estimate_data (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbout, Model *model, double refpot, VectorDouble &zdual, MatrixRectangular &rhs, Db *db_target, VectorInt &uid_pot, VectorInt &uid_grad)
 
static void st_dist_convert (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, Model *model, int ic0, int j0, VectorDouble &zval, MatrixSquareSymmetric &lhs_orig_arg, MatrixRectangular &rhs_arg, double *dist_euc, double *dist_geo)
 
static void st_xvalid_potential (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, Model *model, MatrixSquareSymmetric &lhs, bool flag_dist_conv, VectorDouble &zval, MatrixSquareSymmetric &lhs_orig, MatrixRectangular &rhs, VectorDouble &zdual)
 
static void st_tempere (DbGrid *dbout, int iech, double dist_tempere, double reskrige, VectorDouble &result)
 
static void st_simcond (Pot_Env *pot_env, Pot_Ext *pot_ext, double dist_tempere, bool flag_trans, int nbsimu, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbout, Model *model, double refpot, double *potsim, VectorDouble &zdual, MatrixRectangular &zduals, MatrixRectangular &rhs)
 
static void st_print_result (Pot_Env *pot_env, int isimu, double *result, double tgtval)
 
static void st_check_data (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbgrid, Model *model, int isimu, int nbsimu, double refpot, VectorDouble &zdual, MatrixRectangular &rhs)
 
static double st_evaluate_refpot (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbgrid, Model *model, VectorDouble &zdual, MatrixRectangular &rhs)
 
static void st_evaluate_potval (Pot_Env *pot_env, Pot_Ext *pot_ext, Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbgrid, Model *model, double refpot, int isimu, int nbsimu, VectorDouble &zdual, MatrixRectangular &rhs, double *potval)
 
static void st_save_result_on_data (Pot_Env *pot_env, Db *db, int nvar, double value, const ELoc &loctype_pot, const ELoc &loctype_grad, VectorInt &uid_pot, VectorInt &uid_grad)
 
int potential_kriging (Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbout, Model *model, ANeigh *neigh, double nugget_grd, double nugget_tgt, bool flag_pot, bool flag_grad, bool flag_trans, bool flag_save_data, int opt_part, bool verbose)
 
static int st_distance_to_isoline (DbGrid *dbout)
 
int potential_simulate (Db *dbiso, Db *dbgrd, Db *dbtgt, DbGrid *dbout, Model *model, ANeigh *neigh, double nugget_grd, double nugget_tgt, double dist_tempere, bool flag_trans, int seed, int nbsimu, int nbtuba, bool verbose)
 
int potential_xvalid (Db *dbiso, Db *dbgrd, Db *dbtgt, Model *model, ANeigh *neigh, double nugget_grd, double nugget_tgt, bool flag_dist_conv, bool verbose)
 
static void st_print_type (int rank, int type)
 
int potential_cov (Model *model, bool verbose, int type1, const VectorDouble &x10, const VectorDouble &x1p, const VectorDouble &tx1, int type2, const VectorDouble &x20, const VectorDouble &x2p, const VectorDouble &tx2, VectorDouble &covtab)
 

Function Documentation

◆ EXT()

static int EXT ( int  iext)
static

◆ getLhs()

static double getLhs ( MatrixSquareSymmetric lhs,
int  i,
int  j 
)
static

Get one element from the Kriging L.H.S. matrix

Returns
The returned value
Parameters
[in]lhsMatrix to be filled
[in]iRow number
[in]jColumn number

◆ GRD_COO()

static double GRD_COO ( int  ig,
int  idim 
)
static

◆ GRD_VAL()

static double GRD_VAL ( int  ig,
int  idim 
)
static

◆ GRX()

static int GRX ( int  i)
static

◆ GRY()

static int GRY ( int  i)
static

◆ GRZ()

static int GRZ ( int  i)
static

◆ IAD_GRD()

static int IAD_GRD ( int  ig)
static

◆ IAD_ISO()

static double IAD_ISO ( int  ic,
int  i 
)
static

◆ IAD_TGT()

static int IAD_TGT ( int  it)
static

◆ ISC()

static int ISC ( int  ic,
int  i 
)
static

◆ ISO_COO()

static double ISO_COO ( int  ic,
int  j,
int  idim 
)
static

◆ potential_cov()

int potential_cov ( Model model,
bool  verbose,
int  type1,
const VectorDouble x10,
const VectorDouble x1p,
const VectorDouble tx1,
int  type2,
const VectorDouble x20,
const VectorDouble x2p,
const VectorDouble tx2,
VectorDouble covtab 
)

Potential covariance

Returns
Error return code
Parameters
[in]modelModel structure
[in]verboseVerbose flag
[in]type1Type of the first point 1 for gradient; 2 for tangent; 3 for isopotential
[in]x10Coordinates of the centering for first point
[in]x1pCoordinates of the first point
[in]tx1Tangent values at the first point
[in]type2Type of the second point 1 for gradient; 2 for tangent; 3 for isopotential (Sign is negative for target point)
[in]x20Coordinates of the centering for second point
[in]x2pCoordinates of the second point
[in]tx2Tangent values at the second point
[out]covtabArray of returned values (dimensionned to ndim*ndim)

◆ potential_kriging()

int potential_kriging ( Db dbiso,
Db dbgrd,
Db dbtgt,
DbGrid dbout,
Model model,
ANeigh neigh,
double  nugget_grd,
double  nugget_tgt,
bool  flag_pot,
bool  flag_grad,
bool  flag_trans,
bool  flag_save_data,
int  opt_part,
bool  verbose 
)

Potential estimation

Returns
Error return code
Parameters
[in]dbisoIso-potential Db structure
[in]dbgrdGradient Db structure
[in]dbtgtTangent Db structure (optional)
[in]dboutOutput Db structure
[in]modelModel structure
[in]neighANeigh structure
[in]nugget_grdNugget effect for Gradients
[in]nugget_tgtNugget effect for Tangents
[in]flag_potTrue if the Potential must be estimated
[in]flag_gradTrue if the gradient must also be estimated
[in]flag_transTrue if the estimation result must be translated into layer number
[in]flag_save_dataTrue if the Potential / Gradient must be saved on any Information file
[in]opt_partOption to exhibit only a part of estimation:
  • 0 : the whole estimation
  • 1 : the gradient contribution only
  • 2 : the tangent contribution only
  • 3 : the isovalues contribution only
  • 4 : the drift contribution only
  • 5 : the external drift contribution only
[in]verboseVerbose option
Remarks
The results will be stored in the dbout file
- the estimation in the variable ELoc::Z
- the gradient components in the variables ELoc::GRD

◆ potential_simulate()

int potential_simulate ( Db dbiso,
Db dbgrd,
Db dbtgt,
DbGrid dbout,
Model model,
ANeigh neigh,
double  nugget_grd,
double  nugget_tgt,
double  dist_tempere,
bool  flag_trans,
int  seed,
int  nbsimu,
int  nbtuba,
bool  verbose 
)

Potential simulations

Returns
Error return code
Parameters
[in]dbisoIso-potential Db structure
[in]dbgrdGradient Db structure
[in]dbtgtTangent Db structure (optional)
[in]dboutOutput Db structure
[in]modelModel structure
[in]neighANeigh structure
[in]nugget_grdNugget effect for Gradients
[in]nugget_tgtNugget effect for Tangents
[in]dist_tempereDistance for tempering simulations (or TEST)
[in]flag_transTrue if the estimation result must be translated into layer number
[in]seedSeed for the random number generator
[in]nbsimuNumber of simulations
[in]nbtubaNumber of turning bands
[in]verboseVerbose option
Remarks
The simulations will be stored in the dbout file (ELoc::SIMU)

◆ potential_xvalid()

int potential_xvalid ( Db dbiso,
Db dbgrd,
Db dbtgt,
Model model,
ANeigh neigh,
double  nugget_grd,
double  nugget_tgt,
bool  flag_dist_conv,
bool  verbose 
)

Potential cross-validation

Returns
Error return code
Parameters
[in]dbisoIso-potential Db structure
[in]dbgrdGradient Db structure
[in]dbtgtTangent Db structure (optional)
[in]modelModel structure
[in]neighANeigh structure
[in]nugget_grdNugget effect for Gradients
[in]nugget_tgtNugget effect for Tangents
[in]flag_dist_convFlag for converting into distance
[in]verboseVerbose option

◆ set_IAD_GRD()

static void set_IAD_GRD ( int  ig,
int  value 
)
static

◆ set_IAD_TGT()

static void set_IAD_TGT ( int  it,
int  value 
)
static

◆ setLhs()

static void setLhs ( MatrixSquareSymmetric lhs,
int  i,
int  j,
double  value 
)
static

Set and element in the Kriging L.H.S. matrix

Parameters
[in]lhsMatrix to be filled
[in]iRow number
[in]jColumn number
[in]valueValue to be assigned to this cell

◆ setMatUAV()

static double setMatUAV ( int  ndim,
const double *  a,
double  ux,
double  uy,
double  uz,
double  vx,
double  vy,
double  vz 
)
static

Calculate the norm product of two vectors by a matrix

Parameters
[in]ndim: Space dimension
[in]a: Matrix
[in]ux: First coordinate of the first vector
[in]uy: Second coordinate of the first vector
[in]uz: Third coordinate of the first vector
[in]vx: First coordinate of the second vector
[in]vy: Second coordinate of the second vector
[in]vz: Third coordinate of the second vector

◆ setMatUV()

static double setMatUV ( int  ndim,
double  ux,
double  uy,
double  uz,
double  vx,
double  vy,
double  vz 
)
static

Calculate the inner product of two vectors

Parameters
[in]ndim: Space dimension
[in]ux: First coordinate of the first vector
[in]uy: Second coordinate of the first vector
[in]uz: Third coordinate of the first vector
[in]vx: First coordinate of the second vector
[in]vy: Second coordinate of the second vector
[in]vz: Third coordinate of the second vector

◆ setRhs()

static void setRhs ( MatrixRectangular rhs,
int  i,
int  isol,
double  value 
)
static

Set and element in the Kriging R.H.S. vector

Parameters
[in]rhsVector to be filled
[in]iRow number
[in]isolColumn number
[in]valueValue to be assigned to this cell

◆ st_build_lhs()

static int st_build_lhs ( Pot_Env *  pot_env,
Pot_Ext *  pot_ext,
DbGrid dbout,
Model model,
double  nugget_grd,
double  nugget_tgt,
MatrixSquareSymmetric lhs 
)
static

Establish the cokriging system

Returns
Error return code
Parameters
[in]pot_envPot_Env structure
[in]pot_extPot_Ext structure
[in]dboutTarget Db structure (only used for external drift)
[in]modelModel structure
[in]nugget_grdNugget effect for Gradients
[in]nugget_tgtNugget effect for Tangents
[out]lhsCokriging matrix
Remarks
Organization of the cokriging system
| A11 = | A12 = | A13 = | F1 = |
| <Gu(i),Gv(i')> | <Gu(i) ,(T,G)> | <Gu(i),Pl(j)-Pl(0)> | G(Fl) |
--------------------------------------------------------------—
| A21 = | A22 = | A23 = | F2 = |
| <(T,G),Gv(i') | <(T,G) ,(T,G)> | <(T,G),Pl(j)-Pl(0)> | (T,Fl)|
--------------------------------------------------------------—
| A31 = | A32 = | A33 = | F3 = |
| <Pl(i)-Pl(0),G>| <Pli-Pl0,(T,g)>| <Pli-Pl0,Pl'i-Pl'0> |Fli-Fl0|
--------------------------------------------------------------—
| F1t | F2t | F3t | 0 |
The matrix A11 is subdivided as follows:
| <Gx,Gx> | <Gx,Gy> | <Gx,Gz> |
| | | |
A11 = | <Gy,Gx> | <Gy,Gy> | .... |
| | | |
| <Gz,Gx> | ... | .. |
each one of the 9 blocks has dimension = the number of gradients

◆ st_build_rhs()

static void st_build_rhs ( Pot_Env *  pot_env,
Pot_Ext *  pot_ext,
bool  flag_grad,
DbGrid dbgrid,
Model model,
VectorDouble coor,
MatrixRectangular rhs 
)
static

Calculate the estimation and gradient components at one target location

Parameters
[in]pot_envPot_Env structure
[in]pot_extPot_Ext structure
[in]flag_gradTrue if the gradients must also be calculated
[in]dbgridOutput Grid Db structure (for External Drift)
[in]modelModel structure
[in]coorCoordinates of the target
[out]rhsR.H.S. vector (Dimension: nequa * 4)

◆ st_calc_point()

static void st_calc_point ( Pot_Env *  pot_env,
Pot_Ext *  pot_ext,
bool  flag_grad,
Db dbiso,
Db dbgrd,
Db dbtgt,
DbGrid dbgrid,
Model model,
VectorDouble zdual,
MatrixRectangular rhs,
Db db_target,
int  iech0,
VectorDouble result 
)
static

Calculate the estimation and gradient components at one target

Parameters
[in]pot_envPot_Env structure
[in]pot_extPot_Ext structure
[in]flag_gradTrue if the gradients must also be calculated
[in]dbisoIso-potential Db structure (not used)
[in]dbgrdGradient Db structure (not used)
[in]dbtgtTangent Db structure (not used)
[in]dbgridOutput Db structure (for Ext Drift)
[in]modelModel structure
[in]zdualDual vector (Dimension: nequa)
[in]rhsR.H.S. vector (Dimension: nequa * 4)
[in]db_targetDb corresponding to the target
[in]iech0Rank of the target sample
[out]resultArray of results (Dimension: nsol)

◆ st_check_data()

static void st_check_data ( Pot_Env *  pot_env,
Pot_Ext *  pot_ext,
Db dbiso,
Db dbgrd,
Db dbtgt,
DbGrid dbgrid,
Model model,
int  isimu,
int  nbsimu,
double  refpot,
VectorDouble zdual,
MatrixRectangular rhs 
)
static

Calculate the estimation and gradient components at data information

Parameters
[in]pot_envPot_Env structure
[in]pot_extPot_Ext structure
[in]dbisoIso-potential Db structure
[in]dbgrdGradient Db structure
[in]dbtgtTangent Db structure (optional)
[in]dbgridOutput Db structure (for External drift)
[in]modelModel structure
[in]isimuRank of the simulation (or -1)
[in]nbsimuNumber of simulations
[in]refpotPotential at Reference point
[in]zdualDual vector (Dimension: nequa)
[in]rhsR.H.S. vector (Dimension: nequa * 4)

◆ st_cov()

static void st_cov ( Model model,
bool  flag_grad,
double  dx,
double  dy,
double  dz,
double &  covar,
VectorDouble covGp,
VectorDouble covGG 
)
static

Calculate the covariance and the derivatives

Parameters
[in]modelModel structure
[in]flag_gradTrue if the Gradients must be calculated
[in]dxIncrement along X
[in]dyIncrement along Y
[in]dzIncrement along Z
[out]covarCovariance of potential
[out]covGpCovariance between potential and gradient
[out]covGGCovariance between gradient and gradient

◆ st_dist_convert()

static void st_dist_convert ( Pot_Env *  pot_env,
Pot_Ext *  pot_ext,
Db dbiso,
Db dbgrd,
Db dbtgt,
Model model,
int  ic0,
int  j0,
VectorDouble zval,
MatrixSquareSymmetric lhs_orig_arg,
MatrixRectangular rhs_arg,
double *  dist_euc,
double *  dist_geo 
)
static

Calculate the cross-validation at the iso-potential samples

Parameters
[in]pot_envPot_Env structure
[in]pot_extPot_Ext structure
[in]dbisoIso-potential Db structure (not used)
[in]dbgrdGradient Db structure (not used)
[in]dbtgtTangent Db structure (not used)
[in]modelModel structure
[in]ic0Rank of the isoline
[in]j0Rank of the sample within this isoline
[in]zvalData vector
[in]lhs_orig_argCopy of the initial LHS (non inverted)
[in]rhs_argRight-hand side
[out]dist_eucError converted into Euclidean distance
[out]dist_geoError converted into along surface distance
Remarks
We assume that the new data set (with one sample OFF) is still
contained in 'zval' as the Gradient information (coming first in
this vector) is never excluded.

◆ st_distance_to_isoline()

static int st_distance_to_isoline ( DbGrid dbout)
static

Transform the Estimation variable into a distance to the isoline

Returns
Error return code
Parameters
[in]dboutOutput Db structure

◆ st_estimate_data()

static void st_estimate_data ( Pot_Env *  pot_env,
Pot_Ext *  pot_ext,
Db dbiso,
Db dbgrd,
Db dbtgt,
DbGrid dbout,
Model model,
double  refpot,
VectorDouble zdual,
MatrixRectangular rhs,
Db db_target,
VectorInt uid_pot,
VectorInt uid_grad 
)
static

◆ st_estimate_result()

static void st_estimate_result ( Pot_Env *  pot_env,
Pot_Ext *  pot_ext,
bool  flag_grad,
Db dbiso,
Db dbgrd,
Db dbtgt,
DbGrid dbout,
Model model,
double  refpot,
VectorDouble zdual,
MatrixRectangular rhs,
double *  potval 
)
static

Calculate the estimation and/or gradient components at target samples

Parameters
[in]pot_envPot_Env structure
[in]pot_extPot_Ext structure
[in]flag_gradTrue if the gradients must also be calculated
[in]dbisoIso-potential Db structure
[in]dbgrdGradient Db structure
[in]dbtgtTangent Db structure (optional)
[in]dboutOutput Db structure
[in]modelModel structure
[in]refpotPotential at Reference point
[in]zdualDual vector (Dimension: nequa)
[in]rhsR.H.S. vector (Dimension: nequa * 4)
[in]potvalPotential values at iso-potential samples

◆ st_evaluate_potval()

static void st_evaluate_potval ( Pot_Env *  pot_env,
Pot_Ext *  pot_ext,
Db dbiso,
Db dbgrd,
Db dbtgt,
DbGrid dbgrid,
Model model,
double  refpot,
int  isimu,
int  nbsimu,
VectorDouble zdual,
MatrixRectangular rhs,
double *  potval 
)
static

Calculate the estimation at the iso-potential samples

Parameters
[in]pot_envPot_Env structure
[in]pot_extPot_Ext structure
[in]dbisoIso-potential Db structure
[in]dbgrdGradient Db structure
[in]dbtgtTangent Db structure (optional)
[in]dbgridOuput Db structure (for external drift)
[in]modelModel structure
[in]refpotPotential at Reference point
[in]isimuRank of the simulation (or -1)
[in]nbsimuNumber of simulations (or 0)
[in]zdualDual vector (Dimension: nequa)
[in]rhsR.H.S. vector (Dimension: nequa * 4)
[out]potvalArray of Potential values

◆ st_evaluate_refpot()

static double st_evaluate_refpot ( Pot_Env *  pot_env,
Pot_Ext *  pot_ext,
Db dbiso,
Db dbgrd,
Db dbtgt,
DbGrid dbgrid,
Model model,
VectorDouble zdual,
MatrixRectangular rhs 
)
static

Calculate the estimation at the potential at first point of first potential

Returns
The Potential value at first point of first iso-potential
Parameters
[in]pot_envPot_Env structure
[in]pot_extPot_Ext structure
[in]dbisoIso-potential Db structure
[in]dbgrdGradient Db structure
[in]dbtgtTangent Db structure (optional)
[in]dbgridOuput Db structure (for external drift)
[in]modelModel structure
[in]zdualDual vector (Dimension: nequa)
[in]rhsR.H.S. vector (Dimension: nequa * 4)

◆ st_extdrift_calc_init()

static int st_extdrift_calc_init ( DbGrid dbout,
Pot_Ext *  pot_ext 
)
static

Establish kriging system for calculating Gradient on External Drift

Returns
Error return code
Parameters
[in]dboutOutput Db structure
[out]pot_extPot_Ext structure

◆ st_extdrift_create_db()

static int st_extdrift_create_db ( DbGrid dbout,
Pot_Ext *  pot_ext 
)
static

Establish the neighborhood data Db file

Returns
Error return code
Parameters
[in]dboutOutput Db structure
[out]pot_extPot_Ext structure

◆ st_extdrift_create_model()

static int st_extdrift_create_model ( Pot_Ext *  pot_ext)
static

Establish the Model

Returns
Error return code
Parameters
[out]pot_extPot_Ext structure

◆ st_extdrift_establish()

static MatrixRectangular st_extdrift_establish ( Pot_Ext *  pot_ext,
int  number 
)
static

Establish kriging system

Returns
Teh right-hand side
Parameters
[out]pot_extPot_Ext structure
[out]numberMatrix dimension

◆ st_extdrift_eval()

static int st_extdrift_eval ( const char *  target,
double  x0,
double  y0,
double  z0,
DbGrid dbgrid,
Pot_Ext *  pot_ext,
double *  extval,
VectorDouble extgrd 
)
static

Calculate the external drift contribution

Returns
Error return code (target not within the grid or target on the
edge of the grid of external drift definition)
Parameters
[in]targetType of the target
[in]x0Coordinate along X
[in]y0Coordinate along Y
[in]z0Coordinate along Z
[in]dbgridOutput Db Grid structure
[in]pot_extPot_Ext structure
[out]extvalValue of the external drift
[out]extgrdGradient components of the external drift

◆ st_extdrift_neigh()

static int st_extdrift_neigh ( DbGrid dbgrid,
Pot_Ext *  pot_ext 
)
static

Establish the local neighborhood

Returns
Error return code (Neighborhood not complete)
Parameters
[in]dbgridOutput Db Grid structure
[in]pot_extPot_Ext structure

◆ st_fill_dual()

static void st_fill_dual ( Pot_Env *  pot_env,
VectorDouble zval 
)
static

Establish the data vector

Parameters
[in]pot_envPot_Env structure
[out]zvalData vector

◆ st_fill_dual_simulation()

static void st_fill_dual_simulation ( Pot_Env *  pot_env,
Db dbiso,
Db dbgrd,
Db dbtgt,
int  nbsimu,
MatrixRectangular zvals 
)
static

Establish the simulation errors

Parameters
[in]pot_envPot_Env structure
[in]dbisoDb containing the iso-values
[in]dbgrdGradient Db structure
[in]dbtgtTangent Db structure (optional)
[in]nbsimuNumber of simulations
[out]zvalsSimulated errors

◆ st_model_invalid()

static int st_model_invalid ( Model model)
static

Cehck if the Model can be used for Potentials

Returns
Error return code
Parameters
[in]modelModel structure

◆ st_potential_to_layer()

static void st_potential_to_layer ( Pot_Env *  pot_env,
int  isimu,
const double *  potval,
VectorDouble result 
)
static

Translate potential into layer value or center it

Parameters
[in]pot_envPot_Env structure
[in]isimuRank of the simulation
[in]potvalArray of potential values at different layers
[in]resultResulting value (in potential scale) On output, Resulting value in layer scale
Remarks
The potential values at iso-potential samples are assumed
to be ordered
It is assumed that the potential has already been centered
Therefore the 'potval' values must also be centered (locally)

◆ st_potenv_define()

static void st_potenv_define ( Pot_Env *  pot_env,
Pot_Ext *  pot_ext,
Db dbiso,
Db dbgrd,
Db dbtgt,
Db dbout 
)
static

◆ st_potenv_manage()

static void st_potenv_manage ( Pot_Env *  pot_env,
bool  flag_pot,
bool  flag_grad,
bool  flag_trans,
int  opt_part,
bool  verbose 
)
static

Manage the Pot_Env structure

Parameters
[in,out]pot_envPot_env structure
[in]flag_potTrue if the potential must be calculated
[in]flag_gradTrue if the gradients must be calculated
[in]flag_transTrue if the estimation result must be translated into layer number
[in]opt_partOption to exhibit only a part of estimation:
  • 0 : the whole estimation
  • 1 : the gradient contribution only
  • 2 : the tangent contribution only
  • 3 : the isovalues contribution only
  • 4 : the drift contribution only
  • 5 : the external drift contribution only
[in]verboseVerbose flag

◆ st_potenv_valid()

bool st_potenv_valid ( Pot_Env *  pot_env,
Pot_Ext *  pot_ext,
Db dbiso,
Db dbgrd,
Db dbtgt,
DbGrid dbout,
Model model,
ANeigh neigh 
)

◆ st_potext_manage()

static int st_potext_manage ( int  mode,
Pot_Ext *  pot_ext,
int  nring,
double  range,
DbGrid dbout 
)
static

Manage the Pot_Ext structure

Parameters
[in]mode1 for allocation; 0 for save; -1 for deallocation
[in]pot_extPot_Ext structure to be managed
[in]nringNumber of rings used for Ext. Drift calculations
[in]rangeRange of the structure
[in]dboutOutput Db structure

◆ st_print_result()

static void st_print_result ( Pot_Env *  pot_env,
int  isimu,
double *  result,
double  tgtval 
)
static

Print the estimation at a target sample

Parameters
[in]pot_envPot_env structure
[in]isimuRank of the simulation (or -1)
[in]resultArray of results
[in]tgtvalValue of the tangent (or TEST)

◆ st_print_type()

static void st_print_type ( int  rank,
int  type 
)
static

Print the type of information for the Potential covariance

Parameters
[in]rankRank of the point
[in]typeType of the first point 1 for gradient; 2 for tangent; 3 for isopotential

◆ st_rhs_part()

static void st_rhs_part ( Pot_Env *  pot_env,
MatrixRectangular rhs 
)
static

Blank out part the R.H.S. according to 'flag.part'

Parameters
[in]pot_envPot_Env structure
[in,out]rhsArray for the R.H.S.

◆ st_save_result_on_data()

static void st_save_result_on_data ( Pot_Env *  pot_env,
Db db,
int  nvar,
double  value,
const ELoc &  loctype_pot,
const ELoc &  loctype_grad,
VectorInt uid_pot,
VectorInt uid_grad 
)
static

◆ st_simcond()

static void st_simcond ( Pot_Env *  pot_env,
Pot_Ext *  pot_ext,
double  dist_tempere,
bool  flag_trans,
int  nbsimu,
Db dbiso,
Db dbgrd,
Db dbtgt,
DbGrid dbout,
Model model,
double  refpot,
double *  potsim,
VectorDouble zdual,
MatrixRectangular zduals,
MatrixRectangular rhs 
)
static

Calculate the conditional simulation at target samples

Parameters
[in]pot_envPot_Env structure
[in]pot_extPot_Ext structure
[in]dist_tempereDistance for tempering simulations (or TEST)
[in]flag_transTrue if the estimation result must be translated into layer number
[in]nbsimuNumber of simulation
[in]dbisoIso-potential Db structure
[in]dbgrdGradient Db structure
[in]dbtgtTangent Db structure (optional)
[in]dboutOutput Db structure
[in]modelModel structure
[in]refpotPotential at Reference point
[in]potsimPotential simulated values at iso-potential samples
[in]zdualDual estimated vector (Dimension: nequa)
[in]zdualsDual simulated vector (Dimension: nequa * nbsimu)
[in]rhsR.H.S. vector (Dimension: nequa * 4)

◆ st_tempere()

static void st_tempere ( DbGrid dbout,
int  iech,
double  dist_tempere,
double  reskrige,
VectorDouble result 
)
static

Amortize the conditional simulations

Parameters
[in]dboutOutput Db structure
[in]iechRank of the sample
[in]dist_tempereDistance for tempering simulations (or TEST)
[in]reskrigeKriging result
[in]resultConditional Simulation result On output, Conditional Simulation tempered result
Remarks
This function does nothing if 'dist_tempere' is undefined

◆ st_update_final()

static int st_update_final ( Model model,
Pot_Env *  pot_env 
)
static

Make the final checks and define the addresses

Returns
Error return code
Parameters
[in]modelModel structure
[in,out]pot_envThe Pot_Env structure

◆ st_update_gradient()

static int st_update_gradient ( Db dbgrd,
Pot_Env *  pot_env 
)
static

Load the information linked to the Gradients

Returns
Array of indices of the active gradient information
Parameters
[in]dbgrdInput Db structure
[in,out]pot_envThe Pot_Env structure

◆ st_update_isopot()

static int st_update_isopot ( Db dbiso,
Pot_Env *  pot_env 
)
static

Load the information linked to the Iso_potentials

Returns
Error return code
Parameters
[in]dbisoInput Db structure for Iso-Potential
[in,out]pot_envThe Pot_Env structure

◆ st_update_model()

static int st_update_model ( Model model,
Pot_Env *  pot_env 
)
static

Load the information linked to the Model

Returns
Error return code
Parameters
[in]modelModel structure
[in,out]pot_envThe Pot_Env structure

◆ st_update_tangent()

static int st_update_tangent ( Db dbtgt,
Pot_Env *  pot_env 
)
static

Load the information linked to the Tangents

Returns
Error return code
Parameters
[in]dbtgtInput Db structure
[in,out]pot_envThe Pot_Env structure

◆ st_xvalid_potential()

static void st_xvalid_potential ( Pot_Env *  pot_env,
Pot_Ext *  pot_ext,
Db dbiso,
Db dbgrd,
Db dbtgt,
Model model,
MatrixSquareSymmetric lhs,
bool  flag_dist_conv,
VectorDouble zval,
MatrixSquareSymmetric lhs_orig,
MatrixRectangular rhs,
VectorDouble zdual 
)
static

Calculate the cross-validation at the iso-potential samples

Parameters
[in]pot_envPot_Env structure
[in]pot_extPot_Ext structure
[in]dbisoIso-potential Db structure
[in]dbgrdGradient Db structure
[in]dbtgtTangent Db structure (optional)
[in]modelModel structure
[in]lhsInverted Kriging system
[in]flag_dist_convFlag for converting into distance
[in]zvalData vector
[in]lhs_origCopy of the Initial LHS
[in]rhsRight-hand side
[in]zdualDual vector (Dimension: nequa)
Remarks
Arguments from 'zval' are only used to convert into distance

◆ TGT()

static int TGT ( int  i)
static

◆ TGT_COO()

static double TGT_COO ( int  it,
int  i 
)
static

◆ TGT_VAL()

static double TGT_VAL ( int  it,
int  idim 
)
static