/[escript]/trunk/esys2/finley/src/CPPAdapter/SystemMatrixAdapter.cpp
ViewVC logotype

Diff of /trunk/esys2/finley/src/CPPAdapter/SystemMatrixAdapter.cpp

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

revision 100 by jgs, Wed Dec 15 03:48:48 2004 UTC revision 102 by jgs, Wed Dec 15 07:08:39 2004 UTC
# Line 10  Line 10 
10   * license agreement with ACcESS.                                             *   * license agreement with ACcESS.                                             *
11   *                                                                            *   *                                                                            *
12   ******************************************************************************   ******************************************************************************
13     $Id$
14  */  */
15  extern "C" {  extern "C" {
16  #include "finley/finleyC/System.h"  #include "finley/finleyC/System.h"
# Line 24  using namespace std; Line 25  using namespace std;
25    
26  namespace finley {  namespace finley {
27    
28    struct null_deleter
29    {
30      void operator()(void const *ptr) const
31      {
32      }
33    };
34    
35    
36  SystemMatrixAdapter::SystemMatrixAdapter()  SystemMatrixAdapter::SystemMatrixAdapter()
37  {  {
38     throw FinleyAdapterException("Error - Illegal to generate default SystemMatrixAdapter.");     throw FinleyAdapterException("Error - Illegal to generate default SystemMatrixAdapter.");
39  }  }
40    
41  SystemMatrixAdapter::SystemMatrixAdapter(const Finley_SystemMatrix* system_matrix,  SystemMatrixAdapter::SystemMatrixAdapter(Finley_SystemMatrix* system_matrix,
42                                           const int row_blocksize,                                           const int row_blocksize,
43                                           const escript::FunctionSpace& row_functionspace,                                           const escript::FunctionSpace& row_functionspace,
44                                           const int column_blocksize,                                           const int column_blocksize,
45                                           const escript::FunctionSpace& column_functionspace):                                           const escript::FunctionSpace& column_functionspace):
46  AbstractSystemMatrix(row_blocksize,row_functionspace,column_blocksize,column_functionspace),  AbstractSystemMatrix(row_blocksize,row_functionspace,column_blocksize,column_functionspace)
 m_system_matrix(system_matrix)  
47  {  {
48        m_system_matrix.reset(system_matrix,null_deleter());
49  }  }
50    
51  SystemMatrixAdapter::~SystemMatrixAdapter()  SystemMatrixAdapter::~SystemMatrixAdapter()
# Line 67  void SystemMatrixAdapter::setToSolution( Line 76  void SystemMatrixAdapter::setToSolution(
76      #define EXTRACT(__key__,__val__,__type__) if ( options.has_key(__key__)) finley_options.__val__=boost::python::extract<__type__>(options.get(__key__))      #define EXTRACT(__key__,__val__,__type__) if ( options.has_key(__key__)) finley_options.__val__=boost::python::extract<__type__>(options.get(__key__))
77      EXTRACT("verbose",verbose,int);      EXTRACT("verbose",verbose,int);
78      EXTRACT("reordering",reordering,int);      EXTRACT("reordering",reordering,int);
79      EXTRACT("tolerance",tolerance,double);      EXTRACT(ESCRIPT_TOLERANCE_KEY,tolerance,double);
80      EXTRACT("iterative_method",iterative_method,int);      EXTRACT(ESCRIPT_METHOD_KEY,method,int);
81        EXTRACT(ESCRIPT_SYMMETRY_KEY,symmetric,int);
82      EXTRACT("preconditioner",preconditioner,int);      EXTRACT("preconditioner",preconditioner,int);
83      EXTRACT("iter_max",iter_max,int);      EXTRACT("iter_max",iter_max,int);
84      EXTRACT("drop_tolerance",drop_tolerance,double);      EXTRACT("drop_tolerance",drop_tolerance,double);
85      EXTRACT("drop_storage",drop_storage,double);      EXTRACT("drop_storage",drop_storage,double);
86      EXTRACT("iterative",iterative,int);      EXTRACT("truncation",truncation,double);
87        EXTRACT("restart",restart,double);
88      #undef EXTRACT      #undef EXTRACT
89      if (finley_options.iterative) {      Finley_SystemMatrix_solve(getFinley_SystemMatrix(),&(out.getDataC()),&(in.getDataC()),&finley_options);
        Finley_SystemMatrix_iterative(getFinley_SystemMatrix(),&(out.getDataC()),&(in.getDataC()),&finley_options);  
     } else {  
        Finley_SystemMatrix_solve(getFinley_SystemMatrix(),&(out.getDataC()),&(in.getDataC()),&finley_options);  
     }  
90      checkFinleyError();      checkFinleyError();
91  }  }
92    
# Line 92  void SystemMatrixAdapter::nullifyRowsAnd Line 99  void SystemMatrixAdapter::nullifyRowsAnd
99      Finley_SystemMatrix_nullifyRowsAndCols(system_matrix_ptr, &row_qC, &col_qC, mdv);      Finley_SystemMatrix_nullifyRowsAndCols(system_matrix_ptr, &row_qC, &col_qC, mdv);
100  }  }
101    
102    void SystemMatrixAdapter::saveMM(const std::string& fileName) const
103    {
104        char fName[fileName.size()+1];
105        strcpy(fName,fileName.c_str());
106        Finley_SystemMatrix* system_matrix_ptr = getFinley_SystemMatrix();
107        Finley_SystemMatrix_saveMM(system_matrix_ptr,fName);
108        checkFinleyError();
109    }
110    
111    void SystemMatrixAdapter:: setValue(const double value) const
112    {
113       Finley_SystemMatrix* system_matrix_ptr = getFinley_SystemMatrix();
114       Finley_SystemMatrix_setValues(system_matrix_ptr,value);
115       checkFinleyError();
116    }
117                                                                                                                                                        
118    
119  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.100  
changed lines
  Added in v.102

  ViewVC Help
Powered by ViewVC 1.1.26