Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_BlockPreconditionerImp.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
12 
13 //Computes the exact Schur complement block LU decomposition
14 
15 template <typename ordinal_type, typename value_type>
19  K(K_),
20  p(p_),
21  m(m_)
22 {
23 }
24 
25 template <typename ordinal_type, typename value_type>
28 {
29 }
30 
31 template <typename ordinal_type, typename value_type>
35 {
36  if (n > 1)
37  return (n * facto(n-1));
38  else
39  return (1);
40 }
41 
42 template <typename ordinal_type, typename value_type>
46 {
47  //n is the polynomial order and m is the number of random variables
48  return (facto(n+m)/(facto(n)*facto(m)));
49  }
50 
51 template <typename ordinal_type, typename value_type>
56  ordinal_type n) const
57 { //Solve M*Result=Input
58  ordinal_type c=siz(p,m);
59  ordinal_type s = siz(p-1,m);
60 
61  //Split residual
64 
65  //Split Result
68 
71 
72  //rD=inv(D)r2
73 
75 
76  for (ordinal_type i=0; i<c-s; i++)
77  Dr(i,0)=r2(i,0)/D(i,i);
78 
79  ordinal_type ret = r1.multiply(Teuchos::NO_TRANS,Teuchos::NO_TRANS, -1.0, B, Dr, 1.0);
80  TEUCHOS_ASSERT(ret == 0);
81 
82  //Compute S=A-B*inv(D)*Bt
84  //Compute B*inv(D)
86  for (ordinal_type i=0; i<c-s; i++) //col
87  for (ordinal_type j=0; j<s; j++) //row
88  BinvD(j,i)=B(j,i)/D(i,i);
89 
90  S.multiply(Teuchos::NO_TRANS,Teuchos::TRANS, -1.0, BinvD, B, 1.0);
91 
96 
97 
98  // Setup solver
100  solver.setMatrix(SS);
101  solver.setVectors(w, rr);
102  //Solve S*w=r1
103  if (solver.shouldEquilibrate()) {
104  solver.factorWithEquilibration(true);
105  solver.equilibrateMatrix();
106  }
107  solver.solve();
108 
109  for (ordinal_type i=0; i<s; i++)
110  Result(i,0)=(*w)(i,0);
111 
112  ret = r2.multiply(Teuchos::TRANS,Teuchos::NO_TRANS, -1.0, B, *w, 1.0);
113  TEUCHOS_ASSERT(ret == 0);
114 
115  for (ordinal_type i=s; i<c; i++)
116  Result(i,0)=r2(-s+i,0)/D(-s+i, -s+i);
117 
118  return 0;
119 }
int multiply(ETransp transa, ETransp transb, ScalarType alpha, const SerialDenseMatrix< OrdinalType, ScalarType > &A, const SerialDenseMatrix< OrdinalType, ScalarType > &B, ScalarType beta)
ordinal_type siz(ordinal_type n, ordinal_type m) const
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
BlockPreconditioner(const Teuchos::SerialDenseMatrix< ordinal_type, value_type > &K, const ordinal_type p, const ordinal_type m)
Constructor.
void factorWithEquilibration(bool flag)
int setVectors(const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &X, const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &B)
ordinal_type facto(ordinal_type n) const
#define TEUCHOS_ASSERT(assertion_test)
int setMatrix(const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &A)
virtual ordinal_type ApplyInverse(const Teuchos::SerialDenseMatrix< ordinal_type, value_type > &Input, Teuchos::SerialDenseMatrix< ordinal_type, value_type > &Result, ordinal_type m) const
Returns the result of a Operator inverse applied to a Teuchos::SerialDenseMatrix Input in Result...