Stokhos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Stokhos_AdaptivityManager.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 
10 #ifndef STOKHOS_AdaptivityManager_HPP
11 #define STOKHOS_AdaptivityManager_HPP
12 
13 #include "Stokhos_config.h"
15 #include "Stokhos_ProductBasis.hpp"
16 #include "Stokhos_SGOperator.hpp"
19 
20 #include "Epetra_Map.h"
21 #include "Epetra_CrsGraph.h"
22 #include "Epetra_CrsMatrix.h"
23 
24 #include "Teuchos_RCP.hpp"
25 #include "Teuchos_Array.hpp"
26 
27 #include <vector>
28 
29 #ifdef HAVE_STOKHOS_BOOST
30 #include <boost/unordered_map.hpp>
31 #endif
32 
33 namespace Stokhos {
34 
38  public:
40  const Teuchos::RCP<const Stokhos::ProductBasis<int,double> >& sg_master_basis,
41  const std::vector<Teuchos::RCP<const Stokhos::ProductBasis<int,double> > > & sg_basis_row_dof,
42  const Epetra_CrsGraph & determ_graph,
43  bool onlyUseLinear,int kExpOrder,
44  bool scaleOp=true);
45 
47  const Teuchos::RCP<const Stokhos::ProductBasis<int,double> >& sg_master_basis,
48  const std::vector<Teuchos::RCP<const Stokhos::ProductBasis<int,double> > > & sg_basis_row_dof,
49  const Epetra_Comm & comm,
50  bool scaleOp=true);
51 
63  inline int getGlobalColId(int determLid,int basisIndex) const
64  { return myColGidOffsets_[determLid]+basisIndex; }
65 
77  inline int getGlobalRowId(int determLid,int basisIndex) const
78  { return myRowGidOffsets_[determLid]+basisIndex; }
79 
83 
86  void setupWithGraph(const Epetra_CrsGraph & graph,bool onlyUseLinear,int kExpOrder);
87 
91  { return rowMap_; }
92 
96  bool onlyUseLinear=false,bool includeMean=true) const;
97 
101  void sumInOperator(Epetra_CrsMatrix & A,const Stokhos::Sparse3Tensor<int,double> & Cijk,int k,const Epetra_CrsMatrix & J_k) const;
102 
106 
110 
114  int getRowStochasticBasisSize(int determLid) const
115  { return sg_basis_row_dof_[determLid]->size(); }
116 
120  int getColStochasticBasisSize(int determLid) const
121  { return sg_basis_col_dof_[determLid]->size(); }
122 
126  { return sg_master_basis_; }
127 
131  { return sg_basis_row_dof_[determLid]; }
132 
135  const std::vector<Teuchos::RCP<const Stokhos::ProductBasis<int,double> > > & getRowStochasticBasis() const
136  { return sg_basis_row_dof_; }
137 
141  { return sg_basis_col_dof_[determLid]; }
142 
143  bool isScaled()
144  { return scaleOp_; }
145 
146  private:
147 
154  public:
156 
157  double getValue(int i,int j,int k) const;
158 
159  private:
160  #ifdef HAVE_STOKHOS_BOOST
161  struct IJK {
162  int i_,j_,k_;
163  IJK(int i,int j,int k) : i_(i), j_(j), k_(k) {}
164 
165  bool operator==(const IJK & ijk) const
166  { return i_==ijk.i_ && j_==ijk.j_ && k_==ijk.k_; }
167  };
168 
169  struct IJKHash {
170  std::size_t operator()(const IJK & ijk) const;
171  };
172 
173  boost::unordered_map<IJK,double,IJKHash> hashMap_;
174  #else
176  #endif
177  };
178 
182  void sumInOperator(Epetra_CrsMatrix & A,const Sparse3TensorHash & Cijk,int k,const Epetra_CrsMatrix & J_k) const;
183 
185  std::vector<Teuchos::RCP<const Stokhos::ProductBasis<int,double> > > sg_basis_row_dof_;
186  std::vector<Teuchos::RCP<const Stokhos::ProductBasis<int,double> > > sg_basis_col_dof_;
187 
188  std::vector<int> myRowGidOffsets_;
189  std::vector<int> myColGidOffsets_;
190 
193 
194  bool scaleOp_;
195  };
196 
197 } // namespace Stokhos
198 
199 #endif // STOKHOS_AdaptivityUtils_HPP
Teuchos::RCP< const Stokhos::ProductBasis< int, double > > getColStochasticBasis(int determLid) const
A container class storing an orthogonal polynomial whose coefficients are vectors, operators, or in general any type that would have an expensive copy constructor.
std::vector< Teuchos::RCP< const Stokhos::ProductBasis< int, double > > > sg_basis_col_dof_
std::vector< Teuchos::RCP< const Stokhos::ProductBasis< int, double > > > sg_basis_row_dof_
bool operator==(const aligned_allocator< T > &, const aligned_allocator< U > &)
const Stokhos::Sparse3Tensor< int, double > & Cijk_
Teuchos::RCP< const Stokhos::ProductBasis< int, double > > getRowStochasticBasis(int determLid) const
void setupOperator(Epetra_CrsMatrix &A, const Sparse3Tensor< int, double > &Cijk, Stokhos::EpetraOperatorOrthogPoly &poly, bool onlyUseLinear=false, bool includeMean=true) const
Teuchos::RCP< const Epetra_Map > getAdaptedMap() const
void copyFromAdaptiveVector(const Epetra_Vector &x, Stokhos::EpetraVectorOrthogPoly &x_sg) const
void copyToAdaptiveVector(const Stokhos::EpetraVectorOrthogPoly &x_sg, Epetra_Vector &x) const
int getGlobalColId(int determLid, int basisIndex) const
A container class storing an orthogonal polynomial whose coefficients are vectors, operators, or in general any type that would have an expensive copy constructor.
int getColStochasticBasisSize(int determLid) const
Sparse3TensorHash(const Stokhos::Sparse3Tensor< int, double > &Cijk)
void setupWithGraph(const Epetra_CrsGraph &graph, bool onlyUseLinear, int kExpOrder)
int getRowStochasticBasisSize(int determLid) const
Teuchos::RCP< Epetra_CrsMatrix > buildMatrixFromGraph() const
Teuchos::RCP< const Stokhos::ProductBasis< int, double > > sg_master_basis_
Teuchos::RCP< Epetra_CrsGraph > graph_
Teuchos::RCP< const Stokhos::ProductBasis< int, double > > getMasterStochasticBasis() const
void sumInOperator(Epetra_CrsMatrix &A, const Stokhos::Sparse3Tensor< int, double > &Cijk, int k, const Epetra_CrsMatrix &J_k) const
Teuchos::RCP< Epetra_Map > rowMap_
int getGlobalRowId(int determLid, int basisIndex) const
AdaptivityManager(const Teuchos::RCP< const Stokhos::ProductBasis< int, double > > &sg_master_basis, const std::vector< Teuchos::RCP< const Stokhos::ProductBasis< int, double > > > &sg_basis_row_dof, const Epetra_CrsGraph &determ_graph, bool onlyUseLinear, int kExpOrder, bool scaleOp=true)
const std::vector< Teuchos::RCP< const Stokhos::ProductBasis< int, double > > > & getRowStochasticBasis() const