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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (hide annotations)
Tue Oct 26 06:53:54 2004 UTC (18 years, 5 months ago) by jgs
File size: 3933 byte(s)
Initial revision

1 jgs 82 /*
2     ******************************************************************************
3     * *
4     * COPYRIGHT ACcESS 2004 - All Rights Reserved *
5     * *
6     * This software is the property of ACcESS. No part of this code *
7     * may be copied in any form or by any means without the expressed written *
8     * consent of ACcESS. Copying, use or modification of this software *
9     * by any unauthorised person is illegal unless that person has a software *
10     * license agreement with ACcESS. *
11     * *
12     ******************************************************************************
13     */
14     extern "C" {
15     #include "finley/finleyC/System.h"
16     }
17     #include "escript/Data/Data.h"
18     #include "finley/CPPAdapter/SystemMatrixAdapter.h"
19     #include "finley/CPPAdapter/FinleyAdapterException.h"
20     #include "finley/CPPAdapter/FinleyError.h"
21     #include <boost/python/extract.hpp>
22    
23     using namespace std;
24    
25     namespace finley {
26    
27     SystemMatrixAdapter::SystemMatrixAdapter()
28     {
29     throw FinleyAdapterException("Error - Illegal to generate default SystemMatrixAdapter.");
30     }
31    
32     SystemMatrixAdapter::SystemMatrixAdapter(const Finley_SystemMatrix* system_matrix,
33     const int row_blocksize,
34     const escript::FunctionSpace& row_functionspace,
35     const int column_blocksize,
36     const escript::FunctionSpace& column_functionspace):
37     AbstractSystemMatrix(row_blocksize,row_functionspace,column_blocksize,column_functionspace),
38     m_system_matrix(system_matrix)
39     {
40     }
41    
42     SystemMatrixAdapter::~SystemMatrixAdapter()
43     {
44     if (m_system_matrix.unique()) {
45     Finley_SystemMatrix* mat=m_system_matrix.get();
46     Finley_SystemMatrix_dealloc(mat);
47     }
48     }
49    
50     Finley_SystemMatrix* SystemMatrixAdapter::getFinley_SystemMatrix() const
51     {
52     return m_system_matrix.get();
53     }
54    
55     void SystemMatrixAdapter::ypAx(escript::Data& y, const escript::Data& x) const
56     {
57     Finley_SystemMatrix* mat=getFinley_SystemMatrix();
58     Finley_SystemMatrixVector(&(y.getDataC()),mat,&(x.getDataC()));
59     checkFinleyError();
60     }
61    
62     void SystemMatrixAdapter::setToSolution(escript::Data& out, const escript::Data& in, const boost::python::dict& options) const
63     {
64     Finley_SolverOptions finley_options;
65     Finley_SystemMatrix_setDefaults(&finley_options);
66     // extract options
67     #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);
69     EXTRACT("reordering",reordering,int);
70     EXTRACT("tolerance",tolerance,double);
71     EXTRACT("iterative_method",iterative_method,int);
72     EXTRACT("preconditioner",preconditioner,int);
73     EXTRACT("iter_max",iter_max,int);
74     EXTRACT("drop_tolerance",drop_tolerance,double);
75     EXTRACT("drop_storage",drop_storage,double);
76     EXTRACT("iterative",iterative,int);
77     #undef EXTRACT
78     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();
84     }
85    
86     void SystemMatrixAdapter::nullifyRowsAndCols(const escript::Data& row_q, const escript::Data& col_q, const double mdv) const
87     {
88     Finley_SystemMatrix* system_matrix_ptr = getFinley_SystemMatrix();
89     escriptDataC row_qC = row_q.getDataC();
90     escriptDataC col_qC = col_q.getDataC();
91    
92     Finley_SystemMatrix_nullifyRowsAndCols(system_matrix_ptr, &row_qC, &col_qC, mdv);
93     }
94    
95     } // end of namespace

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26