Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
block_smoothed_aggregation.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 
26 #include <vector> // TODO replace with host_vector
27 #include <cusp/linear_operator.h>
28 
29 #include <cusp/coo_matrix.h>
30 #include <cusp/csr_matrix.h>
31 #include <cusp/hyb_matrix.h>
32 #include <cusp/block_multilevel.h>
35 
36 #include <cusp/detail/spectral_radius.h>
37 #include <cusp/detail/block_lu.h>
38 
39 namespace cusp
40 {
41 namespace precond
42 {
43 namespace aggregation
44 {
45 
51 template <typename IndexType, typename ValueType, typename MemorySpace>
52 struct amg_container {};
53 
54 template <typename IndexType, typename ValueType>
55 struct amg_container<IndexType,ValueType,cusp::host_memory>
56 {
57  // use CSR on host
58  typedef typename cusp::csr_matrix<IndexType,ValueType,cusp::host_memory> setup_type;
59  typedef typename cusp::csr_matrix<IndexType,ValueType,cusp::host_memory> solve_type;
60 };
61 
62 template <typename IndexType, typename ValueType>
63 struct amg_container<IndexType,ValueType,cusp::device_memory>
64 {
65  // use COO on device
66 // typedef typename cusp::coo_matrix<IndexType,ValueType,cusp::device_memory> setup_type;
67 // typedef typename cusp::hyb_matrix<IndexType,ValueType,cusp::device_memory> solve_type;
68  typedef typename cusp::csr_matrix<IndexType,ValueType,cusp::device_memory> setup_type;
69  typedef typename cusp::csr_matrix<IndexType,ValueType,cusp::device_memory> solve_type;
70 
71 };
72 
73 template<typename MatrixType>
74 struct sa_level
75 {
76  typedef typename MatrixType::index_type IndexType;
78  typedef typename MatrixType::memory_space MemorySpace;
79 
80  MatrixType A_; // matrix
81  cusp::array1d<IndexType,MemorySpace> aggregates; // aggregates
82  cusp::array1d<ValueType,MemorySpace> B; // near-nullspace candidates
83 
85 
86  sa_level() {}
87 
88  template<typename SA_Level_Type>
90 };
91 
92 
97 //typename SmootherType = cusp::relaxation::block_polynomial<ValueType,MemorySpace>
98 template <typename IndexType, typename ValueType, typename MemorySpace,
99  typename SmootherType,
101 class block_smoothed_aggregation : public cusp::block_multilevel< typename amg_container<IndexType,ValueType,MemorySpace>::solve_type, SmootherType, SolverType>
102 {
103 
107 
108 public:
109 
112  std::vector< sa_level<SetupMatrixType> > sa_levels;
113 
114  template <typename MatrixType>
115  block_smoothed_aggregation(const MatrixType& A, const IndexType numRHS, const ValueType theta=0);
116 
117  template <typename MatrixType, typename ArrayType>
118  block_smoothed_aggregation(const MatrixType& A, const ArrayType& B, const IndexType numRHS, const ValueType theta=0);
119 
120  template <typename MemorySpace2,typename SmootherType2,typename SolverType2>
122 
123 protected:
124 
125  template <typename MatrixType, typename ArrayType>
126  void init(const MatrixType& A, const ArrayType& B);
127 
128  void extend_hierarchy(void);
129 };
133 } // end namespace aggregation
134 } // end namespace precond
135 } // end namespace cusp
136 
137 #include <cusp/precond/block_smoothed_aggregation.inl>
cusp::precond::aggregation::amg_container< IndexType, ValueType, cusp::device_memory >::solve_type
cusp::csr_matrix< IndexType, ValueType, cusp::device_memory > solve_type
Definition: block_smoothed_aggregation.h:69
cusp::block_multilevel
Definition: block_multilevel.h:34
cusp::precond::aggregation::sa_level::sa_level
sa_level()
Definition: block_smoothed_aggregation.h:86
cusp::precond::aggregation::block_smoothed_aggregation::theta
ValueType theta
Definition: block_smoothed_aggregation.h:110
cusp
Definition: block_monitor.h:37
cusp::precond::aggregation::sa_level::rho_DinvA
ValueType rho_DinvA
Definition: block_smoothed_aggregation.h:84
cusp::precond::aggregation::amg_container
Definition: block_smoothed_aggregation.h:52
block_lu.h
cusp::precond::aggregation::block_smoothed_aggregation::sa_levels
std::vector< sa_level< SetupMatrixType > > sa_levels
Definition: block_smoothed_aggregation.h:112
cusp::precond::aggregation::amg_container< IndexType, ValueType, cusp::device_memory >::setup_type
cusp::csr_matrix< IndexType, ValueType, cusp::device_memory > setup_type
Definition: block_smoothed_aggregation.h:68
cusp::precond::aggregation::amg_container< IndexType, ValueType, cusp::host_memory >::setup_type
cusp::csr_matrix< IndexType, ValueType, cusp::host_memory > setup_type
Definition: block_smoothed_aggregation.h:58
TotalOrderBasisUnitTest::value_type
double value_type
Definition: Stokhos_LexicographicTreeBasisUnitTest.cpp:70
cusp::precond::aggregation::block_smoothed_aggregation::init
void init(const MatrixType &A, const ArrayType &B)
cusp::precond::aggregation::block_smoothed_aggregation::SetupMatrixType
amg_container< IndexType, ValueType, MemorySpace >::setup_type SetupMatrixType
Definition: block_smoothed_aggregation.h:104
cusp::precond::aggregation::block_smoothed_aggregation::Parent
cusp::block_multilevel< SolveMatrixType, SmootherType, SolverType > Parent
Definition: block_smoothed_aggregation.h:106
cusp::precond::aggregation::block_smoothed_aggregation::SolveMatrixType
amg_container< IndexType, ValueType, MemorySpace >::solve_type SolveMatrixType
Definition: block_smoothed_aggregation.h:105
cusp::precond::aggregation::sa_level::sa_level
sa_level(const SA_Level_Type &sa_level)
Definition: block_smoothed_aggregation.h:89
cusp::precond::aggregation::sa_level::aggregates
cusp::array1d< IndexType, MemorySpace > aggregates
Definition: block_smoothed_aggregation.h:81
cusp::detail::block_lu_solver
Definition: block_lu.h:124
cusp::precond::aggregation::sa_level::MemorySpace
MatrixType::memory_space MemorySpace
Definition: block_smoothed_aggregation.h:78
block_multilevel.h
cusp::precond::aggregation::block_smoothed_aggregation::numRHS
IndexType numRHS
Definition: block_smoothed_aggregation.h:111
cusp::block_multilevel< amg_container< IndexType, ValueType, MemorySpace >::solve_type, SmootherType, SolverType >::ValueType
amg_container< IndexType, ValueType, MemorySpace >::solve_type ::value_type ValueType
Definition: block_multilevel.h:41
cusp::precond::aggregation::sa_level
Definition: block_smoothed_aggregation.h:74
cusp::precond::aggregation::sa_level::ValueType
MatrixType::value_type ValueType
Definition: block_smoothed_aggregation.h:77
cusp::precond::aggregation::amg_container< IndexType, ValueType, cusp::host_memory >::solve_type
cusp::csr_matrix< IndexType, ValueType, cusp::host_memory > solve_type
Definition: block_smoothed_aggregation.h:59
cusp::precond::aggregation::block_smoothed_aggregation
Definition: block_smoothed_aggregation.h:101
cusp::precond::aggregation::block_smoothed_aggregation::block_smoothed_aggregation
block_smoothed_aggregation(const MatrixType &A, const IndexType numRHS, const ValueType theta=0)
cusp::block_multilevel< amg_container< IndexType, ValueType, MemorySpace >::solve_type, SmootherType, SolverType >::IndexType
amg_container< IndexType, ValueType, MemorySpace >::solve_type ::index_type IndexType
Definition: block_multilevel.h:40
cusp::precond::aggregation::block_smoothed_aggregation::extend_hierarchy
void extend_hierarchy(void)
A
cusp::precond::aggregation::sa_level::A_
MatrixType A_
Definition: block_smoothed_aggregation.h:80
block_jacobi.h
block_polynomial.h
cusp::precond::aggregation::sa_level::IndexType
MatrixType::index_type IndexType
Definition: block_smoothed_aggregation.h:76
cusp::precond::aggregation::sa_level::B
cusp::array1d< ValueType, MemorySpace > B
Definition: block_smoothed_aggregation.h:82
B