34 "complete",
"tensor",
"total",
"smolyak" };
42 "total",
"lexicographic" };
69 namespace HG_1D_Flat_J {
81 ZOLTAN_ID_PTR globalID, ZOLTAN_ID_PTR localID,
82 int wgt_dim,
float *obj_wgts,
int *ierr) {
87 for (
int i=0; i<n; ++i) {
97 int *format,
int *ierr) {
111 *num_nonzeroes = num_pins;
114 *format = ZOLTAN_COMPRESSED_EDGE;
119 int format, ZOLTAN_ID_PTR edgeGID,
int *vtxPtr,
120 ZOLTAN_ID_PTR vtxGID,
int *ierr) {
128 int kdx = 0, jdx = 0;
136 vtxPtr[kdx] = num_pins;
156 int rc = Zoltan_Initialize(argc,argv,&version);
162 "This example generates the sparsity pattern for the block stochastic Galerkin matrix.\n");
164 CLP.
setOption(
"dimension", &d,
"Stochastic dimension");
166 CLP.
setOption(
"order", &p,
"Polynomial order");
167 double drop = 1.0e-12;
168 CLP.
setOption(
"drop", &drop,
"Drop tolerance");
169 bool symmetric =
true;
170 CLP.
setOption(
"symmetric",
"asymmetric", &symmetric,
"Use basis polynomials with symmetric PDF");
176 CLP.
setOption(
"product_basis", &prod_basis_type,
179 "Product basis type");
181 CLP.
setOption(
"ordering", &ordering_type,
184 "Product basis ordering");
186 CLP.
setOption(
"partitioning", &partitioning_type,
189 "Partitioning Method");
190 double imbalance_tol = 1.2;
191 CLP.
setOption(
"imbalance", &imbalance_tol,
"Imbalance tolerance");
193 CLP.
setOption(
"full",
"linear", &full,
"Use full or linear expansion");
195 CLP.
setOption(
"tile_size", &tile_size,
"Tile size");
196 bool save_3tensor =
false;
197 CLP.
setOption(
"save_3tensor",
"no-save_3tensor", &save_3tensor,
198 "Save full 3tensor to file");
199 std::string file_3tensor =
"Cijk.dat";
200 CLP.
setOption(
"filename_3tensor", &file_3tensor,
201 "Filename to store full 3-tensor");
204 CLP.
parse( argc, argv );
208 const double alpha = 1.0;
209 const double beta = symmetric ? 1.0 : 2.0 ;
210 for (
int i=0; i<d; i++) {
212 p, alpha, beta,
true, growth_type));
221 else if (prod_basis_type ==
TENSOR) {
231 else if (prod_basis_type ==
TOTAL) {
241 else if (prod_basis_type ==
SMOLYAK) {
246 bases, index_set, drop));
250 bases, index_set, drop));
257 Cijk = basis->computeTripleProductTensor();
259 Cijk = basis->computeLinearTripleProductTensor();
261 int basis_size = basis->size();
262 std::cout <<
"basis size = " << basis_size
263 <<
" num nonzero Cijk entries = " << Cijk->num_entries()
267 std::ofstream cijk_file;
269 cijk_file.open(file_3tensor.c_str());
270 cijk_file.precision(14);
271 cijk_file.setf(std::ios::scientific);
272 cijk_file <<
"i, j, k, part" << std::endl;
276 Zoltan_Struct *zz = Zoltan_Create(MPI_COMM_WORLD);
279 Zoltan_Set_Param(zz,
"DEBUG_LEVEL",
"2");
282 Zoltan_Set_Param(zz,
"LB_METHOD",
"HYPERGRAPH");
283 Zoltan_Set_Param(zz,
"HYPERGRAPH_PACKAGE",
"PHG");
284 Zoltan_Set_Param(zz,
"NUM_GID_ENTRIES",
"1");
285 Zoltan_Set_Param(zz,
"NUM_LID_ENTRIES",
"1");
287 Zoltan_Set_Param(zz,
"RETURN_LISTS",
"PARTS");
288 Zoltan_Set_Param(zz,
"OBJ_WEIGHT_DIM",
"0");
289 Zoltan_Set_Param(zz,
"EDGE_WEIGHT_DIM",
"0");
290 int num_parts = basis_size / tile_size;
291 Zoltan_Set_Param(zz,
"NUM_GLOBAL_PARTS",
toString(num_parts).c_str());
292 Zoltan_Set_Param(zz,
"NUM_LOCAL_PARTS",
toString(num_parts).c_str());
293 Zoltan_Set_Param(zz,
"IMBALANCE_TOL",
toString(imbalance_tol).c_str());
303 int changes, numGidEntries, numLidEntries, numImport, numExport;
304 ZOLTAN_ID_PTR importGlobalGids, importLocalGids, exportGlobalGids, exportLocalGids;
305 int *importProcs, *importToPart, *exportProcs, *exportToPart;
324 std::cout <<
"num parts requested = " << num_parts
325 <<
" changes= " << changes
326 <<
" num import = " << numImport
327 <<
" num export = " << numExport << std::endl;
334 for (
int i=0; i<numExport; ++i) {
335 part_map[ exportToPart[i] ].
push_back( exportGlobalGids[i] );
340 for (
int part=0; part<num_parts; ++part) {
341 int num_vtx = part_map[part].
size();
342 for (
int i=0; i<num_vtx; ++i)
343 perm_new_to_old.
push_back(part_map[part][i]);
349 for (
int i=0; i<basis_size; ++i)
350 perm_old_to_new[ perm_new_to_old[i] ] = i;
353 Cijk_type::k_iterator k_begin = Cijk->k_begin();
354 Cijk_type::k_iterator k_end = Cijk->k_end();
355 for (Cijk_type::k_iterator k_it=k_begin; k_it!=k_end; ++k_it) {
357 Cijk_type::kj_iterator j_begin = Cijk->j_begin(k_it);
358 Cijk_type::kj_iterator j_end = Cijk->j_end(k_it);
359 for (Cijk_type::kj_iterator j_it = j_begin; j_it != j_end; ++j_it) {
361 Cijk_type::kji_iterator i_begin = Cijk->i_begin(j_it);
362 Cijk_type::kji_iterator i_end = Cijk->i_end(j_it);
363 for (Cijk_type::kji_iterator i_it = i_begin; i_it != i_end; ++i_it) {
365 cijk_file << perm_old_to_new[i] <<
", "
366 << perm_old_to_new[
j] <<
", "
367 << perm_old_to_new[k] <<
", "
368 << exportToPart[i] << std::endl;
376 Zoltan_LB_Free_Part(&importGlobalGids, &importLocalGids,
377 &importProcs, &importToPart);
378 Zoltan_LB_Free_Part(&exportGlobalGids, &exportLocalGids,
379 &exportProcs, &exportToPart);
385 catch (std::exception& e) {
386 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[]