51#ifndef _ZOLTAN2_VECTORADAPTER_HPP_
52#define _ZOLTAN2_VECTORADAPTER_HPP_
97template <
typename User>
101#ifndef DOXYGEN_SHOULD_SKIP_THIS
109 typedef User userCoord_t;
140 int &stride,
int idx = 0)
const {
145 Kokkos::View<
scalar_t **, Kokkos::LayoutLeft,
146 typename node_t::device_type> kokkosEntries;
148 elements = kokkosEntries.data();
158 Kokkos::View<
scalar_t **, Kokkos::LayoutLeft,
159 typename node_t::device_type> & elements)
const {
164 typedef Kokkos::View<
scalar_t **, Kokkos::LayoutLeft,
165 typename node_t::device_type> kokkos_entries_view_t;
166 elements = kokkos_entries_view_t(
"entries", this->
getLocalNumIDs(),
168 typename kokkos_entries_view_t::HostMirror host_elements =
169 Kokkos::create_mirror_view(elements);
175 for(
size_t n = 0; n < this->
getLocalNumIDs() * stride; n += stride) {
176 host_elements(i++,j) = ptr_elements[n];
179 Kokkos::deep_copy(elements, host_elements);
191 const char *fileprefix,
192 const Teuchos::Comm<int> &comm
199 this->generateCoordsFileOnly(fileprefix, comm);
210 int idx = 0)
const override
217 Kokkos::View<scalar_t **, Kokkos::LayoutLeft, typename node_t::device_type> & elements)
const override
224 void generateCoordsFileOnly(
225 const char* fileprefix,
226 const Teuchos::Comm<int> &comm)
const;
230template <
typename User>
231void VectorAdapter<User>::generateCoordsFileOnly(
232 const char *fileprefix,
233 const Teuchos::Comm<int> &comm
239 int np = comm.getSize();
240 int me = comm.getRank();
244 std::string filenamestr = fileprefix;
245 filenamestr = filenamestr +
".coords";
246 const char *filename = filenamestr.c_str();
248 for (
int p = 0; p < np; p++) {
256 fp.open(filename, std::ios::out);
260 fp.open(filename, std::ios::app);
264 size_t len = this->getLocalNumIDs();
265 int nvec = this->getNumEntriesPerID();
266 const scalar_t **values =
new const scalar_t *[nvec];
267 int *strides =
new int[nvec];
268 for (
int n = 0; n < nvec; n++)
269 getEntriesView(values[n], strides[n], n);
273 for (
size_t i = 0; i < len; i++) {
274 for (
int n = 0; n < nvec; n++)
275 fp << values[n][i*strides[n]] <<
" ";
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > user_t
virtual size_t getLocalNumIDs() const =0
Returns the number of objects on this process.
InputTraits< User >::node_t node_t
InputTraits< User >::offset_t offset_t
InputTraits< User >::part_t part_t
InputTraits< User >::scalar_t scalar_t
void generateWeightFileOnly(const char *fileprefix, const Teuchos::Comm< int > &comm) const
InputTraits< User >::lno_t lno_t
InputTraits< User >::gno_t gno_t
VectorAdapter defines the interface for vector input.
virtual int getNumEntriesPerID() const =0
Return the number of vectors.
virtual ~VectorAdapter()
Destructor.
void getCoordinatesView(const scalar_t *&elements, int &stride, int idx=0) const override
void getCoordinatesKokkosView(Kokkos::View< scalar_t **, Kokkos::LayoutLeft, typename node_t::device_type > &elements) const override
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...
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.
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.
Created by mbenlioglu on Aug 31, 2020.
BaseAdapterType
An enum to identify general types of adapters.
@ VectorAdapterType
vector data