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();
149 Kokkos::View<scalar_t *> tempWeightsView;
151 wgt = tempWeightsView.data();
199 template <
typename Adapter>
213 const Teuchos::Comm<int> &comm)
const;
217 template <
typename User>
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);
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";
InputTraits< User >::scalar_t scalar_t
virtual int getNumWeightsPerID() const
Returns the number of weights per object. Number of weights per object should be zero or greater...
virtual void getIDsView(const gno_t *&ids) const
Provide a pointer to this process' identifiers.
InputTraits< User >::gno_t gno_t
InputTraits< User >::lno_t lno_t
#define Z2_THROW_NOT_IMPLEMENTED
Defines the PartitioningSolution class.
virtual void getWeightsView(const scalar_t *&wgt, int &stride, int idx=0) const
Provide pointer to a weight array with stride.
virtual ~BaseAdapter()
Destructor.
A PartitioningSolution is a solution to a partitioning problem.
void generateWeightFileOnly(const char *fileprefix, const Teuchos::Comm< int > &comm) const
BaseAdapterType
An enum to identify general types of adapters.
identifier data, just a list of IDs
virtual ~BaseAdapterRoot()
BaseAdapter defines methods required by all Adapters.
InputTraits< User >::part_t part_t
void getPartsView(const part_t *&inputPart) const
Provide pointer to an array containing the input part assignment for each ID. The input part informat...
void applyPartitioningSolution(const User &in, User *&out, const PartitioningSolution< Adapter > &solution) const
Apply a PartitioningSolution to an input.
virtual size_t getLocalNumIDs() const =0
Returns the number of objects on this process.
virtual void getWeightsKokkosView(Kokkos::View< scalar_t * > &, int=0) const
Provide pointer to a weight View.
Gathering definitions used in software development.
virtual void getIDsKokkosView(Kokkos::View< gno_t * > &) const
Provide a pointer to this process' identifiers.
InputTraits< User >::offset_t offset_t
virtual enum BaseAdapterType adapterType() const =0
Returns the type of adapter.