42 #include "error_handlers.h"
47 #include <cvode/cvode.h>
48 #include <cvode/cvode_direct.h>
49 #include <nvector/nvector_serial.h>
50 #include <sunmatrix/sunmatrix_dense.h>
51 #include <sunlinsol/sunlinsol_dense.h>
53 #include <sundials/sundials_dense.h>
54 #include <sundials/sundials_types.h>
80 PCSet(
const string sp_type,
const int order,
const int n_dim,
const string pc_type,
81 const double alpha=0.0,
const double betta=1.0);
93 PCSet(
const string sp_type,
const int order,
const int n_dim,
const string pc_type,
const string pc_seq,
94 const double alpha=0.0,
const double betta=1.0);
103 PCSet(
const string sp_type,
const Array1D<int>& maxOrders,
const int n_dim,
const string pc_type,
104 const double alpha=0.0,
const double betta=1.0);
113 PCSet(
const string sp_type,
const Array2D<int>& customMultiIndex,
const string pc_type,
114 const double alpha=0.0,
const double betta=1.0);
159 void SetQuadRule(
const string grid_type,
const string fs_type,
int param);
162 void SetQuadRule(
Quad &quadRule);
169 void PrintMultiIndex()
const;
172 void PrintMultiIndexNormSquared()
const;
192 void GetMultiIndex(
int *mindex)
const;
217 void GetQuadPoints(
double* quad)
const {
for(
int i=0;i<nQuadPoints_;i++)
for(
int j=0;j<nDim_;j++) quad[i*nDim_+j]=quadPoints_(i,j);}
223 void GetQuadWeights(
double* wghts)
const {
for(
int i=0;i<nQuadPoints_;i++) wghts[i]=quadWeights_(i);}
231 void GetPsi(
double* psi)
const {
for(
int i=0;i<nQuadPoints_;i++)
for(
int j=0;j<nPCTerms_;j++) psi[i*nPCTerms_+j]=psi_(i,j);}
237 void GetPsiSq(
double* psisq)
const {
for(
int i=0;i<nPCTerms_;i++) psisq[i]=psiSq_(i);}
274 void InitMeanStDv(
const double& m,
const double& s,
double* p)
const;
282 void InitMeanStDv(
const double& m,
const double& s,
Array1D<double>& p)
const;
287 void Copy(
double* p1,
const double* p2)
const;
297 void Add(
const double* p1,
const double* p2,
double* p3)
const;
306 void AddInPlace(
double* p1,
const double* p2)
const;
315 void Multiply(
const double* p1,
const double& a,
double* p2)
const;
324 void MultiplyInPlace(
double* p1,
const double& a)
const;
333 void Subtract(
const double* p1,
const double* p2,
double* p3)
const;
342 void SubtractInPlace(
double* p1,
const double* p2)
const;
351 void Prod(
const double* p1,
const double* p2,
double* p3)
const;
360 void Prod3(
const double* p1,
const double* p2,
const double* p3,
double* p4)
const;
372 void Polyn(
const double* polycf,
int npoly,
const double* p1,
double* p2)
const;
407 void Exp(
const double* p1,
double* p2)
const;
418 void Log(
const double* p1,
double* p2)
const;
429 void Log10(
const double* p1,
double* p2)
const;
441 void RPow(
const double* p1,
double* p2,
const double& a)
const;
450 void IPow(
const double* p1,
double* p2,
const int& ia)
const;
460 void Inv(
const double* p1,
double* p2)
const;
479 void Div(
const double* p1,
const double* p2,
double* p3)
const;
489 double StDv(
const double* p)
const;
501 double GetModesRMS(
const double* p)
const;
514 void Derivative(
const double* p1,
double* p2)
const;
524 int GetNumTripleProd()
const;
526 void GetTripleProd(
int *nTriple,
int *iProd,
int *jProd,
double *Cijk)
const;
530 int GetNumQuadProd()
const;
532 void GetQuadProd(
int *nQuad,
int *iProd,
int *jProd,
int *kProd,
double *Cijkl)
const;
543 void SeedBasisRandNumGen(
const int& seed)
const;
555 void DrawSampleSet(
const double* p,
double* samples,
const int& nSamples);
560 void DrawSampleVar(
double *samples,
const int &nS,
const int &nD)
const;
582 double EvalPC(
const double* p,
const double* randVarSamples);
593 void EvalBasisAtCustPts(
const double* custPoints,
const int npts,
double* psi);
629 int ComputeEffDims(
int *effdim);
649 double ComputeMean(
const double *coef);
658 double ComputeVarFrac(
const double *coef,
double *varfrac);
691 void EvalNormSq(
double* normsq,
const int npc);
699 bool IsInDomain(
double x);
715 PCSet(
const PCSet &obj):order_(obj.order_), nDim_(obj.nDim_) {};
718 void ComputeMaxOrdPerDim();
723 void Initialize(
const string ordertype);
734 void EvalBasisProd3();
737 void EvalBasisProd4();
748 int* ia,
int* ja,
double* a,
int* obj) {
750 OMap_t::iterator it = omap_->find(*obj);
751 if(it == omap_->end()) {
752 string err_message = (string)
"GMRESMatrixVectorProdWrapper():"
753 +
" the callback object is not a valid entry in the map";
754 throw Tantrum(err_message);
757 it->second->GMRESMatrixVectorProd(x, a, y);
771 int* ia,
int* ja,
double* a,
int* obj,
772 double* rwork,
int* iwork) { };
779 void GMRESMatrixVectorProd(
const double* x,
const double*a,
double* y)
const;
793 void LogTaylor(
const double* p1,
double* p2)
const;
797 void LogInt(
const double* p1,
double* p2)
const;
805 double indxobj = ((
double*) f_data)[0] ;
807 OMap_t::iterator it = omap_->find((
int) indxobj);
809 if (it == omap_->end())
811 string err_message = (string)
"LogIntRhsWrapper():"
812 +
" the callback object is not a valid entry in the map";
813 throw Tantrum(err_message);
817 it->second->LogIntRhs(t,y,ydot,f_data);
824 int LogIntRhs(realtype t, N_Vector y, N_Vector ydot,
void *f_data)
const;
948 int Check_CVflag(
void *flagvalue,
const char *funcname,
int opt)
const;
1D Array class for any type T
2D Array class for any type T
LogCompMethod
Definition: PCSet.h:65
@ TaylorSeries
Definition: PCSet.h:65
@ Integration
Definition: PCSet.h:65
Definition: Array1D.h:472
Definition: Array1D.h:262
Stores data of any type T in a 1D array.
Definition: Array1D.h:61
Contains all basis type specific definitions and operations needed to generate a PCSet.
Definition: PCBasis.h:47
Defines and initializes PC basis function set and provides functions to manipulate PC expansions defi...
Definition: PCSet.h:71
Array2D< double > quadPoints_
Array to store quadrature points.
Definition: PCSet.h:885
Array1D< int > maxOrders_
Array of maximum orders requested if custom(HDMR) ordering is requested.
Definition: PCSet.h:849
void GetPsi(Array2D< double > &psi) const
Get the values of the basis polynomials evaluated at the quadrature points.
Definition: PCSet.h:227
int nQuadPoints_
Number of quadrature points used.
Definition: PCSet.h:858
Array2D< double > psi_
Array to store basis functions evaluated at quadrature points for each order: psi_(iqp,...
Definition: PCSet.h:878
Array1D< Array1D< double > > psiIJKProd2_
<\Psi_i \Psi_j \Psi_k> terms that are not zero, for all k
Definition: PCSet.h:908
void SetGMRESDivTolerance(const double &rTol)
Set the relative tolerance for GMRES in Div routine.
Definition: PCSet.h:261
double rTolGMRESDiv_
GMRES tolerance in Div()
Definition: PCSet.h:873
string GetPCType() const
Get and set variables/arrays inline.
Definition: PCSet.h:180
void GetQuadWeights(Array1D< double > &wghts) const
Get the quadrature weights.
Definition: PCSet.h:220
void GetNormSq(Array1D< double > &normsq) const
Get the norm-squared.
Definition: PCSet.h:196
double GetGMRESDivTolerance() const
Get relative tolerance for GMRES in Div routine.
Definition: PCSet.h:258
void GetPsiSq(double *psisq) const
Get the basis polynomial norms-squared in a double* array psisq.
Definition: PCSet.h:237
PCSet()
Dummy default constructor, which should not be used as it is not well defined Therefore we make it pr...
Definition: PCSet.h:707
double SMALL_
Tolerance to avoid floating-point errors.
Definition: PCSet.h:870
double rTolTaylor_
Relative tolerance for Taylor series approximations.
Definition: PCSet.h:864
double GetBeta() const
Get the value of the parameter beta.
Definition: PCSet.h:186
void GetMultiIndex(Array2D< int > &mindex) const
Get the multiindex (return Array2D)
Definition: PCSet.h:189
int narg_
Number of free parameters to specify the basis.
Definition: PCSet.h:954
double CVinitstep_
CVODE parameter: initial step size.
Definition: PCSet.h:936
Array1D< Array1D< int > > iProd2_
i-indices of <\Psi_i \Psi_j \Psi_k> terms that are not zero, for all k
Definition: PCSet.h:900
Array1D< Array1D< int > > jProd3_
j-indices of <\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l
Definition: PCSet.h:916
void GetQuadWeights(double *wghts) const
Get the quadrature weights folded into a one-dimensional array wghts.
Definition: PCSet.h:223
void GetPsi(double *psi) const
Get the polynomials evaluated at the quadrature points folded into a one-dimensional array psi.
Definition: PCSet.h:231
static OMap_t * omap_
Map to connect integer indexes with pointers to this class.
Definition: PCSet.h:966
Array1D< Array1D< int > > jProd2_
j-indices of <\Psi_i \Psi_j \Psi_k> terms that are not zero, for all k
Definition: PCSet.h:904
Array1D< Array1D< int > > iProd3_
i-indices of <\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l
Definition: PCSet.h:912
int order_
Order of the PC representation.
Definition: PCSet.h:843
int GetNQuadPoints() const
Get the number of quadrature points.
Definition: PCSet.h:208
double beta_
Parameter beta for PCs that require two parameters (SW,JB)
Definition: PCSet.h:959
Array1D< int > maxOrdPerDim_
Array of maximum orders per dimension.
Definition: PCSet.h:852
Array1D< double > psiSq_
Array with the norms squared of the basis functions, corresponding to each term in the PC expansion.
Definition: PCSet.h:882
void SetVerbosity(int verbosity)
Other.
Definition: PCSet.h:686
Array2D< int > quadIndices_
Array to store quadrature point indexing; useful for nested rules.
Definition: PCSet.h:891
double CVmaxstep_
CVODE parameter: maximal step size.
Definition: PCSet.h:939
int GetOrder() const
Get the PC order.
Definition: PCSet.h:205
void GetPsiSq(Array1D< double > &psisq) const
Get the basis polynomial norms-squared in an array class object psisq.
Definition: PCSet.h:234
int nPCTerms_
Total number of terms in the PC expansions.
Definition: PCSet.h:861
string pcType_
String indicator of PC type.
Definition: PCSet.h:834
double GetTaylorTolerance() const
Get relative tolerance for Taylor series approximations.
Definition: PCSet.h:240
std::map< int, PCSet * > OMap_t
Definition of a map to connect integer indexes with pointers to this class.
Definition: PCSet.h:962
Array1D< Array1D< int > > kProd3_
k-indices of <\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l
Definition: PCSet.h:920
int uqtkverbose_
Verbosity level.
Definition: PCSet.h:828
int my_index_
Index of this class.
Definition: PCSet.h:951
PCSet(const PCSet &obj)
Dummy copy constructor, which should not be used as it is currently not well defined....
Definition: PCSet.h:715
void GetQuadPointsWeights(Array2D< double > &quad, Array1D< double > &wghts) const
Get the quadrature points and weights.
Definition: PCSet.h:214
int CVmaxnumsteps_
CVODE parameter: maximal number of steps.
Definition: PCSet.h:933
PCBasis * p_basis_
Pointer to the class that defines the basis type and functions.
Definition: PCSet.h:840
Array1D< double > quadWeights_
Array to store quadrature weights.
Definition: PCSet.h:888
int maxTermTaylor_
Max number of terms in Taylor series approximations.
Definition: PCSet.h:867
int GetTaylorTermsMax() const
Get maximum number of terms in Taylor series approximations.
Definition: PCSet.h:246
double GetAlpha() const
Get the value of the parameter alpha.
Definition: PCSet.h:183
string pcSeq_
String indicator of multiindex ordering.
Definition: PCSet.h:837
Array1D< Array1D< double > > psiIJKLProd3_
<\Psi_i \Psi_j \Psi_k \Psi_l> terms that are not zero, for all l
Definition: PCSet.h:924
LogCompMethod logMethod_
Flag for method to compute log: TaylorSeries or Integration.
Definition: PCSet.h:927
const int nDim_
Number of stochastic dimensions (degrees of freedom) in the PC representation.
Definition: PCSet.h:855
static void GMRESPreCondWrapper(int *n, double *r, double *z, int *nelt, int *ia, int *ja, double *a, int *obj, double *rwork, int *iwork)
Wrapper for preconditioner routine to be called by GMRES.
Definition: PCSet.h:770
double CVrelt_
CVODE parameter: relative tolerance.
Definition: PCSet.h:942
void SetLogCompMethod(const LogCompMethod &logMethod)
Set method of computing the log function.
Definition: PCSet.h:255
static void GMRESMatrixVectorProdWrapper(int *n, double *x, double *y, int *nelt, int *ia, int *ja, double *a, int *obj)
Wrapper for Matrix-vector multiplication routine to be called by GMRES.
Definition: PCSet.h:747
static int LogIntRhsWrapper(realtype t, N_Vector y, N_Vector ydot, void *f_data)
Wrapper for LogIntRhs. The first component of f_data pointer carries an integer handle identifying th...
Definition: PCSet.h:803
void SetTaylorTolerance(const double &rTol)
Set relative tolerance for Taylor series approximations.
Definition: PCSet.h:243
double alpha_
Parameter alpha for PCs that require a parameter (LG,SW,JB)
Definition: PCSet.h:957
double CVabst_
CVODE parameter: absolute tolerance.
Definition: PCSet.h:945
int CVmaxord_
CVODE parameter: maximal order.
Definition: PCSet.h:930
void SetTaylorTermsMax(const int &maxTerm)
Set maximum number of terms in Taylor series approximations.
Definition: PCSet.h:249
string spType_
String indicator of ISP or NISP implementation type.
Definition: PCSet.h:831
int GetNumberPCTerms() const
Get the number of terms in a PC expansion of this order and dimension.
Definition: PCSet.h:199
static int next_index_
index of next object in map
Definition: PCSet.h:964
void GetQuadPoints(double *quad) const
Get the quadrature points folded into a one-dimensional array quad.
Definition: PCSet.h:217
int GetNDim() const
Get the PC dimensionality.
Definition: PCSet.h:202
int maxorddim_
Maximal order within all dimensions.
Definition: PCSet.h:846
Array2D< int > multiIndex_
Array to store multi-index: multiIndex_(ipc,idim) contains the order of the basis function associated...
Definition: PCSet.h:896
void GetQuadPoints(Array2D< double > &quad) const
Get the quadrature points.
Definition: PCSet.h:211
Generates quadrature rules.
Definition: quad.h:54
Header file for the quadrature class.