Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
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>
35
36#include <cusp/detail/spectral_radius.h>
38
39namespace cusp
40{
41namespace precond
42{
43namespace aggregation
44{
45
51template <typename IndexType, typename ValueType, typename MemorySpace>
52struct amg_container {};
53
54template <typename IndexType, typename ValueType>
55struct 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
62template <typename IndexType, typename ValueType>
63struct 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
73template<typename MatrixType>
75{
76 typedef typename MatrixType::index_type IndexType;
77 typedef typename MatrixType::value_type ValueType;
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
87
88 template<typename SA_Level_Type>
90};
91
92
97//typename SmootherType = cusp::relaxation::block_polynomial<ValueType,MemorySpace>
98template <typename IndexType, typename ValueType, typename MemorySpace,
99 typename SmootherType,
101class block_smoothed_aggregation : public cusp::block_multilevel< typename amg_container<IndexType,ValueType,MemorySpace>::solve_type, SmootherType, SolverType>
102{
103
107
108public:
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
123protected:
124
125 template <typename MatrixType, typename ArrayType>
126 void init(const MatrixType& A, const ArrayType& B);
127
129};
133} // end namespace aggregation
134} // end namespace precond
135} // end namespace cusp
136
137#include <cusp/precond/block_smoothed_aggregation.inl>
MatrixType::index_type IndexType
MatrixType::value_type ValueType
block_smoothed_aggregation(const block_smoothed_aggregation< IndexType, ValueType, MemorySpace2, SmootherType2, SolverType2 > &M)
block_smoothed_aggregation(const MatrixType &A, const ArrayType &B, const IndexType numRHS, const ValueType theta=0)
void init(const MatrixType &A, const ArrayType &B)
amg_container< IndexType, ValueType, MemorySpace >::setup_type SetupMatrixType
amg_container< IndexType, ValueType, MemorySpace >::solve_type SolveMatrixType
block_smoothed_aggregation(const MatrixType &A, const IndexType numRHS, const ValueType theta=0)
cusp::block_multilevel< SolveMatrixType, SmootherType, SolverType > Parent
cusp::array1d< ValueType, MemorySpace > B
cusp::array1d< IndexType, MemorySpace > aggregates