/[escript]/branches/domexper/finley/src/CPPAdapter/SystemMatrixAdapter.cpp
ViewVC logotype

Diff of /branches/domexper/finley/src/CPPAdapter/SystemMatrixAdapter.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2473 by jfenwick, Mon Feb 16 05:08:29 2009 UTC revision 2474 by gross, Tue Jun 16 06:32:15 2009 UTC
# Line 81  void SystemMatrixAdapter::ypAx(escript:: Line 81  void SystemMatrixAdapter::ypAx(escript::
81  }  }
82    
83  int SystemMatrixAdapter::mapOptionToPaso(const int option)  {  int SystemMatrixAdapter::mapOptionToPaso(const int option)  {
84    
85     switch (option) {     switch (option) {
86         case  ESCRIPT_DEFAULT:         case  ESCRIPT_DEFAULT:
87            return PASO_DEFAULT;            return PASO_DEFAULT;
# Line 108  int SystemMatrixAdapter::mapOptionToPaso Line 109  int SystemMatrixAdapter::mapOptionToPaso
109            return PASO_GMRES;            return PASO_GMRES;
110         case  ESCRIPT_PRES20:         case  ESCRIPT_PRES20:
111            return PASO_PRES20;            return PASO_PRES20;
112           case  ESCRIPT_LUMPING:
113              return PASO_LUMPING;
114         case  ESCRIPT_NO_REORDERING:         case  ESCRIPT_NO_REORDERING:
115            return PASO_NO_REORDERING;            return PASO_NO_REORDERING;
116         case  ESCRIPT_MINIMUM_FILL_IN:         case  ESCRIPT_MINIMUM_FILL_IN:
117            return PASO_MINIMUM_FILL_IN;            return PASO_MINIMUM_FILL_IN;
118         case  ESCRIPT_NESTED_DISSECTION:         case  ESCRIPT_NESTED_DISSECTION:
119            return PASO_NESTED_DISSECTION;            return PASO_NESTED_DISSECTION;
        case  ESCRIPT_SCSL:  
           return PASO_SCSL;  
120         case  ESCRIPT_MKL:         case  ESCRIPT_MKL:
121            return PASO_MKL;            return PASO_MKL;
122         case  ESCRIPT_UMFPACK:         case  ESCRIPT_UMFPACK:
# Line 124  int SystemMatrixAdapter::mapOptionToPaso Line 125  int SystemMatrixAdapter::mapOptionToPaso
125            return PASO_ITERATIVE;            return PASO_ITERATIVE;
126         case  ESCRIPT_PASO:         case  ESCRIPT_PASO:
127            return PASO_PASO;            return PASO_PASO;
        case  ESCRIPT_LUMPING:  
           return PASO_LUMPING;  
128         case  ESCRIPT_AMG:         case  ESCRIPT_AMG:
129            return PASO_AMG;            return PASO_AMG;
130         case  ESCRIPT_RILU:         case  ESCRIPT_REC_ILU:
131            return PASO_RILU;            return PASO_REC_ILU;
132         case  ESCRIPT_TRILINOS:         case  ESCRIPT_TRILINOS:
133            return PASO_TRILINOS;            return PASO_TRILINOS;
134         case  ESCRIPT_NONLINEAR_GMRES:         case  ESCRIPT_NONLINEAR_GMRES:
135            return PASO_NONLINEAR_GMRES;            return PASO_NONLINEAR_GMRES;
136         case  ESCRIPT_TFQMR:         case  ESCRIPT_TFQMR :
137            return PASO_TFQMR;            return PASO_TFQMR;
138         case  ESCRIPT_MINRES:         case  ESCRIPT_MINRES:
139            return PASO_MINRES;            return PASO_MINRES;
140         case  ESCRIPT_GS:         case  ESCRIPT_GAUSS_SEIDEL:
141            return PASO_GS;            return PASO_GAUSS_SEIDEL;
142           case  ESCRIPT_RILU:
143              return PASO_RILU;
144           case  ESCRIPT_DEFAULT_REORDERING:
145              return PASO_DEFAULT_REORDERING;
146           case  ESCRIPT_SUPER_LU:
147              return PASO_SUPER_LU;
148           case  ESCRIPT_PASTIX:
149              return PASO_PASTIX;
150           case  ESCRIPT_YAIR_SHAPIRA_COARSENING:
151              return PASO_YAIR_SHAPIRA_COARSENING;
152           case  ESCRIPT_RUGE_STUEBEN_COARSENING:
153              return PASO_RUGE_STUEBEN_COARSENING;
154           case  ESCRIPT_AGGREGATION_COARSENING:
155              return PASO_AGGREGATION_COARSENING;
156           case  ESCRIPT_NO_PRECONDITIONER:
157              return PASO_NO_PRECONDITIONER;
158         default:         default:
159             stringstream temp;             stringstream temp;
160             temp << "Error - Cannot map option value "<< option << " onto Paso";             temp << "Error - Cannot map option value "<< option << " onto Paso";
# Line 187  void finley::SystemMatrixAdapter::Print_ Line 202  void finley::SystemMatrixAdapter::Print_
202    
203  }  }
204    
205  void SystemMatrixAdapter::setToSolution(escript::Data& out,escript::Data& in, const boost::python::dict& options) const  void SystemMatrixAdapter::setToSolution(escript::Data& out,escript::Data& in, boost::python::object& options) const
206  {  {
207     Paso_SystemMatrix* mat=getPaso_SystemMatrix();     Paso_SystemMatrix* mat=getPaso_SystemMatrix();
208     Paso_Options paso_options;     Paso_Options paso_options;
209     dictToPasoOptions(&paso_options,options);     options.attr("resetDiagnostics")();
210       escriptToPasoOptions(&paso_options,options);
211     if ( out.getDataPointSize()  != getColumnBlockSize()) {     if ( out.getDataPointSize()  != getColumnBlockSize()) {
212        throw FinleyAdapterException("solve : column block size does not match the number of components of solution.");        throw FinleyAdapterException("solve : column block size does not match the number of components of solution.");
213     } else if ( in.getDataPointSize() != getRowBlockSize()) {     } else if ( in.getDataPointSize() != getRowBlockSize()) {
# Line 206  void SystemMatrixAdapter::setToSolution( Line 222  void SystemMatrixAdapter::setToSolution(
222     double* out_dp=out.getSampleDataRW(0);       double* out_dp=out.getSampleDataRW(0);  
223     double* in_dp=in.getSampleDataRW(0);         double* in_dp=in.getSampleDataRW(0);    
224     Paso_solve(mat,out_dp,in_dp,&paso_options);     Paso_solve(mat,out_dp,in_dp,&paso_options);
225       pasoToEscriptOptions(&paso_options,options);
226     checkPasoError();     checkPasoError();
227  }  }
228    
# Line 273  void SystemMatrixAdapter::resetValues() Line 290  void SystemMatrixAdapter::resetValues()
290     checkPasoError();     checkPasoError();
291  }  }
292    
293  void SystemMatrixAdapter::dictToPasoOptions(Paso_Options* paso_options, const boost::python::dict& options)  void SystemMatrixAdapter::pasoToEscriptOptions(const Paso_Options* paso_options,boost::python::object& options)
294    {
295    #define SET(__key__,__val__,__type__) options.attr("_updateDiagnostics")(__key__,(__type__)paso_options->__val__)
296       SET("num_iter", num_iter, int);
297       SET("num_level", num_level, int);
298       SET("num_inner_iter", num_inner_iter, int);
299       SET("time", time, double);
300       SET("set_up_time", set_up_time, double);
301       SET("residual_norm", residual_norm, double);
302       SET("converged",converged, bool);
303    #undef SET
304    }
305    void SystemMatrixAdapter::escriptToPasoOptions(Paso_Options* paso_options, const boost::python::object& options)
306  {  {
307    #define EXTRACT(__key__,__val__,__type__) paso_options->__val__=boost::python::extract<__type__>(options.attr(__key__)())
308    #define EXTRACT_OPTION(__key__,__val__,__type__) paso_options->__val__=mapOptionToPaso(boost::python::extract<__type__>(options.attr(__key__)()))
309    
310     Paso_Options_setDefaults(paso_options);     Paso_Options_setDefaults(paso_options);
311  #define EXTRACT(__key__,__val__,__type__) if ( options.has_key(__key__)) paso_options->__val__=boost::python::extract<__type__>(options.get(__key__))     EXTRACT_OPTION("getSolverMethod",method,index_t);
312  #define EXTRACT_OPTION(__key__,__val__,__type__) if ( options.has_key(__key__)) paso_options->__val__=mapOptionToPaso(boost::python::extract<__type__>(options.get(__key__)))     EXTRACT_OPTION("getPackage",package,index_t);
313     EXTRACT("verbose",verbose,int);     EXTRACT("isVerbose",verbose,bool_t);
314     EXTRACT_OPTION("reordering",reordering,int);     EXTRACT("isSymmetric",symmetric,bool_t);
315     EXTRACT(ESCRIPT_TOLERANCE_KEY,tolerance,double);     EXTRACT("getTolerance",tolerance, double);
316     EXTRACT_OPTION(ESCRIPT_METHOD_KEY,method,int);     EXTRACT("getAbsoluteTolerance",absolute_tolerance, double);
317     EXTRACT(ESCRIPT_SYMMETRY_KEY,symmetric,int);     EXTRACT("getInnerTolerance",inner_tolerance, double);
318     EXTRACT_OPTION(ESCRIPT_PACKAGE_KEY,package,int);     EXTRACT("adaptInnerTolerance",adapt_inner_tolerance, bool_t);
319     EXTRACT_OPTION("preconditioner",preconditioner,int);     EXTRACT_OPTION("getReordering", reordering, index_t);
320     EXTRACT("iter_max",iter_max,int);     EXTRACT_OPTION("getPreconditioner", preconditioner, index_t);
321     EXTRACT("drop_tolerance",drop_tolerance,double);     EXTRACT("getIterMax", iter_max, dim_t);
322     EXTRACT("drop_storage",drop_storage,double);     EXTRACT("getInnerIterMax", inner_iter_max, dim_t);
323     EXTRACT("truncation",truncation,int);     EXTRACT("getDropTolerance", drop_tolerance, double);
324     EXTRACT("restart",restart,int);     EXTRACT("getDropStorage", drop_storage, double);
325     EXTRACT("sweeps",sweeps,int);     EXTRACT("getTruncation", truncation, dim_t);
326       EXTRACT("_getRestartForC", restart, index_t);
327       EXTRACT("getNumSweeps", sweeps, index_t);
328       EXTRACT("getNumPreSweeps", pre_sweeps, dim_t);
329       EXTRACT("getNumPostSweeps", post_sweeps, dim_t);
330       EXTRACT("getLevelMax", level_max, dim_t);
331       EXTRACT("getCoarseningThreshold", coarsening_threshold, double);
332       EXTRACT("acceptConvergenceFailure", accept_failed_convergence, bool_t);
333       EXTRACT_OPTION("getCoarsening", coarsening_method, index_t);
334       EXTRACT("getRelaxationFactor",  relaxation_factor,  double);  
335      
336  #undef EXTRACT  #undef EXTRACT
337  #undef EXTRACT_OPTION  #undef EXTRACT_OPTION
338  }  }

Legend:
Removed from v.2473  
changed lines
  Added in v.2474

  ViewVC Help
Powered by ViewVC 1.1.26