14 #ifdef HAVE_STOKHOS_ISORROPIA
15 #include "Isorropia_Epetra.hpp"
24 int k_begin_,
int k_end_) :
27 globalMultiComm(globalMultiComm_),
63 int k_begin_,
int k_end_) :
66 globalMultiComm(globalMultiComm_),
69 stoch_row_map(stoch_row_map_),
70 Cijk_parallel(Cijk_parallel_)
96 int k_begin_,
int k_end_) :
97 basis(epetraCijk.basis),
98 Cijk(epetraCijk.Cijk),
99 globalMultiComm(epetraCijk.globalMultiComm),
100 num_global_stoch_blocks(epetraCijk.num_global_stoch_blocks),
103 stoch_comm(epetraCijk.stoch_comm),
104 is_parallel(epetraCijk.is_parallel),
105 stoch_row_map(epetraCijk.stoch_row_map)
127 #ifdef HAVE_STOKHOS_ISORROPIA
131 *stoch_graph, isorropia_params));
132 stoch_graph = rebalanced_graph;
135 stoch_row_map =
Teuchos::rcp(&(stoch_graph->RowMap()),
false);
136 stoch_col_map =
Teuchos::rcp(&(stoch_graph->ColMap()),
false);
139 Cijk_parallel = buildParallelCijk();
142 "Error! Stokhos must be configured with " <<
143 "isorropia support to rebalance the stochastic " <<
153 int *rowIndices = stoch_row_map->MyGlobalElements();
154 int myBlockRows = stoch_row_map->NumMyElements();
155 for (
int i=0; i<myBlockRows; i++) {
156 int myRow = rowIndices[i];
159 k_it != Cijk->k_end(i_it); ++k_it) {
161 if (k >= k_begin && k < k_end) {
163 j_it != Cijk->j_end(k_it); ++j_it) {
165 double c = value(j_it);
166 Cijk_tmp->add_term(myRow, j, k, c);
171 Cijk_tmp->fillComplete();
182 i_it != Cijk_parallel->i_end(); ++i_it) {
183 int i = stoch_row_map->LID(index(i_it));
185 "Error! Global row index " << index(i_it) <<
186 " is not on processor " << globalMultiComm->MyPID());
188 k_it != Cijk_parallel->k_end(i_it); ++k_it) {
191 j_it != Cijk_parallel->j_end(k_it); ++j_it) {
192 int j= stoch_col_map->LID(index(j_it));
194 "Error! Global col index " << index(j_it) <<
195 " is not on processor " << globalMultiComm->MyPID());
196 double c = value(j_it);
197 Cijk_tmp->add_term(i, j, k, c);
201 Cijk_tmp->fillComplete();
203 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.