15 #ifndef _ZOLTAN2_VECTORADAPTER_HPP_
16 #define _ZOLTAN2_VECTORADAPTER_HPP_
61 template <
typename User>
62 class VectorAdapter :
public AdapterWithCoords<User> {
65 #ifndef DOXYGEN_SHOULD_SKIP_THIS
66 typedef typename InputTraits<User>::scalar_t
scalar_t;
71 typedef typename InputTraits<User>::offset_t
offset_t;
73 typedef User userCoord_t;
100 int &stride,
int idx = 0)
const {
105 Kokkos::View<
scalar_t **, Kokkos::LayoutLeft,
106 typename node_t::device_type> kokkosEntries;
108 elements = kokkosEntries.data();
118 Kokkos::View<
scalar_t **, Kokkos::LayoutLeft,
119 typename node_t::device_type> & elements)
const {
124 typedef Kokkos::View<
scalar_t **, Kokkos::LayoutLeft,
125 typename node_t::device_type> kokkos_entries_view_t;
126 elements = kokkos_entries_view_t(
"entries", this->
getLocalNumIDs(),
128 typename kokkos_entries_view_t::HostMirror host_elements =
129 Kokkos::create_mirror_view(elements);
131 const scalar_t * ptr_elements;
135 for(
size_t n = 0; n < this->
getLocalNumIDs() * stride; n += stride) {
136 host_elements(i++,j) = ptr_elements[n];
139 Kokkos::deep_copy(elements, host_elements);
168 const char *fileprefix,
169 const Teuchos::Comm<int> &comm
176 this->generateCoordsFileOnly(fileprefix, comm);
187 int idx = 0)
const override
210 void generateCoordsFileOnly(
211 const char* fileprefix,
212 const Teuchos::Comm<int> &comm)
const;
216 template <
typename User>
217 void VectorAdapter<User>::generateCoordsFileOnly(
218 const char *fileprefix,
219 const Teuchos::Comm<int> &comm
225 int np = comm.getSize();
226 int me = comm.getRank();
230 std::string filenamestr = fileprefix;
231 filenamestr = filenamestr +
".coords";
232 const char *filename = filenamestr.c_str();
234 for (
int p = 0; p < np; p++) {
242 fp.open(filename, std::ios::out);
246 fp.open(filename, std::ios::app);
250 size_t len = this->getLocalNumIDs();
251 int nvec = this->getNumEntriesPerID();
252 const scalar_t **values =
new const scalar_t *[nvec];
253 int *strides =
new int[nvec];
254 for (
int n = 0; n < nvec; n++)
255 getEntriesView(values[n], strides[n], n);
259 for (
size_t i = 0; i < len; i++) {
260 for (
int n = 0; n < nvec; n++)
261 fp << values[n][i*strides[n]] <<
" ";
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
virtual void getEntriesKokkosView(Kokkos::View< scalar_t **, Kokkos::LayoutLeft, typename node_t::device_type > &elements) const
Provide a Kokkos view to the elements of the specified vector.
typename InputTraits< UserCoord >::scalar_t scalar_t
void getCoordinatesView(const scalar_t *&elements, int &stride, int idx=0) const override
virtual int getNumEntriesPerID() const =0
Return the number of vectors.
void getCoordinatesKokkosView(typename AdapterWithCoords< User >::CoordsDeviceView &elements) const override
Kokkos::View< scalar_t **, Kokkos::LayoutLeft, device_t > CoordsDeviceView
void generateFiles(const char *fileprefix, const Teuchos::Comm< int > &comm) const
Write files that can be used as input to Zoltan or Zoltan2 driver Creates chaco-formatted input files...
map_t::global_ordinal_type gno_t
#define Z2_THROW_NOT_IMPLEMENTED
typename InputTraits< User >::part_t part_t
virtual void getEntriesHostView(typename AdapterWithCoords< User >::CoordsHostView &elements) const
Provide a Kokkos view (Host side) to the elements of the specified vector.
SparseMatrixAdapter_t::part_t part_t
typename InputTraits< User >::node_t node_t
typename CoordsDeviceView::HostMirror CoordsHostView
enum BaseAdapterType adapterType() const override
Returns the type of adapter.
virtual void getEntriesView(const scalar_t *&elements, int &stride, int idx=0) const
Provide a pointer to the elements of the specified vector.
typename InputTraits< User >::gno_t gno_t
void getCoordinatesHostView(typename AdapterWithCoords< User >::CoordsHostView &elements) const override
void generateWeightFileOnly(const char *fileprefix, const Teuchos::Comm< int > &comm) const
BaseAdapterType
An enum to identify general types of adapters.
map_t::local_ordinal_type lno_t
typename InputTraits< User >::offset_t offset_t
virtual size_t getLocalNumIDs() const =0
Returns the number of objects on this process.
typename BaseAdapter< User >::scalar_t scalar_t
typename InputTraits< User >::lno_t lno_t
virtual void getEntriesDeviceView(typename AdapterWithCoords< User >::CoordsDeviceView &elements) const
Provide a Kokkos view (Device side) to the elements of the specified vector.
void getCoordinatesDeviceView(typename AdapterWithCoords< User >::CoordsDeviceView &elements) const override
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > user_t