47 #ifndef _ZOLTAN2_SPHYNXPROBLEM_HPP_
48 #define _ZOLTAN2_SPHYNXPROBLEM_HPP_
75 RCP<Teuchos::StringValidator> sphynx_preconditionner_type_method_Validator =
76 Teuchos::rcp(
new Teuchos::StringValidator(Teuchos::tuple<std::string>(
"muelu",
"jacobi",
"polynomial")));
78 pl.set(
"sphynx_preconditioner_type",
"polynomial",
"Sphynx preconditioner type", sphynx_preconditionner_type_method_Validator);
80 RCP<Teuchos::StringValidator> sphynx_initial_guess_method_Validator =
81 Teuchos::rcp(
new Teuchos::StringValidator(Teuchos::tuple<std::string>(
"random",
"constants")));
83 pl.set(
"sphynx_initial_guess",
"random",
"Sphynx initial guess", sphynx_initial_guess_method_Validator);
85 RCP<Teuchos::StringValidator> sphynx_eigensolver_Validator =
86 Teuchos::rcp(
new Teuchos::StringValidator(Teuchos::tuple<std::string>(
"LOBPCG",
"randomized",
"GeneralizedDavidson",
"BlockDavidson",
"BlockKrylovSchur")));
88 pl.set(
"sphynx_eigensolver",
"LOBPCG",
"Sphynx eigensolver", sphynx_eigensolver_Validator);
90 RCP<Teuchos::StringValidator> sphynx_problem_type_method_Validator =
91 Teuchos::rcp(
new Teuchos::StringValidator(Teuchos::tuple<std::string>(
"combinatorial",
"normalized",
"generalized")));
93 pl.set(
"sphynx_problem_type",
"combinatorial",
"Sphynx problem type", sphynx_problem_type_method_Validator);
95 RCP<Teuchos::EnhancedNumberValidator<int>> sphynx_verbosity_validator =
96 Teuchos::rcp(
new Teuchos::EnhancedNumberValidator<int>(0, 1) );
97 pl.set(
"sphynx_verbosity", 0,
"Sphynx verbosity.", sphynx_verbosity_validator);
99 pl.set(
"sphynx_ortho_freq", 0,
"Sphynx orthogonalization frequency");
100 pl.set(
"sphynx_res_freq", 0,
"Sphynx residual frequency");
101 pl.set(
"sphynx_tolerance", 1e-1,
"Sphynx tolerance");
102 pl.set(
"sphynx_max_iterations", 1000,
"Sphynx max iterations");
103 pl.set(
"sphynx_block_size", 0,
"Sphynx block size");
110 const Teuchos::ParameterList &plSome,
111 const Teuchos::ParameterList &plAll,
112 Teuchos::ParameterList &plVal)
114 ParameterList::ConstIterator next = plSome.begin();
116 while (next != plSome.end()){
118 const std::string &name = next->first;
119 const ParameterEntry &entrySome = plSome.getEntry(name);
120 const ParameterEntry &entryAll = plAll.getEntry(name);
122 if (entrySome.isList()){
127 plVal.setEntry(name, entryAll);
134 template <
typename Adapter>
146 using mvector_t =
typename Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t>;
155 Teuchos::ParameterList *p,
156 RCP<Teuchos::ParameterList> sphynxParams,
157 const RCP<
const Teuchos::Comm<int> > &comm):
161 ParameterList validParams;
163 ParameterList allParameters;
170 sphynxParams_->validateParametersAndSetDefaults(validParams, 0);
173 const Teuchos::ParameterEntry *pe = this->
params_->getEntryPtr(
"num_global_parts");
175 nparts = pe->getValue<
int>(&nparts);
178 throw std::runtime_error(
"\nUser did not set num_global_parts"
179 "in the parameter list!n");
182 #ifdef HAVE_ZOLTAN2_MPI
184 SphynxProblem(Adapter *A, ParameterList *p, RCP<Teuchos::ParameterList> sphynxParams, MPI_Comm mpicomm):
186 rcp<const Comm<int> >(new Teuchos::MpiComm<int>(
187 Teuchos::opaqueWrapper(mpicomm))))
192 SphynxProblem(Adapter *A, ParameterList *p, RCP<Teuchos::ParameterList> sphynxParams):
204 void processAlgorithmName(
const std::string& algorithm,
const std::string& defString,
const std::string& model,
205 Environment &env,
bool& removeSelfEdges,
bool& isGraphType,
bool& needConsecutiveGlobalIds)
override;
223 Teuchos::RCP<Teuchos::ParameterList> envParams_;
224 RCP<ParameterList> sphynxParams_;
225 RCP<mvector_t> eigenVectors_;
233 template <
typename Adapter>
235 const std::string &algorithm,
const std::string &defString,
236 const std::string &model,
Environment &env,
bool &removeSelfEdges,
237 bool &isGraphType,
bool &needConsecutiveGlobalIds)
239 this->algName_ = std::string(
"sphynx");
242 template <
typename Adapter>
246 if (this->algName_ == std::string(
"sphynx")) {
251 this->inputAdapter_));
252 if( this->eigenVectors_!=Teuchos::null ){
257 throw std::logic_error(
"partitioning algorithm not supported");
266 template <
typename Adapter>
269 eigenVectors_ = userEvects;
275 template <
typename Adapter>
276 Teuchos::RCP<Tpetra::MultiVector<double, typename Adapter::lno_t, typename Adapter::gno_t, typename Adapter::node_t> >
279 if(this->algorithm_!=Teuchos::null){
283 return Teuchos::null;
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
Adapter::scalar_t scalar_t
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
Adapter::base_adapter_t base_adapter_t
static RCP< Teuchos::BoolParameterEntryValidator > getBoolValidator()
Exists to make setting up validators less cluttered.
SphynxProblem(Adapter *A, ParameterList *p, RCP< Teuchos::ParameterList > sphynxParams)
map_t::global_ordinal_type gno_t
Defines the PartitioningSolution class.
void createAlgorithm() override
static void setSphynxValidatorsInList(const Teuchos::ParameterList &plSome, const Teuchos::ParameterList &plAll, Teuchos::ParameterList &plVal)
void setUserEigenvectors(const RCP< mvector_t > &userEvects)
SparseMatrixAdapter_t::part_t part_t
A PartitioningSolution is a solution to a partitioning problem.
SphynxProblem(Adapter *A, Teuchos::ParameterList *p, RCP< Teuchos::ParameterList > sphynxParams, const RCP< const Teuchos::Comm< int > > &comm)
map_t::local_ordinal_type lno_t
RCP< PartitioningSolution< Adapter > > solution_
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
static void getSphynxValidParameters(ParameterList &pl)
Set up validators specific to this algorithm.
PartitioningProblem sets up partitioning problems for the user.
typename Adapter::node_t node_t
typename Tpetra::MultiVector< scalar_t, lno_t, gno_t, node_t > mvector_t
RCP< ParameterList > params_
void processAlgorithmName(const std::string &algorithm, const std::string &defString, const std::string &model, Environment &env, bool &removeSelfEdges, bool &isGraphType, bool &needConsecutiveGlobalIds) override
Defines the PartitioningProblem class.
typename Adapter::scalar_t weight_t
RCP< mvector_t > getSphynxEigenvectors()
const PartitioningSolution< Adapter > & getSolution()