45 #ifndef _ZOLTAN2_ALGFORTESTINGONLY_HPP_
46 #define _ZOLTAN2_ALGFORTESTINGONLY_HPP_
60 template <
typename Adapter>
65 const RCP<const Environment> env;
66 const RCP<const Comm<int> > comm;
67 const RCP<const typename Adapter::base_adapter_t> adapter;
72 const RCP<const Environment> &env__,
73 const RCP<
const Comm<int> > &problemComm__,
74 const RCP<const typename Adapter::base_adapter_t> &adapter__):
75 env(env__), comm(problemComm__), adapter(adapter__)
83 RCP<Teuchos::EnhancedNumberValidator<int>> forTestingOnlyFlag_Validator =
84 Teuchos::rcp(
new Teuchos::EnhancedNumberValidator<int>(0, 1000, 1, 0) );
85 pl.set(
"forTestingOnlyFlag", 0,
"Used only for testing; look at "
86 "Zoltan2_AlgForTestingOnly for interpretations",
87 forTestingOnlyFlag_Validator);
92 size_t nObj = adapter->getLocalNumIDs();
93 ArrayRCP<part_t> partList(
new part_t[nObj], 0, nObj,
true);
94 size_t nGlobalParts = solution->getTargetGlobalNumberOfParts();
96 const Teuchos::ParameterEntry *pe =
97 env->getParameters().getEntryPtr(
"forTestingOnlyFlag");
98 int forTestingOnlyFlag = pe->getValue<
int>(&forTestingOnlyFlag);
100 switch (forTestingOnlyFlag) {
104 if (comm->getRank() == 0) {
105 for (
size_t i = 0; i < nObj; i++) partList[i] = 0;
108 for (
size_t i = 0; i < nObj; i++)
109 if (i % 2) partList[i] = nGlobalParts - 1;
110 else partList[i] = 0;
116 if (comm->getRank() == 0) {
117 for (
size_t i = 0; i < nObj; i++) partList[i] = 0;
120 for (
size_t i = 0; i < nObj; i++)
121 if (i % 2) partList[i] = 0;
122 else partList[i] = nGlobalParts - 1;
126 throw std::runtime_error(
"invalid forTestingOnlyFlag value");
129 std::cout << comm->getRank() <<
" forTestingOnly " << forTestingOnlyFlag
131 for (
size_t i = 0; i < nObj; i++)
132 std::cout << partList[i] <<
" ";
133 std::cout << std::endl;
135 solution->setParts(partList);
static void getValidParameters(ParameterList &pl)
Set up validators specific to this algorithm.
Defines the PartitioningSolution class.
SparseMatrixAdapter_t::part_t part_t
A PartitioningSolution is a solution to a partitioning problem.
void partition(const RCP< PartitioningSolution< Adapter > > &solution)
Partitioning method.
Algorithm defines the base class for all algorithms.
AlgForTestingOnly(const RCP< const Environment > &env__, const RCP< const Comm< int > > &problemComm__, const RCP< const typename Adapter::base_adapter_t > &adapter__)