Stokhos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
Stokhos_AdaptivityManager.hpp
Go to the documentation of this file.
1// $Id$
2// $Source$
3// @HEADER
4// ***********************************************************************
5//
6// Stokhos Package
7// Copyright (2009) Sandia Corporation
8//
9// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
10// license for use of this work by or on behalf of the U.S. Government.
11//
12// Redistribution and use in source and binary forms, with or without
13// modification, are permitted provided that the following conditions are
14// met:
15//
16// 1. Redistributions of source code must retain the above copyright
17// notice, this list of conditions and the following disclaimer.
18//
19// 2. Redistributions in binary form must reproduce the above copyright
20// notice, this list of conditions and the following disclaimer in the
21// documentation and/or other materials provided with the distribution.
22//
23// 3. Neither the name of the Corporation nor the names of the
24// contributors may be used to endorse or promote products derived from
25// this software without specific prior written permission.
26//
27// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
28// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
31// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
34// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
35// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
36// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
37// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38//
39// Questions? Contact Eric T. Phipps (etphipp@sandia.gov).
40//
41// ***********************************************************************
42// @HEADER
43
44#ifndef STOKHOS_AdaptivityManager_HPP
45#define STOKHOS_AdaptivityManager_HPP
46
47#include "Stokhos_config.h"
53
54#include "Epetra_Map.h"
55#include "Epetra_CrsGraph.h"
56#include "Epetra_CrsMatrix.h"
57
58#include "Teuchos_RCP.hpp"
59#include "Teuchos_Array.hpp"
60
61#include <vector>
62
63#ifdef HAVE_STOKHOS_BOOST
64#include <boost/unordered_map.hpp>
65#endif
66
67namespace Stokhos {
68
72 public:
74 const Teuchos::RCP<const Stokhos::ProductBasis<int,double> >& sg_master_basis,
75 const std::vector<Teuchos::RCP<const Stokhos::ProductBasis<int,double> > > & sg_basis_row_dof,
76 const Epetra_CrsGraph & determ_graph,
77 bool onlyUseLinear,int kExpOrder,
78 bool scaleOp=true);
79
81 const Teuchos::RCP<const Stokhos::ProductBasis<int,double> >& sg_master_basis,
82 const std::vector<Teuchos::RCP<const Stokhos::ProductBasis<int,double> > > & sg_basis_row_dof,
83 const Epetra_Comm & comm,
84 bool scaleOp=true);
85
97 inline int getGlobalColId(int determLid,int basisIndex) const
98 { return myColGidOffsets_[determLid]+basisIndex; }
99
111 inline int getGlobalRowId(int determLid,int basisIndex) const
112 { return myRowGidOffsets_[determLid]+basisIndex; }
113
116 Teuchos::RCP<Epetra_CrsMatrix> buildMatrixFromGraph() const;
117
120 void setupWithGraph(const Epetra_CrsGraph & graph,bool onlyUseLinear,int kExpOrder);
121
124 Teuchos::RCP<const Epetra_Map> getAdaptedMap() const
125 { return rowMap_; }
126
130 bool onlyUseLinear=false,bool includeMean=true) const;
131
135 void sumInOperator(Epetra_CrsMatrix & A,const Stokhos::Sparse3Tensor<int,double> & Cijk,int k,const Epetra_CrsMatrix & J_k) const;
136
140
144
148 int getRowStochasticBasisSize(int determLid) const
149 { return sg_basis_row_dof_[determLid]->size(); }
150
154 int getColStochasticBasisSize(int determLid) const
155 { return sg_basis_col_dof_[determLid]->size(); }
156
159 Teuchos::RCP<const Stokhos::ProductBasis<int,double> > getMasterStochasticBasis() const
160 { return sg_master_basis_; }
161
164 Teuchos::RCP<const Stokhos::ProductBasis<int,double> > getRowStochasticBasis(int determLid) const
165 { return sg_basis_row_dof_[determLid]; }
166
169 const std::vector<Teuchos::RCP<const Stokhos::ProductBasis<int,double> > > & getRowStochasticBasis() const
170 { return sg_basis_row_dof_; }
171
174 Teuchos::RCP<const Stokhos::ProductBasis<int,double> > getColStochasticBasis(int determLid) const
175 { return sg_basis_col_dof_[determLid]; }
176
177 bool isScaled()
178 { return scaleOp_; }
179
180 private:
181
188 public:
190
191 double getValue(int i,int j,int k) const;
192
193 private:
194 #ifdef HAVE_STOKHOS_BOOST
195 struct IJK {
196 int i_,j_,k_;
197 IJK(int i,int j,int k) : i_(i), j_(j), k_(k) {}
198
199 bool operator==(const IJK & ijk) const
200 { return i_==ijk.i_ && j_==ijk.j_ && k_==ijk.k_; }
201 };
202
203 struct IJKHash {
204 std::size_t operator()(const IJK & ijk) const;
205 };
206
207 boost::unordered_map<IJK,double,IJKHash> hashMap_;
208 #else
210 #endif
211 };
212
216 void sumInOperator(Epetra_CrsMatrix & A,const Sparse3TensorHash & Cijk,int k,const Epetra_CrsMatrix & J_k) const;
217
218 Teuchos::RCP<const Stokhos::ProductBasis<int,double> > sg_master_basis_;
219 std::vector<Teuchos::RCP<const Stokhos::ProductBasis<int,double> > > sg_basis_row_dof_;
220 std::vector<Teuchos::RCP<const Stokhos::ProductBasis<int,double> > > sg_basis_col_dof_;
221
222 std::vector<int> myRowGidOffsets_;
223 std::vector<int> myColGidOffsets_;
224
225 Teuchos::RCP<Epetra_CrsGraph> graph_;
226 Teuchos::RCP<Epetra_Map> rowMap_;
227
229 };
230
231} // namespace Stokhos
232
233#endif // STOKHOS_AdaptivityUtils_HPP
const Stokhos::Sparse3Tensor< int, double > & Cijk_
Teuchos::RCP< const Stokhos::ProductBasis< int, double > > getMasterStochasticBasis() const
Teuchos::RCP< const Stokhos::ProductBasis< int, double > > sg_master_basis_
Teuchos::RCP< Epetra_CrsMatrix > buildMatrixFromGraph() const
Teuchos::RCP< Epetra_Map > rowMap_
void setupOperator(Epetra_CrsMatrix &A, const Sparse3Tensor< int, double > &Cijk, Stokhos::EpetraOperatorOrthogPoly &poly, bool onlyUseLinear=false, bool includeMean=true) const
Teuchos::RCP< Epetra_CrsGraph > graph_
Teuchos::RCP< const Stokhos::ProductBasis< int, double > > getColStochasticBasis(int determLid) const
void copyToAdaptiveVector(const Stokhos::EpetraVectorOrthogPoly &x_sg, Epetra_Vector &x) const
Teuchos::RCP< const Stokhos::ProductBasis< int, double > > getRowStochasticBasis(int determLid) const
Teuchos::RCP< const Epetra_Map > getAdaptedMap() const
int getColStochasticBasisSize(int determLid) const
void copyFromAdaptiveVector(const Epetra_Vector &x, Stokhos::EpetraVectorOrthogPoly &x_sg) const
void setupWithGraph(const Epetra_CrsGraph &graph, bool onlyUseLinear, int kExpOrder)
int getGlobalColId(int determLid, int basisIndex) const
int getRowStochasticBasisSize(int determLid) const
void sumInOperator(Epetra_CrsMatrix &A, const Stokhos::Sparse3Tensor< int, double > &Cijk, int k, const Epetra_CrsMatrix &J_k) const
std::vector< Teuchos::RCP< const Stokhos::ProductBasis< int, double > > > sg_basis_col_dof_
const std::vector< Teuchos::RCP< const Stokhos::ProductBasis< int, double > > > & getRowStochasticBasis() const
std::vector< Teuchos::RCP< const Stokhos::ProductBasis< int, double > > > sg_basis_row_dof_
int getGlobalRowId(int determLid, int basisIndex) const
A container class storing an orthogonal polynomial whose coefficients are vectors,...
A container class storing an orthogonal polynomial whose coefficients are vectors,...
Abstract base class for multivariate orthogonal polynomials generated from tensor products of univari...
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
Top-level namespace for Stokhos classes and functions.