34 "complete",
"tensor",
"total",
"smolyak" };
42 "total",
"lexicographic" };
81 ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID,
82 int wgt_dim,
float *obj_wgts,
int *ierr) {
87 for (
int i=0; i<nnz; ++i) {
97 int *format,
int *ierr) {
112 *format = ZOLTAN_COMPRESSED_VERTEX;
117 int format, ZOLTAN_ID_PTR vtxGID,
int *edgePtr,
118 ZOLTAN_ID_PTR edgeGID,
int *ierr) {
151 vtxGID[vtx_idx] = vtx_idx;
152 edgePtr[vtx_idx++] = pin_idx;
153 edgeGID[pin_idx++] = i;
154 edgeGID[pin_idx++] = n +
j;
155 edgeGID[pin_idx++] = 2*n + k;
169 int rc = Zoltan_Initialize(argc,argv,&version);
175 "This example generates the sparsity pattern for the block stochastic Galerkin matrix.\n");
177 CLP.
setOption(
"dimension", &d,
"Stochastic dimension");
179 CLP.
setOption(
"order", &p,
"Polynomial order");
180 double drop = 1.0e-12;
181 CLP.
setOption(
"drop", &drop,
"Drop tolerance");
182 bool symmetric =
true;
183 CLP.
setOption(
"symmetric",
"asymmetric", &symmetric,
"Use basis polynomials with symmetric PDF");
189 CLP.
setOption(
"product_basis", &prod_basis_type,
192 "Product basis type");
194 CLP.
setOption(
"ordering", &ordering_type,
197 "Product basis ordering");
199 CLP.
setOption(
"partitioning", &partitioning_type,
202 "Partitioning Method");
203 double imbalance_tol = 1.2;
204 CLP.
setOption(
"imbalance", &imbalance_tol,
"Imbalance tolerance");
206 CLP.
setOption(
"full",
"linear", &full,
"Use full or linear expansion");
208 CLP.
setOption(
"tile_size", &tile_size,
"Tile size");
209 bool save_3tensor =
false;
210 CLP.
setOption(
"save_3tensor",
"no-save_3tensor", &save_3tensor,
211 "Save full 3tensor to file");
212 std::string file_3tensor =
"Cijk.dat";
213 CLP.
setOption(
"filename_3tensor", &file_3tensor,
214 "Filename to store full 3-tensor");
217 CLP.
parse( argc, argv );
221 const double alpha = 1.0;
222 const double beta = symmetric ? 1.0 : 2.0 ;
223 for (
int i=0; i<d; i++) {
225 p, alpha, beta,
true, growth_type));
234 else if (prod_basis_type ==
TENSOR) {
244 else if (prod_basis_type ==
TOTAL) {
254 else if (prod_basis_type ==
SMOLYAK) {
259 bases, index_set, drop));
263 bases, index_set, drop));
270 Cijk = basis->computeTripleProductTensor();
272 Cijk = basis->computeLinearTripleProductTensor();
274 int basis_size = basis->size();
275 std::cout <<
"basis size = " << basis_size
276 <<
" num nonzero Cijk entries = " << Cijk->num_entries()
280 std::ofstream cijk_file;
282 cijk_file.open(file_3tensor.c_str());
283 cijk_file.precision(14);
284 cijk_file.setf(std::ios::scientific);
285 cijk_file <<
"i, j, k, part" << std::endl;
289 Zoltan_Struct *zz = Zoltan_Create(MPI_COMM_WORLD);
292 Zoltan_Set_Param(zz,
"DEBUG_LEVEL",
"2");
295 Zoltan_Set_Param(zz,
"LB_METHOD",
"HYPERGRAPH");
296 Zoltan_Set_Param(zz,
"HYPERGRAPH_PACKAGE",
"PHG");
297 Zoltan_Set_Param(zz,
"NUM_GID_ENTRIES",
"1");
298 Zoltan_Set_Param(zz,
"NUM_LID_ENTRIES",
"1");
300 Zoltan_Set_Param(zz,
"RETURN_LISTS",
"PARTS");
301 Zoltan_Set_Param(zz,
"OBJ_WEIGHT_DIM",
"0");
302 Zoltan_Set_Param(zz,
"EDGE_WEIGHT_DIM",
"0");
303 int num_parts = basis_size / tile_size;
304 Zoltan_Set_Param(zz,
"NUM_GLOBAL_PARTS",
toString(num_parts).c_str());
305 Zoltan_Set_Param(zz,
"NUM_LOCAL_PARTS",
toString(num_parts).c_str());
306 Zoltan_Set_Param(zz,
"IMBALANCE_TOL",
toString(imbalance_tol).c_str());
316 int changes, numGidEntries, numLidEntries, numImport, numExport;
317 ZOLTAN_ID_PTR importGlobalGids, importLocalGids, exportGlobalGids, exportLocalGids;
318 int *importProcs, *importToPart, *exportProcs, *exportToPart;
337 std::cout <<
"num parts requested = " << num_parts
338 <<
" changes= " << changes
339 <<
" num import = " << numImport
340 <<
" num export = " << numExport << std::endl;
346 Cijk_type::k_iterator k_begin = Cijk->k_begin();
347 Cijk_type::k_iterator k_end = Cijk->k_end();
348 for (Cijk_type::k_iterator k_it=k_begin; k_it!=k_end; ++k_it) {
350 Cijk_type::kj_iterator j_begin = Cijk->j_begin(k_it);
351 Cijk_type::kj_iterator j_end = Cijk->j_end(k_it);
352 for (Cijk_type::kj_iterator j_it = j_begin; j_it != j_end; ++j_it) {
354 Cijk_type::kji_iterator i_begin = Cijk->i_begin(j_it);
355 Cijk_type::kji_iterator i_end = Cijk->i_end(j_it);
356 for (Cijk_type::kji_iterator i_it = i_begin; i_it != i_end; ++i_it) {
358 if (i == j && j == k) {
359 part_map[ exportToPart[idx] ].
push_back(i);
367 std::cout <<
"basis_size = " << basis_size <<
" num_diag = " << num_diag
372 for (
int part=0; part<num_parts; ++part) {
373 int num_row = part_map[part].
size();
374 for (
int i=0; i<num_row; ++i)
375 perm_new_to_old.
push_back(part_map[part][i]);
381 for (
int i=0; i<basis_size; ++i)
382 perm_old_to_new[ perm_new_to_old[i] ] = i;
386 Cijk_type::k_iterator k_begin = Cijk->k_begin();
387 Cijk_type::k_iterator k_end = Cijk->k_end();
388 for (Cijk_type::k_iterator k_it=k_begin; k_it!=k_end; ++k_it) {
390 Cijk_type::kj_iterator j_begin = Cijk->j_begin(k_it);
391 Cijk_type::kj_iterator j_end = Cijk->j_end(k_it);
392 for (Cijk_type::kj_iterator j_it = j_begin; j_it != j_end; ++j_it) {
394 Cijk_type::kji_iterator i_begin = Cijk->i_begin(j_it);
395 Cijk_type::kji_iterator i_end = Cijk->i_end(j_it);
396 for (Cijk_type::kji_iterator i_it = i_begin; i_it != i_end; ++i_it) {
398 cijk_file << perm_old_to_new[i] <<
", "
399 << perm_old_to_new[
j] <<
", "
400 << perm_old_to_new[k] <<
", "
401 << exportToPart[idx++] << std::endl;
413 Zoltan_LB_Free_Part(&importGlobalGids, &importLocalGids,
414 &importProcs, &importToPart);
415 Zoltan_LB_Free_Part(&exportGlobalGids, &exportLocalGids,
416 &exportProcs, &exportToPart);
422 catch (std::exception& e) {
423 std::cout << e.what() << std::endl;
const ProductBasisType prod_basis_type_values[]
void get_hypergraph_size(void *data, int *num_lists, int *num_pins, int *format, int *ierr)
k_iterator k_begin() const
Iterator pointing to first k entry.
SparseArrayIterator< index_iterator, value_iterator >::value_type index(const SparseArrayIterator< index_iterator, value_iterator > &it)
Multivariate orthogonal polynomial basis generated from a total order tensor product of univariate po...
kj_iterator j_begin(const k_iterator &k) const
Iterator pointing to first j entry for given k.
const int num_prod_basis_types
int get_number_of_vertices(void *data, int *ierr)
GrowthPolicy
Enumerated type for determining Smolyak growth policies.
const char * growth_type_names[]
const OrderingType ordering_type_values[]
const char * partitioning_type_names[]
const char * toString(const EReductionType reductType)
void get_vertex_list(void *data, int sizeGID, int sizeLID, ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID, int wgt_dim, float *obj_wgts, int *ierr)
const int num_ordering_types
A comparison functor implementing a strict weak ordering based total-order ordering, recursive on the dimension.
kj_iterator j_end(const k_iterator &k) const
Iterator pointing to last j entry for given k.
Bi-directional iterator for traversing a sparse array.
RCP< const Stokhos::ProductBasis< int, double > > basis
void get_hypergraph(void *data, int sizeGID, int num_vtx, int num_pins, int format, ZOLTAN_ID_PTR vtxGID, int *edgePtr, ZOLTAN_ID_PTR edgeGID, int *ierr)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
const int num_growth_types
std::string toString(const HashSet< Key > &h)
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
const int num_partitioning_types
const Stokhos::GrowthPolicy growth_type_values[]
Multivariate orthogonal polynomial basis generated from a Smolyak sparse grid.
k_iterator k_end() const
Iterator pointing to last k entry.
Multivariate orthogonal polynomial basis generated from a tensor product of univariate polynomials...
Stokhos::Sparse3Tensor< int, double > Cijk_type
int main(int argc, char **argv)
void push_back(const value_type &x)
An isotropic total order index set.
void setDocString(const char doc_string[])
A comparison functor implementing a strict weak ordering based lexographic ordering.
Stokhos::Sparse3Tensor< int, double > Cijk_type
#define TEUCHOS_ASSERT(assertion_test)
RCP< const Stokhos::Sparse3Tensor< int, double > > Cijk
kji_iterator i_begin(const kj_iterator &j) const
Iterator pointing to first i entry for given j and k.
const char * ordering_type_names[]
kji_iterator i_end(const kj_iterator &j) const
Iterator pointing to last i entry for given j and k.
const char * prod_basis_type_names[]
virtual ordinal_type size() const =0
Return total size of basis.
ordinal_type num_entries() const
Return number of non-zero entries.
const PartitioningType partitioning_type_values[]