Changeset 13195
- Timestamp:
- 08/30/12 11:35:29 (13 years ago)
- Location:
- issm/trunk-jpl/src/c/modules/Solverx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/c/modules/Solverx/Solverx.cpp ¶
r13119 r13195 41 41 #endif 42 42 case SeqMatType:{ 43 SolverxSeq(&uf->svector,Kff->smatrix,pf->svector );43 SolverxSeq(&uf->svector,Kff->smatrix,pf->svector,parameters); 44 44 break;} 45 45 default: -
TabularUnified issm/trunk-jpl/src/c/modules/Solverx/Solverx.h ¶
r13185 r13195 23 23 #endif 24 24 25 void SolverxSeq(SeqVec** puf,SeqMat* Kff, SeqVec* pf); 26 void SolverxSeq(IssmDouble** pX,IssmDouble* A,IssmDouble* B,int n); 27 void SolverxSeq(double** pX,double* A,double* B,int n); 25 void SolverxSeq(SeqVec** puf,SeqMat* Kff, SeqVec* pf,Parameters* parameters); 26 void SolverxSeq(IssmPDouble** pX,IssmPDouble* A,IssmPDouble* B,int n); 28 27 29 28 #ifdef _HAVE_ADOLC_ 29 void SolverxSeq(IssmDouble** pX,IssmDouble* A,IssmDouble* B,int n, Parameters* parameters); 30 30 ADOLC_ext_fct EDF_for_solverx; 31 31 #endif -
TabularUnified issm/trunk-jpl/src/c/modules/Solverx/SolverxSeq.cpp ¶
r13185 r13195 19 19 #endif 20 20 21 void SolverxSeq(SeqVec** puf,SeqMat* Kff, SeqVec* pf){/*{{{*/ 21 #ifdef _HAVE_ADOLC_ 22 #include "../../shared/Numerics/adolc_edf.h" 23 #endif 24 25 void SolverxSeq(SeqVec** puf,SeqMat* Kff, SeqVec* pf, Parameters* parameters){/*{{{*/ 22 26 23 27 #ifdef _HAVE_GSL_ … … 33 37 if(M!=N)_error_("Stiffness matrix should be square!"); 34 38 39 #ifdef _HAVE_ADOLC_ 40 SolverxSeq(&x,Kff->matrix,pf->vector,N,parameters); 41 #else 35 42 SolverxSeq(&x,Kff->matrix,pf->vector,N); 43 #endif 36 44 uf=new SeqVec(x,N); 37 45 … … 52 60 } 53 61 54 void SolverxSeq(IssmDouble** pX,IssmDouble* A,IssmDouble* B,int n){//{{{ 55 /* if we use Adol-C then the IssmDouble will be an adouble 56 and the calls to gsl_... will not work. 57 We therefore call a wrapped solver instead. 58 */ 59 60 /*Output: */ 61 IssmDouble* X=NULL; 62 63 /*Intermediary: */ 64 int i; 65 IssmPDouble* pdoubleA=NULL; 66 IssmPDouble* pdoubleB=NULL; 67 IssmPDouble* pdoubleX=NULL; 68 69 /*First, transfer from IssmDouble to double all our matrices and vectors: */ 70 pdoubleA=xNew<IssmPDouble>(n*n); 71 pdoubleB=xNew<IssmPDouble>(n); 72 for(i=0;i<n*n;i++)pdoubleA[i]=reCast<IssmPDouble>(A[i]); 73 for(i=0;i<n;i++)pdoubleB[i]=reCast<IssmPDouble>(B[i]); 74 75 /*Call wrapped solver: */ 76 SolverxSeq(&pdoubleX,pdoubleA, pdoubleB, n); 77 78 /*Transfer solution vector from double to IssmDouble: */ 79 X = xNew<IssmDouble>(n); 80 for(i=0;i<n;i++)X[i]=reCast<IssmDouble>(pdoubleX[i]); 81 82 /*Free ressources:*/ 83 xDelete<IssmPDouble>(pdoubleA); 84 xDelete<IssmPDouble>(pdoubleB); 85 86 /*Assign output pointers: */ 87 *pX=X; 62 void SolverxSeq(IssmDouble** pX,IssmDouble* A,IssmDouble* B,int n, Parameters* parameters){//{{{ 63 // pack inputs to conform to the EDF-prescribed interface 64 IssmDouble* adoubleEDF_X=xNew<IssmDouble>(n*(n+1)); // packed inputs, i.e. matrix and right hand side 65 for(int i=0; i<n*n;i++)adoubleEDF_X[i] =A[i]; // pack matrix 66 for(int i=0; i<n; i++)adoubleEDF_X[i+n*n]=B[i]; // pack the right hand side 67 IssmPDouble* pdoubleEDF_X=xNew<IssmPDouble>(n*(n+1)); // provide space to transfer inputs during call_ext_fct 68 IssmPDouble* pdoubleEDF_Y=xNew<IssmPDouble>(n); // provide space to transfer outputs during call_ext_fct 69 // call the wrapped solver through the registry entry we retrieve from parameters 70 call_ext_fct(dynamic_cast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p, 71 n*(n+1), pdoubleEDF_X, adoubleEDF_X, 72 n, pdoubleEDF_Y, B); 73 xDelete(adoubleEDF_X); 74 xDelete(pdoubleEDF_X); 75 xDelete(pdoubleEDF_Y); 88 76 } 89 77 /*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.