/[escript]/trunk/cusplibrary/cusp/multilevel.h
ViewVC logotype

Annotation of /trunk/cusplibrary/cusp/multilevel.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5148 - (hide annotations)
Mon Sep 15 01:25:23 2014 UTC (5 years, 9 months ago) by caltinay
File MIME type: text/plain
File size: 2864 byte(s)
Merging ripley diagonal storage + CUDA support into trunk.
Options file version has been incremented due to new options
'cuda' and 'nvccflags'.

1 caltinay 4955 /*
2     * Copyright 2008-2009 NVIDIA Corporation
3     *
4     * Licensed under the Apache License, Version 2.0 (the "License");
5     * you may not use this file except in compliance with the License.
6     * You may obtain a copy of the License at
7     *
8     * http://www.apache.org/licenses/LICENSE-2.0
9     *
10     * Unless required by applicable law or agreed to in writing, software
11     * distributed under the License is distributed on an "AS IS" BASIS,
12     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     * See the License for the specific language governing permissions and
14     * limitations under the License.
15     */
16    
17     /*! \file multilevel.h
18     * \brief Multilevel hierarchy
19     *
20     */
21    
22     #pragma once
23    
24     #include <cusp/detail/config.h>
25     #include <cusp/detail/lu.h>
26    
27     #include <cusp/array1d.h>
28     #include <cusp/linear_operator.h>
29    
30     namespace cusp
31     {
32    
33     /*! \addtogroup iterative_solvers Multilevel hiearchy
34     * \ingroup iterative_solvers
35     * \{
36     */
37    
38     /*! \p multilevel : multilevel hierarchy
39     *
40     *
41     * TODO
42     */
43     template <typename MatrixType, typename SmootherType, typename SolverType>
44     class multilevel : public cusp::linear_operator<typename MatrixType::value_type,
45     typename MatrixType::memory_space>
46     {
47     public:
48    
49     typedef typename MatrixType::index_type IndexType;
50     typedef typename MatrixType::value_type ValueType;
51     typedef typename MatrixType::memory_space MemorySpace;
52    
53     struct level
54     {
55     MatrixType R; // restriction operator
56     MatrixType A; // matrix
57     MatrixType P; // prolongation operator
58     cusp::array1d<ValueType,MemorySpace> x; // per-level solution
59     cusp::array1d<ValueType,MemorySpace> b; // per-level rhs
60     cusp::array1d<ValueType,MemorySpace> residual; // per-level residual
61    
62     SmootherType smoother;
63    
64     level(){}
65    
66     template<typename Level_Type>
67     level(const Level_Type& level) : R(level.R), A(level.A), P(level.P), x(level.x), b(level.b), residual(level.residual), smoother(level.smoother){}
68     };
69    
70     SolverType solver;
71    
72     std::vector<level> levels;
73    
74     multilevel(){};
75    
76     template <typename MatrixType2, typename SmootherType2, typename SolverType2>
77     multilevel(const multilevel<MatrixType2, SmootherType2, SolverType2>& M);
78    
79     template <typename Array1, typename Array2>
80     void operator()(const Array1& x, Array2& y);
81    
82     template <typename Array1, typename Array2>
83     void solve(const Array1& b, Array2& x);
84    
85     template <typename Array1, typename Array2, typename Monitor>
86     void solve(const Array1& b, Array2& x, Monitor& monitor);
87    
88     void print( void );
89    
90     double operator_complexity( void );
91    
92     double grid_complexity( void );
93    
94     protected:
95    
96     template <typename Array1, typename Array2>
97     void _solve(const Array1& b, Array2& x, const size_t i);
98     };
99     /*! \}
100     */
101    
102     } // end namespace cusp
103    
104     #include <cusp/detail/multilevel.inl>
105    

  ViewVC Help
Powered by ViewVC 1.1.26