58 #include <Teuchos_Comm.hpp> 59 #include <Teuchos_DefaultComm.hpp> 60 #include <Teuchos_ArrayView.hpp> 61 #include <Teuchos_OrdinalTraits.hpp> 63 #include <Tpetra_CrsMatrix.hpp> 69 using Teuchos::DefaultComm;
72 const RCP<
const Comm<int> > &comm,
bool consecutiveIds)
74 int rank = comm->getRank();
75 int fail = 0, gfail = 0;
77 std::bitset<Zoltan2::NUM_MODEL_FLAGS> modelFlags = 0;
86 typedef Tpetra::CrsMatrix<scalar_t, lno_t, gno_t>
tcrsMatrix_t;
95 lno_t nLocalIds = M->getNodeNumRows();
96 gno_t nGlobalIds = M->getGlobalNumRows();
98 ArrayView<const gno_t>
idList = M->getRowMap()->getNodeElementList();
99 std::set<gno_t> idSet(idList.begin(), idList.end());
109 RCP<const adapter_t> ia = Teuchos::rcp(
new adapter_t(M));
112 const base_adapter_t *base_ia = ia.get();
116 base_ia, env, comm, modelFlags);
118 catch (std::exception &e){
119 std::cerr << rank <<
") " << e.what() << std::endl;
145 ArrayView<const gno_t> gids;
146 ArrayView<input_t> wgts;
150 if (!fail && gids.size() != nLocalIds)
153 if (!fail && wgts.size() != 0)
156 for (
lno_t i=0; !fail && i < nLocalIds; i++){
157 std::set<gno_t>::iterator next = idSet.find(gids[i]);
158 if (next == idSet.end())
162 if (!fail && consecutiveIds){
164 gids.getRawPtr(), nLocalIds);
179 int main(
int argc,
char *argv[])
181 Teuchos::GlobalMPISession session(&argc, &argv);
182 Teuchos::RCP<const Teuchos::Comm<int> > comm =
183 Teuchos::DefaultComm<int>::getComm();
185 int rank = comm->getRank();
187 string fname(
"simple");
189 bool wishConsecutiveIds =
true;
193 std::cout <<
", consecutive IDs not requested" << std::endl;
199 std::cout <<
", consecutive IDs are requested" << std::endl;
203 if (rank==0) std::cout <<
"PASS" << std::endl;
int main(int argc, char *argv[])
int globalFail(const RCP< const Comm< int > > &comm, int fail)
Zoltan2::StridedData< lno_t, scalar_t > input_t
algorithm requires consecutive ids
common code used by tests
Tpetra::CrsMatrix< scalar_t, lno_t, gno_t, node_t > tcrsMatrix_t
list idList
Match up parameters to validators.
int getIdentifierWeightDim() const
Returns the dimension (0 or greater) of identifier weights.
Defines the IdentifierModel interface.
The StridedData class manages lists of weights or coordinates.
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
void testIdentifierModel(std::string fname, gno_t xdim, gno_t ydim, gno_t zdim, const RCP< const Comm< int > > &comm, bool consecutiveIds)
static bool areConsecutive(const T *val, size_t n)
Determine if the values are locally increasing consecutive.
void printFailureCode(const RCP< const Comm< int > > &comm, int fail)
size_t getLocalNumIdentifiers() const
Returns the number identifiers on this process.
IdentifierModel defines the interface for all identifier models.
global_size_t getGlobalNumIdentifiers() const
Returns the global number identifiers.
size_t getIdentifierList(ArrayView< const gno_t > &Ids, ArrayView< input_t > &wgts) const
Sets pointers to this process' identifier Ids and their weights.
std::string testDataFilePath(".")