66 "complete",
"tensor",
"total",
"smolyak" };
74 "total",
"lexicographic" };
101 namespace HG_1D_Flat_J {
113 ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID,
114 int wgt_dim,
float *obj_wgts,
int *ierr) {
119 for (
int i=0; i<n; ++i) {
129 int *format,
int *ierr) {
143 *num_nonzeroes = num_pins;
146 *format = ZOLTAN_COMPRESSED_EDGE;
151 int format, ZOLTAN_ID_PTR edgeGID,
int *vtxPtr,
152 ZOLTAN_ID_PTR vtxGID,
int *ierr) {
160 int kdx = 0, jdx = 0;
168 vtxPtr[kdx] = num_pins;
188 int rc = Zoltan_Initialize(argc,argv,&version);
194 "This example generates the sparsity pattern for the block stochastic Galerkin matrix.\n");
196 CLP.
setOption(
"dimension", &d,
"Stochastic dimension");
198 CLP.
setOption(
"order", &p,
"Polynomial order");
199 double drop = 1.0e-12;
200 CLP.
setOption(
"drop", &drop,
"Drop tolerance");
201 bool symmetric =
true;
202 CLP.
setOption(
"symmetric",
"asymmetric", &symmetric,
"Use basis polynomials with symmetric PDF");
208 CLP.
setOption(
"product_basis", &prod_basis_type,
211 "Product basis type");
213 CLP.
setOption(
"ordering", &ordering_type,
216 "Product basis ordering");
218 CLP.
setOption(
"partitioning", &partitioning_type,
221 "Partitioning Method");
222 double imbalance_tol = 1.2;
223 CLP.
setOption(
"imbalance", &imbalance_tol,
"Imbalance tolerance");
225 CLP.
setOption(
"full",
"linear", &full,
"Use full or linear expansion");
227 CLP.
setOption(
"tile_size", &tile_size,
"Tile size");
228 bool save_3tensor =
false;
229 CLP.
setOption(
"save_3tensor",
"no-save_3tensor", &save_3tensor,
230 "Save full 3tensor to file");
231 std::string file_3tensor =
"Cijk.dat";
232 CLP.
setOption(
"filename_3tensor", &file_3tensor,
233 "Filename to store full 3-tensor");
236 CLP.
parse( argc, argv );
240 const double alpha = 1.0;
241 const double beta = symmetric ? 1.0 : 2.0 ;
242 for (
int i=0; i<d; i++) {
244 p, alpha, beta,
true, growth_type));
253 else if (prod_basis_type ==
TENSOR) {
263 else if (prod_basis_type ==
TOTAL) {
273 else if (prod_basis_type ==
SMOLYAK) {
278 bases, index_set, drop));
282 bases, index_set, drop));
289 Cijk = basis->computeTripleProductTensor();
291 Cijk = basis->computeLinearTripleProductTensor();
293 int basis_size = basis->size();
294 std::cout <<
"basis size = " << basis_size
295 <<
" num nonzero Cijk entries = " << Cijk->num_entries()
299 std::ofstream cijk_file;
301 cijk_file.open(file_3tensor.c_str());
302 cijk_file.precision(14);
303 cijk_file.setf(std::ios::scientific);
304 cijk_file <<
"i, j, k, part" << std::endl;
308 Zoltan_Struct *zz = Zoltan_Create(MPI_COMM_WORLD);
311 Zoltan_Set_Param(zz,
"DEBUG_LEVEL",
"2");
314 Zoltan_Set_Param(zz,
"LB_METHOD",
"HYPERGRAPH");
315 Zoltan_Set_Param(zz,
"HYPERGRAPH_PACKAGE",
"PHG");
316 Zoltan_Set_Param(zz,
"NUM_GID_ENTRIES",
"1");
317 Zoltan_Set_Param(zz,
"NUM_LID_ENTRIES",
"1");
319 Zoltan_Set_Param(zz,
"RETURN_LISTS",
"PARTS");
320 Zoltan_Set_Param(zz,
"OBJ_WEIGHT_DIM",
"0");
321 Zoltan_Set_Param(zz,
"EDGE_WEIGHT_DIM",
"0");
322 int num_parts = basis_size / tile_size;
323 Zoltan_Set_Param(zz,
"NUM_GLOBAL_PARTS",
toString(num_parts).c_str());
324 Zoltan_Set_Param(zz,
"NUM_LOCAL_PARTS",
toString(num_parts).c_str());
325 Zoltan_Set_Param(zz,
"IMBALANCE_TOL",
toString(imbalance_tol).c_str());
335 int changes, numGidEntries, numLidEntries, numImport, numExport;
336 ZOLTAN_ID_PTR importGlobalGids, importLocalGids, exportGlobalGids, exportLocalGids;
337 int *importProcs, *importToPart, *exportProcs, *exportToPart;
356 std::cout <<
"num parts requested = " << num_parts
357 <<
" changes= " << changes
358 <<
" num import = " << numImport
359 <<
" num export = " << numExport << std::endl;
366 for (
int i=0; i<numExport; ++i) {
367 part_map[ exportToPart[i] ].
push_back( exportGlobalGids[i] );
372 for (
int part=0; part<num_parts; ++part) {
373 int num_vtx = part_map[part].
size();
374 for (
int i=0; i<num_vtx; ++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;
385 Cijk_type::k_iterator k_begin = Cijk->k_begin();
386 Cijk_type::k_iterator k_end = Cijk->k_end();
387 for (Cijk_type::k_iterator k_it=k_begin; k_it!=k_end; ++k_it) {
389 Cijk_type::kj_iterator j_begin = Cijk->j_begin(k_it);
390 Cijk_type::kj_iterator j_end = Cijk->j_end(k_it);
391 for (Cijk_type::kj_iterator j_it = j_begin; j_it != j_end; ++j_it) {
393 Cijk_type::kji_iterator i_begin = Cijk->i_begin(j_it);
394 Cijk_type::kji_iterator i_end = Cijk->i_end(j_it);
395 for (Cijk_type::kji_iterator i_it = i_begin; i_it != i_end; ++i_it) {
397 cijk_file << perm_old_to_new[i] <<
", "
398 << perm_old_to_new[
j] <<
", "
399 << perm_old_to_new[k] <<
", "
400 << exportToPart[i] << std::endl;
408 Zoltan_LB_Free_Part(&importGlobalGids, &importLocalGids,
409 &importProcs, &importToPart);
410 Zoltan_LB_Free_Part(&exportGlobalGids, &exportLocalGids,
411 &exportProcs, &exportToPart);
417 catch (std::exception& e) {
418 std::cout << e.what() << std::endl;
const ProductBasisType prod_basis_type_values[]
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...
ordinal_type num_j(const k_iterator &k) const
Number of j entries in C(i,j,k) for given k.
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)
ordinal_type num_k() const
Number of k entries in C(i,j,k)
kj_iterator j_begin(const k_iterator &k) const
Iterator pointing to first j entry for given k.
const int num_prod_basis_types
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)
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
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
int get_number_of_vertices(void *data, int *ierr)
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
void get_hypergraph_size(void *data, int *num_lists, int *num_nonzeroes, int *format, int *ierr)
#define TEUCHOS_ASSERT(assertion_test)
RCP< const Stokhos::Sparse3Tensor< int, double > > Cijk
const char * ordering_type_names[]
const char * prod_basis_type_names[]
virtual ordinal_type size() const =0
Return total size of basis.
void get_hypergraph(void *data, int sizeGID, int num_edges, int num_nonzeroes, int format, ZOLTAN_ID_PTR edgeGID, int *vtxPtr, ZOLTAN_ID_PTR vtxGID, int *ierr)
const PartitioningType partitioning_type_values[]