10 |
* license agreement with ACcESS. * |
* license agreement with ACcESS. * |
11 |
* * |
* * |
12 |
****************************************************************************** |
****************************************************************************** |
|
$Id$ |
|
13 |
*/ |
*/ |
14 |
extern "C" { |
extern "C" { |
15 |
#include "finley/finleyC/System.h" |
#include "finley/finleyC/System.h" |
24 |
|
|
25 |
namespace finley { |
namespace finley { |
26 |
|
|
|
struct null_deleter |
|
|
{ |
|
|
void operator()(void const *ptr) const |
|
|
{ |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
27 |
SystemMatrixAdapter::SystemMatrixAdapter() |
SystemMatrixAdapter::SystemMatrixAdapter() |
28 |
{ |
{ |
29 |
throw FinleyAdapterException("Error - Illegal to generate default SystemMatrixAdapter."); |
throw FinleyAdapterException("Error - Illegal to generate default SystemMatrixAdapter."); |
30 |
} |
} |
31 |
|
|
32 |
SystemMatrixAdapter::SystemMatrixAdapter(Finley_SystemMatrix* system_matrix, |
SystemMatrixAdapter::SystemMatrixAdapter(const Finley_SystemMatrix* system_matrix, |
33 |
const int row_blocksize, |
const int row_blocksize, |
34 |
const escript::FunctionSpace& row_functionspace, |
const escript::FunctionSpace& row_functionspace, |
35 |
const int column_blocksize, |
const int column_blocksize, |
36 |
const escript::FunctionSpace& column_functionspace): |
const escript::FunctionSpace& column_functionspace): |
37 |
AbstractSystemMatrix(row_blocksize,row_functionspace,column_blocksize,column_functionspace) |
AbstractSystemMatrix(row_blocksize,row_functionspace,column_blocksize,column_functionspace), |
38 |
|
m_system_matrix(system_matrix) |
39 |
{ |
{ |
|
m_system_matrix.reset(system_matrix,null_deleter()); |
|
40 |
} |
} |
41 |
|
|
42 |
SystemMatrixAdapter::~SystemMatrixAdapter() |
SystemMatrixAdapter::~SystemMatrixAdapter() |
67 |
#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__)) |
68 |
EXTRACT("verbose",verbose,int); |
EXTRACT("verbose",verbose,int); |
69 |
EXTRACT("reordering",reordering,int); |
EXTRACT("reordering",reordering,int); |
70 |
EXTRACT(ESCRIPT_TOLERANCE_KEY,tolerance,double); |
EXTRACT("tolerance",tolerance,double); |
71 |
EXTRACT(ESCRIPT_METHOD_KEY,method,int); |
EXTRACT("iterative_method",iterative_method,int); |
|
EXTRACT(ESCRIPT_SYMMETRY_KEY,symmetric,int); |
|
72 |
EXTRACT("preconditioner",preconditioner,int); |
EXTRACT("preconditioner",preconditioner,int); |
73 |
EXTRACT("iter_max",iter_max,int); |
EXTRACT("iter_max",iter_max,int); |
74 |
EXTRACT("drop_tolerance",drop_tolerance,double); |
EXTRACT("drop_tolerance",drop_tolerance,double); |
75 |
EXTRACT("drop_storage",drop_storage,double); |
EXTRACT("drop_storage",drop_storage,double); |
76 |
EXTRACT("truncation",truncation,double); |
EXTRACT("iterative",iterative,int); |
|
EXTRACT("restart",restart,double); |
|
77 |
#undef EXTRACT |
#undef EXTRACT |
78 |
Finley_SystemMatrix_solve(getFinley_SystemMatrix(),&(out.getDataC()),&(in.getDataC()),&finley_options); |
if (finley_options.iterative) { |
79 |
|
Finley_SystemMatrix_iterative(getFinley_SystemMatrix(),&(out.getDataC()),&(in.getDataC()),&finley_options); |
80 |
|
} else { |
81 |
|
Finley_SystemMatrix_solve(getFinley_SystemMatrix(),&(out.getDataC()),&(in.getDataC()),&finley_options); |
82 |
|
} |
83 |
checkFinleyError(); |
checkFinleyError(); |
84 |
} |
} |
85 |
|
|
92 |
Finley_SystemMatrix_nullifyRowsAndCols(system_matrix_ptr, &row_qC, &col_qC, mdv); |
Finley_SystemMatrix_nullifyRowsAndCols(system_matrix_ptr, &row_qC, &col_qC, mdv); |
93 |
} |
} |
94 |
|
|
|
void SystemMatrixAdapter::saveMM(const std::string& fileName) const |
|
|
{ |
|
|
char fName[fileName.size()+1]; |
|
|
strcpy(fName,fileName.c_str()); |
|
|
Finley_SystemMatrix* system_matrix_ptr = getFinley_SystemMatrix(); |
|
|
Finley_SystemMatrix_saveMM(system_matrix_ptr,fName); |
|
|
checkFinleyError(); |
|
|
} |
|
|
|
|
|
void SystemMatrixAdapter:: setValue(const double value) const |
|
|
{ |
|
|
Finley_SystemMatrix* system_matrix_ptr = getFinley_SystemMatrix(); |
|
|
Finley_SystemMatrix_setValues(system_matrix_ptr,value); |
|
|
checkFinleyError(); |
|
|
} |
|
|
|
|
|
|
|
95 |
} // end of namespace |
} // end of namespace |