/[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 152 by jgs, Thu Sep 15 03:44:45 2005 UTC revision 153 by jgs, Tue Oct 25 01:51:20 2005 UTC
# Line 63  Paso_SystemMatrix* SystemMatrixAdapter:: Line 63  Paso_SystemMatrix* SystemMatrixAdapter::
63     return m_system_matrix.get();     return m_system_matrix.get();
64  }  }
65    
66  void SystemMatrixAdapter::ypAx(escript::Data& y, const escript::Data& x) const  void SystemMatrixAdapter::ypAx(escript::Data& y,escript::Data& x) const
67  {  {
68     Paso_SystemMatrix* mat=getPaso_SystemMatrix();     Paso_SystemMatrix* mat=getPaso_SystemMatrix();
69    
70    if (!x.isExpanded()) {    if ( x.getDataPointSize()  != getColumnBlockSize()) {
    throw FinleyAdapterException("matrix vector product : input Data object has to be expanded");  
   } else if (!y.isExpanded()) {  
    throw FinleyAdapterException("matrix vector product : output Data object has to be expanded");  
   } else if ( x.getDataPointSize()  != getColumnBlockSize()) {  
71     throw FinleyAdapterException("matrix vector product : column block size does not match the number of components in input.");     throw FinleyAdapterException("matrix vector product : column block size does not match the number of components in input.");
72    } else if (y.getDataPointSize() != getRowBlockSize()) {    } else if (y.getDataPointSize() != getRowBlockSize()) {
73     throw FinleyAdapterException("matrix vector product : row block size does not match the number of components in output.");     throw FinleyAdapterException("matrix vector product : row block size does not match the number of components in output.");
# Line 80  void SystemMatrixAdapter::ypAx(escript:: Line 76  void SystemMatrixAdapter::ypAx(escript::
76    } else if (y.getFunctionSpace() != getRowFunctionSpace()) {    } else if (y.getFunctionSpace() != getRowFunctionSpace()) {
77     throw FinleyAdapterException("matrix vector product : row function space and function space of output don't match.");     throw FinleyAdapterException("matrix vector product : row function space and function space of output don't match.");
78    }    }
79    double* x_dp=((escript::Data)x).getSampleData(0);    x.expand();
80      y.expand();
81      double* x_dp=x.getSampleData(0);
82    double* y_dp=y.getSampleData(0);    double* y_dp=y.getSampleData(0);
83    Paso_SystemMatrix_MatrixVector(1., mat,x_dp, 1.,y_dp);    Paso_SystemMatrix_MatrixVector(1., mat,x_dp, 1.,y_dp);
84    checkPasoError();    checkPasoError();
# Line 139  int SystemMatrixAdapter::mapOptionToPaso Line 137  int SystemMatrixAdapter::mapOptionToPaso
137      }      }
138  }  }
139    
140  void SystemMatrixAdapter::setToSolution(escript::Data& out, const escript::Data& in, const boost::python::dict& options) const  void SystemMatrixAdapter::setToSolution(escript::Data& out,escript::Data& in, const boost::python::dict& options) const
141  {  {
142      Paso_SystemMatrix* mat=getPaso_SystemMatrix();      Paso_SystemMatrix* mat=getPaso_SystemMatrix();
143      Paso_Options paso_options;      Paso_Options paso_options;
# Line 161  void SystemMatrixAdapter::setToSolution( Line 159  void SystemMatrixAdapter::setToSolution(
159      EXTRACT("restart",restart,double);      EXTRACT("restart",restart,double);
160      #undef EXTRACT      #undef EXTRACT
161      #undef EXTRACT_OPTION      #undef EXTRACT_OPTION
162      if (! out.isExpanded()) {      if ( out.getDataPointSize()  != getColumnBlockSize()) {
      throw FinleyAdapterException("solve : result Data object has to be expanded");  
     } else if (!in.isExpanded()) {  
      throw FinleyAdapterException("solve : right hand side Data object has to be expanded");  
     } else if ( out.getDataPointSize()  != getColumnBlockSize()) {  
163       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.");
164      } else if ( in.getDataPointSize() != getRowBlockSize()) {      } else if ( in.getDataPointSize() != getRowBlockSize()) {
165       throw FinleyAdapterException("solve : row block size does not match the number of components of  right hand side.");       throw FinleyAdapterException("solve : row block size does not match the number of components of  right hand side.");
# Line 174  void SystemMatrixAdapter::setToSolution( Line 168  void SystemMatrixAdapter::setToSolution(
168      } else if (in.getFunctionSpace() != getRowFunctionSpace()) {      } else if (in.getFunctionSpace() != getRowFunctionSpace()) {
169       throw FinleyAdapterException("solve : row function space and function space of right hand side don't match.");       throw FinleyAdapterException("solve : row function space and function space of right hand side don't match.");
170      }      }
171        out.expand();
172        in.expand();
173      double* out_dp=out.getSampleData(0);      double* out_dp=out.getSampleData(0);
174      double* in_dp=((escript::Data) in).getSampleData(0);      double* in_dp=in.getSampleData(0);
175      Paso_solve(mat,out_dp,in_dp,&paso_options);      Paso_solve(mat,out_dp,in_dp,&paso_options);
176      checkPasoError();      checkPasoError();
177  }  }
178    
179  void SystemMatrixAdapter::nullifyRowsAndCols(const escript::Data& row_q, const escript::Data& col_q, const double mdv) const  void SystemMatrixAdapter::nullifyRowsAndCols(escript::Data& row_q,escript::Data& col_q, const double mdv) const
180  {  {
181      Paso_SystemMatrix* mat = getPaso_SystemMatrix();      Paso_SystemMatrix* mat = getPaso_SystemMatrix();
182      if (! col_q.isExpanded()) {      if ( col_q.getDataPointSize()  != getColumnBlockSize()) {
      throw FinleyAdapterException("nullifyRowsAndCols : column mask has to be expanded");  
     } else if (!row_q.isExpanded()) {  
      throw FinleyAdapterException("nullifyRowsAndCols : row mask has to be expanded");  
     } else if ( col_q.getDataPointSize()  != getColumnBlockSize()) {  
183       throw FinleyAdapterException("nullifyRowsAndCols : column block size does not match the number of components of column mask.");       throw FinleyAdapterException("nullifyRowsAndCols : column block size does not match the number of components of column mask.");
184      } else if ( row_q.getDataPointSize() != getRowBlockSize()) {      } else if ( row_q.getDataPointSize() != getRowBlockSize()) {
185       throw FinleyAdapterException("nullifyRowsAndCols : row block size does not match the number of components of row mask.");       throw FinleyAdapterException("nullifyRowsAndCols : row block size does not match the number of components of row mask.");
# Line 196  void SystemMatrixAdapter::nullifyRowsAnd Line 188  void SystemMatrixAdapter::nullifyRowsAnd
188      } else if (row_q.getFunctionSpace() != getRowFunctionSpace()) {      } else if (row_q.getFunctionSpace() != getRowFunctionSpace()) {
189       throw FinleyAdapterException("nullifyRowsAndCols : row function space and function space of row mask don't match.");       throw FinleyAdapterException("nullifyRowsAndCols : row function space and function space of row mask don't match.");
190      }      }
191      double* row_q_dp=((escript::Data) row_q).getSampleData(0);      row_q.expand();
192      double* col_q_dp=((escript::Data) col_q).getSampleData(0);      col_q.expand();
193        double* row_q_dp=row_q.getSampleData(0);
194        double* col_q_dp=col_q.getSampleData(0);
195      Paso_SystemMatrix_nullifyRowsAndCols(mat,row_q_dp,col_q_dp, mdv);      Paso_SystemMatrix_nullifyRowsAndCols(mat,row_q_dp,col_q_dp, mdv);
196      checkPasoError();      checkPasoError();
197  }  }

Legend:
Removed from v.152  
changed lines
  Added in v.153

  ViewVC Help
Powered by ViewVC 1.1.26