46 #ifdef HAVE_STOKHOS_ISORROPIA
47 #include "Isorropia_Epetra.hpp"
56 int k_begin_,
int k_end_) :
59 globalMultiComm(globalMultiComm_),
95 int k_begin_,
int k_end_) :
98 globalMultiComm(globalMultiComm_),
101 stoch_row_map(stoch_row_map_),
102 Cijk_parallel(Cijk_parallel_)
128 int k_begin_,
int k_end_) :
129 basis(epetraCijk.basis),
130 Cijk(epetraCijk.Cijk),
131 globalMultiComm(epetraCijk.globalMultiComm),
132 num_global_stoch_blocks(epetraCijk.num_global_stoch_blocks),
135 stoch_comm(epetraCijk.stoch_comm),
136 is_parallel(epetraCijk.is_parallel),
137 stoch_row_map(epetraCijk.stoch_row_map)
159 #ifdef HAVE_STOKHOS_ISORROPIA
163 *stoch_graph, isorropia_params));
164 stoch_graph = rebalanced_graph;
167 stoch_row_map =
Teuchos::rcp(&(stoch_graph->RowMap()),
false);
168 stoch_col_map =
Teuchos::rcp(&(stoch_graph->ColMap()),
false);
171 Cijk_parallel = buildParallelCijk();
174 "Error! Stokhos must be configured with " <<
175 "isorropia support to rebalance the stochastic " <<
185 int *rowIndices = stoch_row_map->MyGlobalElements();
186 int myBlockRows = stoch_row_map->NumMyElements();
187 for (
int i=0; i<myBlockRows; i++) {
188 int myRow = rowIndices[i];
191 k_it != Cijk->k_end(i_it); ++k_it) {
193 if (k >= k_begin && k < k_end) {
195 j_it != Cijk->j_end(k_it); ++j_it) {
197 double c = value(j_it);
198 Cijk_tmp->add_term(myRow, j, k, c);
203 Cijk_tmp->fillComplete();
214 i_it != Cijk_parallel->i_end(); ++i_it) {
215 int i = stoch_row_map->LID(index(i_it));
217 "Error! Global row index " << index(i_it) <<
218 " is not on processor " << globalMultiComm->MyPID());
220 k_it != Cijk_parallel->k_end(i_it); ++k_it) {
223 j_it != Cijk_parallel->j_end(k_it); ++j_it) {
224 int j= stoch_col_map->LID(index(j_it));
226 "Error! Global col index " << index(j_it) <<
227 " is not on processor " << globalMultiComm->MyPID());
228 double c = value(j_it);
229 Cijk_tmp->add_term(i, j, k, c);
233 Cijk_tmp->fillComplete();
235 Cijk_parallel = Cijk_tmp;
Teuchos::RCP< const Epetra_CrsGraph > stoch_graph
Stochastic operator graph.
void transformToLocal()
Transform Cijk to local i and j indices.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< const Epetra_BlockMap > stoch_col_map
Stochastic col-map.
const Epetra_BlockMap & ColMap() const
Bi-directional iterator for traversing a sparse array.
EpetraSparse3Tensor(const Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > &basis, const Teuchos::RCP< const Stokhos::Sparse3Tensor< int, double > > &Cijk, const Teuchos::RCP< const EpetraExt::MultiComm > &globalMultiComm, int k_begin=0, int k_end=-1)
Constructor from a full Cijk.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Teuchos::RCP< const Cijk_type > Cijk
Triple product.
Teuchos::RCP< const EpetraExt::MultiComm > globalMultiComm
Multi-comm.
Teuchos::RCP< const Cijk_type > Cijk_parallel
Cijk tensor parallel over i.
Teuchos::RCP< const Epetra_BlockMap > stoch_row_map
Stochastic row-map.
void rebalance(Teuchos::ParameterList &isorropia_params)
Rebalance maps and graph using Isorropia.
Teuchos::RCP< const Stokhos::OrthogPolyBasis< int, double > > basis
Basis.
virtual int NumProc() const =0
Teuchos::RCP< Epetra_CrsGraph > sparse3Tensor2CrsGraph(const Stokhos::OrthogPolyBasis< ordinal_type, value_type > &basis, const Stokhos::Sparse3Tensor< ordinal_type, value_type > &Cijk, const Epetra_Comm &comm)
Build an Epetra_CrsGraph from a sparse 3 tensor.
Teuchos::RCP< const Epetra_Comm > stoch_comm
Stochastic comm.
Teuchos::RCP< Cijk_type > buildParallelCijk() const
Build parallel Cijk tensor from a parallel row map.
int num_global_stoch_blocks
Number of global stochastic blocks.
virtual ordinal_type size() const =0
Return total size of basis.
bool is_parallel
Whether stochastic blocks are parallel.