50 #ifndef _ZOLTAN2_ADAPTER_HPP_
51 #define _ZOLTAN2_ADAPTER_HPP_
53 #include <Kokkos_Core.hpp>
100 template <
typename User>
124 Kokkos::View<gno_t *> kokkosIds;
126 ids = kokkosIds.data();
147 virtual void getWeightsView(
const scalar_t *&wgt,
int &stride,
149 Kokkos::View<scalar_t *> tempWeightsView;
150 getWeightsKokkosView(tempWeightsView, idx);
151 wgt = tempWeightsView.data();
162 virtual void getWeightsKokkosView(Kokkos::View<scalar_t *> &,
176 void getPartsView(
const part_t *&inputPart)
const {
199 template <
typename Adapter>
200 void applyPartitioningSolution(
const User &in, User *&out,
201 const PartitioningSolution<Adapter> &solution)
const {
212 void generateWeightFileOnly(
const char* fileprefix,
213 const Teuchos::Comm<int> &comm)
const;
217 template <
typename User>
218 void BaseAdapter<User>::generateWeightFileOnly(
219 const char *fileprefix,
220 const Teuchos::Comm<int> &comm
223 int np = comm.getSize();
224 int me = comm.getRank();
226 size_t nLocalIDs = this->getLocalNumIDs();
233 std::string filenamestr = fileprefix;
234 filenamestr = filenamestr +
".graph";
235 const char *filename = filenamestr.c_str();
238 Teuchos::reduceAll(comm, Teuchos::REDUCE_SUM, 1, &nLocalIDs, &nGlobalIDs);
240 int nWgts = this->getNumWeightsPerID();
242 for (
int p = 0; p < np; p++) {
251 fp.open(filename, std::ios::out);
254 fp << nGlobalIDs <<
" " << 0 <<
" "
255 << (nWgts ?
"010" :
"000") <<
" "
256 << (nWgts > 1 ? std::to_string(nWgts) :
" ") << std::endl;
260 fp.open(filename, std::ios::app);
266 const scalar_t **wgts =
new const scalar_t *[nWgts];
267 int *strides =
new int[nWgts];
268 for (
int n = 0; n < nWgts; n++)
269 getWeightsView(wgts[n], strides[n], n);
272 for (
size_t i = 0; i < nLocalIDs; i++) {
273 for (
int n = 0; n < nWgts; n++)
274 fp << wgts[n][i*strides[n]] <<
" ";
291 std::string filenamestr = fileprefix;
292 filenamestr = filenamestr +
".assign";
293 const char *filename = filenamestr.c_str();
295 for (
int p = 0; p < np; p++) {
304 fp.open(filename, std::ios::out);
308 fp.open(filename, std::ios::app);
312 this->getPartsView(parts);
314 for (
size_t i = 0; i < nLocalIDs; i++) {
315 fp << (parts != NULL ? parts[i] : me) <<
"\n";
#define Z2_THROW_NOT_IMPLEMENTED
Defines the PartitioningSolution class.
Gathering definitions used in software development.
BaseAdapter defines methods required by all Adapters.
virtual ~BaseAdapterRoot()
virtual int getNumWeightsPerID() const
Returns the number of weights per object. Number of weights per object should be zero or greater....
virtual size_t getLocalNumIDs() const =0
Returns the number of objects on this process.
InputTraits< User >::offset_t offset_t
InputTraits< User >::part_t part_t
InputTraits< User >::scalar_t scalar_t
virtual void getIDsView(const gno_t *&ids) const
Provide a pointer to this process' identifiers.
InputTraits< User >::lno_t lno_t
virtual ~BaseAdapter()
Destructor.
virtual enum BaseAdapterType adapterType() const =0
Returns the type of adapter.
virtual void getIDsKokkosView(Kokkos::View< gno_t * > &) const
Provide a pointer to this process' identifiers.
InputTraits< User >::gno_t gno_t
BaseAdapterType
An enum to identify general types of adapters.
@ VectorAdapterType
vector data
@ InvalidAdapterType
unused value
@ GraphAdapterType
graph data
@ MatrixAdapterType
matrix data
@ MeshAdapterType
mesh data
@ IdentifierAdapterType
identifier data, just a list of IDs
SparseMatrixAdapter_t::part_t part_t