51 #ifndef _ZOLTAN2_VECTORADAPTER_HPP_
52 #define _ZOLTAN2_VECTORADAPTER_HPP_
97 template <
typename User>
98 class VectorAdapter :
public AdapterWithCoords<User> {
101 #ifndef DOXYGEN_SHOULD_SKIP_THIS
102 typedef typename InputTraits<User>::scalar_t
scalar_t;
107 typedef typename InputTraits<User>::offset_t
offset_t;
109 typedef User userCoord_t;
136 int &stride,
int idx = 0)
const {
141 Kokkos::View<
scalar_t **, Kokkos::LayoutLeft,
142 typename node_t::device_type> kokkosEntries;
144 elements = kokkosEntries.data();
154 Kokkos::View<
scalar_t **, Kokkos::LayoutLeft,
155 typename node_t::device_type> & elements)
const {
160 typedef Kokkos::View<
scalar_t **, Kokkos::LayoutLeft,
161 typename node_t::device_type> kokkos_entries_view_t;
162 elements = kokkos_entries_view_t(
"entries", this->
getLocalNumIDs(),
164 typename kokkos_entries_view_t::HostMirror host_elements =
165 Kokkos::create_mirror_view(elements);
167 const scalar_t * ptr_elements;
171 for(
size_t n = 0; n < this->
getLocalNumIDs() * stride; n += stride) {
172 host_elements(i++,j) = ptr_elements[n];
175 Kokkos::deep_copy(elements, host_elements);
204 const char *fileprefix,
205 const Teuchos::Comm<int> &comm
212 this->generateCoordsFileOnly(fileprefix, comm);
223 int idx = 0)
const override
246 void generateCoordsFileOnly(
247 const char* fileprefix,
248 const Teuchos::Comm<int> &comm)
const;
252 template <
typename User>
253 void VectorAdapter<User>::generateCoordsFileOnly(
254 const char *fileprefix,
255 const Teuchos::Comm<int> &comm
261 int np = comm.getSize();
262 int me = comm.getRank();
266 std::string filenamestr = fileprefix;
267 filenamestr = filenamestr +
".coords";
268 const char *filename = filenamestr.c_str();
270 for (
int p = 0; p < np; p++) {
278 fp.open(filename, std::ios::out);
282 fp.open(filename, std::ios::app);
286 size_t len = this->getLocalNumIDs();
287 int nvec = this->getNumEntriesPerID();
288 const scalar_t **values =
new const scalar_t *[nvec];
289 int *strides =
new int[nvec];
290 for (
int n = 0; n < nvec; n++)
291 getEntriesView(values[n], strides[n], n);
295 for (
size_t i = 0; i < len; i++) {
296 for (
int n = 0; n < nvec; n++)
297 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