66 "complete",
"tensor",
"total",
"smolyak" };
74 "total",
"lexicographic" };
113 ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID,
114 int wgt_dim,
float *obj_wgts,
int *ierr) {
119 for (
int i=0; i<nnz; ++i) {
129 int *format,
int *ierr) {
144 *format = ZOLTAN_COMPRESSED_VERTEX;
149 int format, ZOLTAN_ID_PTR vtxGID,
int *edgePtr,
150 ZOLTAN_ID_PTR edgeGID,
int *ierr) {
183 vtxGID[vtx_idx] = vtx_idx;
184 edgePtr[vtx_idx++] = pin_idx;
185 edgeGID[pin_idx++] = i;
186 edgeGID[pin_idx++] = n +
j;
187 edgeGID[pin_idx++] = 2*n + k;
201 int rc = Zoltan_Initialize(argc,argv,&version);
207 "This example generates the sparsity pattern for the block stochastic Galerkin matrix.\n");
209 CLP.
setOption(
"dimension", &d,
"Stochastic dimension");
211 CLP.
setOption(
"order", &p,
"Polynomial order");
212 double drop = 1.0e-12;
213 CLP.
setOption(
"drop", &drop,
"Drop tolerance");
214 bool symmetric =
true;
215 CLP.
setOption(
"symmetric",
"asymmetric", &symmetric,
"Use basis polynomials with symmetric PDF");
221 CLP.
setOption(
"product_basis", &prod_basis_type,
224 "Product basis type");
226 CLP.
setOption(
"ordering", &ordering_type,
229 "Product basis ordering");
231 CLP.
setOption(
"partitioning", &partitioning_type,
234 "Partitioning Method");
235 double imbalance_tol = 1.2;
236 CLP.
setOption(
"imbalance", &imbalance_tol,
"Imbalance tolerance");
238 CLP.
setOption(
"full",
"linear", &full,
"Use full or linear expansion");
240 CLP.
setOption(
"tile_size", &tile_size,
"Tile size");
241 bool save_3tensor =
false;
242 CLP.
setOption(
"save_3tensor",
"no-save_3tensor", &save_3tensor,
243 "Save full 3tensor to file");
244 std::string file_3tensor =
"Cijk.dat";
245 CLP.
setOption(
"filename_3tensor", &file_3tensor,
246 "Filename to store full 3-tensor");
249 CLP.
parse( argc, argv );
253 const double alpha = 1.0;
254 const double beta = symmetric ? 1.0 : 2.0 ;
255 for (
int i=0; i<d; i++) {
257 p, alpha, beta,
true, growth_type));
266 else if (prod_basis_type ==
TENSOR) {
276 else if (prod_basis_type ==
TOTAL) {
286 else if (prod_basis_type ==
SMOLYAK) {
291 bases, index_set, drop));
295 bases, index_set, drop));
302 Cijk = basis->computeTripleProductTensor();
304 Cijk = basis->computeLinearTripleProductTensor();
306 int basis_size = basis->size();
307 std::cout <<
"basis size = " << basis_size
308 <<
" num nonzero Cijk entries = " << Cijk->num_entries()
312 std::ofstream cijk_file;
314 cijk_file.open(file_3tensor.c_str());
315 cijk_file.precision(14);
316 cijk_file.setf(std::ios::scientific);
317 cijk_file <<
"i, j, k, part" << std::endl;
321 Zoltan_Struct *zz = Zoltan_Create(MPI_COMM_WORLD);
324 Zoltan_Set_Param(zz,
"DEBUG_LEVEL",
"2");
327 Zoltan_Set_Param(zz,
"LB_METHOD",
"HYPERGRAPH");
328 Zoltan_Set_Param(zz,
"HYPERGRAPH_PACKAGE",
"PHG");
329 Zoltan_Set_Param(zz,
"NUM_GID_ENTRIES",
"1");
330 Zoltan_Set_Param(zz,
"NUM_LID_ENTRIES",
"1");
332 Zoltan_Set_Param(zz,
"RETURN_LISTS",
"PARTS");
333 Zoltan_Set_Param(zz,
"OBJ_WEIGHT_DIM",
"0");
334 Zoltan_Set_Param(zz,
"EDGE_WEIGHT_DIM",
"0");
335 int num_parts = basis_size / tile_size;
336 Zoltan_Set_Param(zz,
"NUM_GLOBAL_PARTS",
toString(num_parts).c_str());
337 Zoltan_Set_Param(zz,
"NUM_LOCAL_PARTS",
toString(num_parts).c_str());
338 Zoltan_Set_Param(zz,
"IMBALANCE_TOL",
toString(imbalance_tol).c_str());
348 int changes, numGidEntries, numLidEntries, numImport, numExport;
349 ZOLTAN_ID_PTR importGlobalGids, importLocalGids, exportGlobalGids, exportLocalGids;
350 int *importProcs, *importToPart, *exportProcs, *exportToPart;
369 std::cout <<
"num parts requested = " << num_parts
370 <<
" changes= " << changes
371 <<
" num import = " << numImport
372 <<
" num export = " << numExport << std::endl;
378 Cijk_type::k_iterator k_begin = Cijk->k_begin();
379 Cijk_type::k_iterator k_end = Cijk->k_end();
380 for (Cijk_type::k_iterator k_it=k_begin; k_it!=k_end; ++k_it) {
382 Cijk_type::kj_iterator j_begin = Cijk->j_begin(k_it);
383 Cijk_type::kj_iterator j_end = Cijk->j_end(k_it);
384 for (Cijk_type::kj_iterator j_it = j_begin; j_it != j_end; ++j_it) {
386 Cijk_type::kji_iterator i_begin = Cijk->i_begin(j_it);
387 Cijk_type::kji_iterator i_end = Cijk->i_end(j_it);
388 for (Cijk_type::kji_iterator i_it = i_begin; i_it != i_end; ++i_it) {
390 if (i == j && j == k) {
391 part_map[ exportToPart[idx] ].
push_back(i);
399 std::cout <<
"basis_size = " << basis_size <<
" num_diag = " << num_diag
404 for (
int part=0; part<num_parts; ++part) {
405 int num_row = part_map[part].
size();
406 for (
int i=0; i<num_row; ++i)
407 perm_new_to_old.
push_back(part_map[part][i]);
413 for (
int i=0; i<basis_size; ++i)
414 perm_old_to_new[ perm_new_to_old[i] ] = i;
418 Cijk_type::k_iterator k_begin = Cijk->k_begin();
419 Cijk_type::k_iterator k_end = Cijk->k_end();
420 for (Cijk_type::k_iterator k_it=k_begin; k_it!=k_end; ++k_it) {
422 Cijk_type::kj_iterator j_begin = Cijk->j_begin(k_it);
423 Cijk_type::kj_iterator j_end = Cijk->j_end(k_it);
424 for (Cijk_type::kj_iterator j_it = j_begin; j_it != j_end; ++j_it) {
426 Cijk_type::kji_iterator i_begin = Cijk->i_begin(j_it);
427 Cijk_type::kji_iterator i_end = Cijk->i_end(j_it);
428 for (Cijk_type::kji_iterator i_it = i_begin; i_it != i_end; ++i_it) {
430 cijk_file << perm_old_to_new[i] <<
", "
431 << perm_old_to_new[
j] <<
", "
432 << perm_old_to_new[k] <<
", "
433 << exportToPart[idx++] << std::endl;
445 Zoltan_LB_Free_Part(&importGlobalGids, &importLocalGids,
446 &importProcs, &importToPart);
447 Zoltan_LB_Free_Part(&exportGlobalGids, &exportLocalGids,
448 &exportProcs, &exportToPart);
454 catch (std::exception& e) {
455 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[]