Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
block_multilevel.h
Go to the documentation of this file.
1 /*
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 
22 #pragma once
23 
24 #include <cusp/detail/config.h>
25 #include <cusp/detail/lu.h>
26 #include <cusp/array2d.h>
27 #include <cusp/array1d.h>
28 #include <cusp/linear_operator.h>
29 
30 namespace cusp
31 {
32 
33 template <typename MatrixType, typename SmootherType, typename SolverType>
35  public cusp::linear_operator<typename MatrixType::value_type,
36  typename MatrixType::memory_space>
37 {
38 public:
39 
40  typedef typename MatrixType::index_type IndexType;
42  typedef typename MatrixType::memory_space MemorySpace;
43  typedef typename SmootherType::orientation Orientation;
44 
45  struct level
46  {
47  MatrixType R; // restriction operator
48  MatrixType A; // matrix
49  MatrixType P; // prolongation operator
50  cusp::array2d<ValueType,MemorySpace,Orientation> x; // per-level solution
51  cusp::array2d<ValueType,MemorySpace,Orientation> b; // per-level rhs
52  cusp::array2d<ValueType,MemorySpace,Orientation> residual; // per-level residual
53 
54  SmootherType smoother;
55 
56  level(){}
57 
58  template<typename Level_Type>
59  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){}
60  };
61 
62  SolverType solver;
63 
64  std::vector<level> levels;
65 
67 
68  template <typename MatrixType2, typename SmootherType2, typename SolverType2>
70 
71  template <typename Array1, typename Array2>
72  void operator()(const Array1& x, Array2& y);
73 
74  template <typename Array1, typename Array2>
75  void solve(const Array1& b, Array2& x);
76 
77  template <typename Array1, typename Array2, typename Monitor>
78  void solve(const Array1& b, Array2& x, Monitor& monitor);
79 
80  void print( void );
81 
82  double operator_complexity( void );
83 
84  double grid_complexity( void );
85 
86 protected:
87 
88  template <typename Array1, typename Array2>
89  void _solve(const Array1& b, Array2& x, const size_t i);
90 };
94 } // end namespace cusp
95 
96 #include <cusp/block_multilevel.inl>
cusp::block_multilevel
Definition: block_multilevel.h:34
cusp::block_multilevel::level::b
cusp::array2d< ValueType, MemorySpace, Orientation > b
Definition: block_multilevel.h:51
cusp::block_multilevel::level
Definition: block_multilevel.h:45
cusp::block_multilevel::grid_complexity
double grid_complexity(void)
cusp::block_multilevel::level::smoother
SmootherType smoother
Definition: block_multilevel.h:54
cusp
Definition: block_monitor.h:37
cusp::block_multilevel::solver
SolverType solver
Definition: block_multilevel.h:62
cusp::block_multilevel::level::level
level(const Level_Type &level)
Definition: block_multilevel.h:59
TotalOrderBasisUnitTest::value_type
double value_type
Definition: Stokhos_LexicographicTreeBasisUnitTest.cpp:70
cusp::block_multilevel::solve
void solve(const Array1 &b, Array2 &x)
cusp::block_multilevel::level::A
MatrixType A
Definition: block_multilevel.h:48
cusp::block_multilevel::level::P
MatrixType P
Definition: block_multilevel.h:49
cusp::block_multilevel::print
void print(void)
cusp::block_multilevel::level::level
level()
Definition: block_multilevel.h:56
cusp::block_multilevel::ValueType
MatrixType::value_type ValueType
Definition: block_multilevel.h:41
cusp::block_multilevel::MemorySpace
MatrixType::memory_space MemorySpace
Definition: block_multilevel.h:42
cusp::block_multilevel::operator_complexity
double operator_complexity(void)
cusp::block_multilevel::levels
std::vector< level > levels
Definition: block_multilevel.h:64
cusp::block_multilevel::IndexType
MatrixType::index_type IndexType
Definition: block_multilevel.h:40
cusp::block_multilevel::Orientation
SmootherType::orientation Orientation
Definition: block_multilevel.h:43
cusp::block_multilevel::level::x
cusp::array2d< ValueType, MemorySpace, Orientation > x
Definition: block_multilevel.h:50
cusp::detail::device::x
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType * x
Definition: csr_vector.h:260
cusp::block_multilevel::level::residual
cusp::array2d< ValueType, MemorySpace, Orientation > residual
Definition: block_multilevel.h:52
cusp::block_multilevel::_solve
void _solve(const Array1 &b, Array2 &x, const size_t i)
cusp::block_multilevel::operator()
void operator()(const Array1 &x, Array2 &y)
A
cusp::block_multilevel::block_multilevel
block_multilevel()
Definition: block_multilevel.h:66
cusp::detail::device::y
const IndexType const IndexType const IndexType const IndexType const ValueType const ValueType ValueType * y
Definition: csr_vector.h:267
cusp::block_multilevel::level::R
MatrixType R
Definition: block_multilevel.h:47