42 #ifndef STOKHOS_SPARSE_3_TENSOR_PARTITION_HPP
43 #define STOKHOS_SPARSE_3_TENSOR_PARTITION_HPP
52 template <
typename TupleType>
57 typedef typename TupleType::id_type
id_type;
62 bool operator() (
const TupleType& a,
const TupleType& b)
const {
89 if (y < ymin) ymin = y;
90 if (z < zmin) zmin = z;
91 if (x > xmax) xmax = x;
92 if (y > ymax) ymax = y;
93 if (z > zmax) zmax = z;
145 coords(coords_.begin(), coords_.end()) {
169 part_ids[ box->
coords[i].ID() ] = part;
228 template <
typename ordinal_type,
typename scalar_type>
237 if (d == 0)
return i;
238 if (d == 1)
return j;
239 if (d == 2)
return k;
252 template <
typename ordinal_type,
typename scalar_type>
258 typedef typename Cijk_type::k_iterator k_iterator;
259 typedef typename Cijk_type::kj_iterator kj_iterator;
260 typedef typename Cijk_type::kji_iterator kji_iterator;
266 k_iterator k_begin = Cijk.
k_begin();
267 k_iterator k_end = Cijk.
k_end();
268 for (k_iterator k_it=k_begin; k_it!=k_end; ++k_it) {
270 kj_iterator j_begin = Cijk.
j_begin(k_it);
271 kj_iterator j_end = Cijk.
j_end(k_it);
272 for (kj_iterator j_it = j_begin; j_it != j_end; ++j_it) {
274 kji_iterator i_begin = Cijk.
i_begin(j_it);
275 kji_iterator i_end = Cijk.
i_end(j_it);
276 for (kji_iterator i_it = i_begin; i_it != i_end; ++i_it) {
279 coordinate_list[idx].i = i;
280 coordinate_list[idx].j =
j;
281 coordinate_list[idx].k = k;
282 coordinate_list[idx].c = value(i_it);
283 coordinate_list[idx].gid = idx;
287 coordinate_list[idx].i = i;
288 coordinate_list[idx].j =
j;
289 coordinate_list[idx].k = k;
291 coordinate_list[idx].c = 0.5*value(i_it);
293 coordinate_list[idx].c = value(i_it);
294 coordinate_list[idx].gid = idx;
298 coordinate_list[idx].i = i;
299 coordinate_list[idx].j =
j;
300 coordinate_list[idx].k = k;
301 if (i == j && j == k)
302 coordinate_list[idx].c = (1.0/6.0)*value(i_it);
304 coordinate_list[idx].c = value(i_it);
305 coordinate_list[idx].gid = idx;
311 coordinate_list.
resize(idx);
313 return coordinate_list;
318 #endif // STOKHOS_SPARSE_3_TENSOR_PARTITION_HPP
void computeBoundingBox()
k_iterator k_begin() const
Iterator pointing to first k entry.
Data structure storing a sparse 3-tensor C(i,j,k) in a a compressed format.
Teuchos::Array< TupleType > coords
ArrayView< T > view(size_type offset, size_type size)
kj_iterator j_begin(const k_iterator &k) const
Iterator pointing to first j entry for given k.
size_type get_num_parts() const
Get number of parts.
Teuchos::ArrayRCP< id_type > get_part_IDs() const
void partition()
Partition.
kj_iterator j_end(const k_iterator &k) const
Iterator pointing to last j entry for given k.
void resize(const size_type n, const T &val=T())
Teuchos::RCP< Box > get_partition_root() const
Get root of partition.
Teuchos::RCP< Teuchos::Array< Teuchos::RCP< Box > > > parts
TupleType::value_type coord_type
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Box(const Teuchos::ArrayView< TupleType > &c)
bool operator()(const TupleType &a, const TupleType &b) const
Teuchos::Array< TupleType > coords
void computeSplittingDimension()
k_iterator k_end() const
Iterator pointing to last k entry.
Stokhos::Sparse3Tensor< int, double > Cijk_type
Teuchos::RCP< Teuchos::Array< Teuchos::RCP< Box > > > get_parts() const
Get parts array.
void push_back(const value_type &x)
Teuchos::RCP< Box > right
TupleType::id_type id_type
CoordCompare(const size_type &d_)
#define TEUCHOS_ASSERT(assertion_test)
Teuchos::ArrayView< TupleType >::size_type size_type
Teuchos::ArrayRCP< CijkData< ordinal_type, scalar_type > > build_cijk_coordinate_list(const Sparse3Tensor< ordinal_type, scalar_type > &Cijk, CijkSymmetryType symmetry_type)
kji_iterator i_begin(const kj_iterator &j) const
Iterator pointing to first i entry for given j and k.
kji_iterator i_end(const kj_iterator &j) const
Iterator pointing to last i entry for given j and k.
RCB(const coord_type &max_length_, const size_type &max_parts_, const Teuchos::ArrayView< TupleType > &coords_)
Constructor.
ordinal_type operator()(ordinal_type d) const
ordinal_type num_entries() const
Return number of non-zero entries.