Changeset 13195


Ignore:
Timestamp:
08/30/12 11:35:29 (13 years ago)
Author:
utke
Message:

NEW - to trace the solver call for ADOLC call the wrapped solver through the EDF interface

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  
    4141                #endif
    4242                case SeqMatType:{
    43                         SolverxSeq(&uf->svector,Kff->smatrix,pf->svector);
     43                        SolverxSeq(&uf->svector,Kff->smatrix,pf->svector,parameters);
    4444                        break;}
    4545                default:
  • TabularUnified issm/trunk-jpl/src/c/modules/Solverx/Solverx.h

    r13185 r13195  
    2323#endif
    2424
    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);
     25void SolverxSeq(SeqVec** puf,SeqMat* Kff, SeqVec* pf,Parameters* parameters);
     26void SolverxSeq(IssmPDouble** pX,IssmPDouble* A,IssmPDouble* B,int n);
    2827
    2928#ifdef _HAVE_ADOLC_
     29void SolverxSeq(IssmDouble** pX,IssmDouble* A,IssmDouble* B,int n, Parameters* parameters);
    3030ADOLC_ext_fct EDF_for_solverx;
    3131#endif
  • TabularUnified issm/trunk-jpl/src/c/modules/Solverx/SolverxSeq.cpp

    r13185 r13195  
    1919#endif
    2020
    21 void SolverxSeq(SeqVec** puf,SeqMat* Kff, SeqVec* pf){/*{{{*/
     21#ifdef _HAVE_ADOLC_
     22#include "../../shared/Numerics/adolc_edf.h"
     23#endif
     24
     25void SolverxSeq(SeqVec** puf,SeqMat* Kff, SeqVec* pf, Parameters* parameters){/*{{{*/
    2226
    2327        #ifdef _HAVE_GSL_
     
    3337        if(M!=N)_error_("Stiffness matrix should be square!");
    3438
     39#ifdef _HAVE_ADOLC_
     40        SolverxSeq(&x,Kff->matrix,pf->vector,N,parameters);
     41#else
    3542        SolverxSeq(&x,Kff->matrix,pf->vector,N);
     43#endif
    3644        uf=new SeqVec(x,N);
    3745
     
    5260}
    5361
    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;
     62void 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);
    8876}
    8977/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.