30 "complete",
"tensor",
"total",
"smolyak" };
38 "total",
"lexicographic" };
48 "none",
"2-way",
"6-way" };
63 "This example generates the sparsity pattern for the block stochastic Galerkin matrix.\n");
65 CLP.
setOption(
"dimension", &d,
"Stochastic dimension");
67 CLP.
setOption(
"order", &p,
"Polynomial order");
68 double drop = 1.0e-12;
69 CLP.
setOption(
"drop", &drop,
"Drop tolerance");
70 bool symmetric =
true;
71 CLP.
setOption(
"symmetric",
"asymmetric", &symmetric,
"Use basis polynomials with symmetric PDF");
77 CLP.
setOption(
"product_basis", &prod_basis_type,
80 "Product basis type");
85 "Product basis ordering");
90 "Cijk symmetry type");
92 CLP.
setOption(
"full",
"linear", &full,
"Use full or linear expansion");
94 CLP.
setOption(
"tile_size", &tile_size,
"Tile size");
95 bool save_3tensor =
false;
96 CLP.
setOption(
"save_3tensor",
"no-save_3tensor", &save_3tensor,
97 "Save full 3tensor to file");
98 std::string file_3tensor =
"Cijk.dat";
99 CLP.
setOption(
"filename_3tensor", &file_3tensor,
100 "Filename to store full 3-tensor");
103 CLP.
parse( argc, argv );
107 const double alpha = 1.0;
108 const double beta = symmetric ? 1.0 : 2.0 ;
109 for (
int i=0; i<d; i++) {
111 p, alpha, beta,
true, growth_type));
120 else if (prod_basis_type ==
TENSOR) {
130 else if (prod_basis_type ==
TOTAL) {
140 else if (prod_basis_type ==
SMOLYAK) {
145 bases, index_set, drop));
149 bases, index_set, drop));
156 Cijk = basis->computeTripleProductTensor();
158 Cijk = basis->computeLinearTripleProductTensor();
160 int basis_size = basis->size();
161 std::cout <<
"basis size = " << basis_size
162 <<
" num nonzero Cijk entries = " << Cijk->num_entries()
166 std::ofstream cijk_file;
168 cijk_file.open(file_3tensor.c_str());
169 cijk_file.precision(14);
170 cijk_file.setf(std::ios::scientific);
171 cijk_file <<
"i, j, k, part" << std::endl;
180 rcb_type rcb(tile_size, 10000, coordinate_list());
181 int num_parts = rcb.get_num_parts();
182 std::cout <<
"num parts = " << num_parts << std::endl;
186 for (
int i=0; i<num_parts; ++i) {
188 std::cout <<
"part " << i <<
" bounding box ="
189 <<
" [ " << box->delta_x <<
", " << box->delta_y <<
", "
190 << box->delta_z <<
" ]" <<
" nnz = "
191 << box->coords.size() << std::endl;
197 Cijk_type::k_iterator k_begin = Cijk->k_begin();
198 Cijk_type::k_iterator k_end = Cijk->k_end();
199 for (Cijk_type::k_iterator k_it=k_begin; k_it!=k_end; ++k_it) {
201 Cijk_type::kj_iterator j_begin = Cijk->j_begin(k_it);
202 Cijk_type::kj_iterator j_end = Cijk->j_end(k_it);
203 for (Cijk_type::kj_iterator j_it = j_begin; j_it != j_end; ++j_it) {
205 Cijk_type::kji_iterator i_begin = Cijk->i_begin(j_it);
206 Cijk_type::kji_iterator i_end = Cijk->i_end(j_it);
207 for (Cijk_type::kji_iterator i_it = i_begin; i_it != i_end; ++i_it) {
212 cijk_file << i <<
", " << j <<
", " << k <<
", "
213 << part_ids[idx++] << std::endl;
224 catch (std::exception& e) {
225 std::cout << e.what() << std::endl;
const ProductBasisType prod_basis_type_values[]
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...
const char * symmetry_type_names[]
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 int num_ordering_types
A comparison functor implementing a strict weak ordering based total-order ordering, recursive on the dimension.
const Stokhos::CijkSymmetryType symmetry_type_values[]
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
const int num_symmetry_types
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
const int num_growth_types
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
const Stokhos::GrowthPolicy growth_type_values[]
Multivariate orthogonal polynomial basis generated from a Smolyak sparse grid.
Multivariate orthogonal polynomial basis generated from a tensor product of univariate polynomials...
Stokhos::Sparse3Tensor< int, double > Cijk_type
int main(int argc, char **argv)
An isotropic total order index set.
void setDocString(const char doc_string[])
A comparison functor implementing a strict weak ordering based lexographic ordering.
Teuchos::ArrayRCP< CijkData< ordinal_type, scalar_type > > build_cijk_coordinate_list(const Sparse3Tensor< ordinal_type, scalar_type > &Cijk, CijkSymmetryType symmetry_type)
const char * ordering_type_names[]
const char * prod_basis_type_names[]