10#ifndef _ZOLTAN2_SPHYNXPROBLEM_HPP_
11#define _ZOLTAN2_SPHYNXPROBLEM_HPP_
38 RCP<Teuchos::StringValidator> sphynx_preconditionner_type_method_Validator =
39 Teuchos::rcp(
new Teuchos::StringValidator(Teuchos::tuple<std::string>(
"muelu",
"jacobi",
"polynomial")));
41 pl.set(
"sphynx_preconditioner_type",
"polynomial",
"Sphynx preconditioner type", sphynx_preconditionner_type_method_Validator);
43 RCP<Teuchos::StringValidator> sphynx_initial_guess_method_Validator =
44 Teuchos::rcp(
new Teuchos::StringValidator(Teuchos::tuple<std::string>(
"random",
"constants")));
46 pl.set(
"sphynx_initial_guess",
"random",
"Sphynx initial guess", sphynx_initial_guess_method_Validator);
48 RCP<Teuchos::StringValidator> sphynx_eigensolver_Validator =
49 Teuchos::rcp(
new Teuchos::StringValidator(Teuchos::tuple<std::string>(
"LOBPCG",
"randomized",
"GeneralizedDavidson",
"BlockDavidson",
"BlockKrylovSchur")));
51 pl.set(
"sphynx_eigensolver",
"LOBPCG",
"Sphynx eigensolver", sphynx_eigensolver_Validator);
53 RCP<Teuchos::StringValidator> sphynx_problem_type_method_Validator =
54 Teuchos::rcp(
new Teuchos::StringValidator(Teuchos::tuple<std::string>(
"combinatorial",
"normalized",
"generalized")));
56 pl.set(
"sphynx_problem_type",
"combinatorial",
"Sphynx problem type", sphynx_problem_type_method_Validator);
58 RCP<Teuchos::EnhancedNumberValidator<int>> sphynx_verbosity_validator =
59 Teuchos::rcp(
new Teuchos::EnhancedNumberValidator<int>(0, 1) );
60 pl.set(
"sphynx_verbosity", 0,
"Sphynx verbosity.", sphynx_verbosity_validator);
62 pl.set(
"sphynx_ortho_freq", 0,
"Sphynx orthogonalization frequency");
63 pl.set(
"sphynx_res_freq", 0,
"Sphynx residual frequency");
64 pl.set(
"sphynx_tolerance", 1e-1,
"Sphynx tolerance");
65 pl.set(
"sphynx_max_iterations", 1000,
"Sphynx max iterations");
66 pl.set(
"sphynx_block_size", 0,
"Sphynx block size");
73 const Teuchos::ParameterList &plSome,
74 const Teuchos::ParameterList &plAll,
75 Teuchos::ParameterList &plVal)
77 ParameterList::ConstIterator next = plSome.begin();
79 while (next != plSome.end()){
81 const std::string &name = next->first;
82 const ParameterEntry &entrySome = plSome.getEntry(name);
83 const ParameterEntry &entryAll = plAll.getEntry(name);
85 if (entrySome.isList()){
90 plVal.setEntry(name, entryAll);
97 template <
typename Adapter>
106 using lno_t =
typename Adapter::lno_t;
107 using gno_t =
typename Adapter::gno_t;
109 using mvector_t =
typename Tpetra::MultiVector<scalar_t, lno_t, gno_t, node_t>;
118 Teuchos::ParameterList *p,
119 RCP<Teuchos::ParameterList> sphynxParams,
120 const RCP<
const Teuchos::Comm<int> > &comm):
124 ParameterList validParams;
126 ParameterList allParameters;
133 sphynxParams_->validateParametersAndSetDefaults(validParams, 0);
136 const Teuchos::ParameterEntry *pe = this->
params_->getEntryPtr(
"num_global_parts");
138 nparts = pe->getValue<
int>(&nparts);
141 throw std::runtime_error(
"\nUser did not set num_global_parts"
142 "in the parameter list!n");
145#ifdef HAVE_ZOLTAN2_MPI
147 SphynxProblem(Adapter *A, ParameterList *p, RCP<Teuchos::ParameterList> sphynxParams, MPI_Comm mpicomm):
149 rcp<const Comm<int> >(new
Teuchos::MpiComm<int>(
150 Teuchos::opaqueWrapper(mpicomm))))
155 SphynxProblem(Adapter *A, ParameterList *p, RCP<Teuchos::ParameterList> sphynxParams):
167 void processAlgorithmName(
const std::string& algorithm,
const std::string& defString,
const std::string& model,
168 Environment &env,
bool& removeSelfEdges,
bool& isGraphType,
bool& needConsecutiveGlobalIds)
override;
186 Teuchos::RCP<Teuchos::ParameterList> envParams_;
187 RCP<ParameterList> sphynxParams_;
188 RCP<mvector_t> eigenVectors_;
196 template <
typename Adapter>
198 const std::string &algorithm,
const std::string &defString,
199 const std::string &model,
Environment &env,
bool &removeSelfEdges,
200 bool &isGraphType,
bool &needConsecutiveGlobalIds)
202 this->algName_ = std::string(
"sphynx");
205 template <
typename Adapter>
209 if (this->algName_ == std::string(
"sphynx")) {
214 this->inputAdapter_));
215 if( this->eigenVectors_!=Teuchos::null ){
216 Teuchos::rcp_dynamic_cast<Zoltan2::Sphynx<Adapter>>(this->algorithm_)->setUserEigenvectors(eigenVectors_);
220 throw std::logic_error(
"partitioning algorithm not supported");
229 template <
typename Adapter>
232 eigenVectors_ = userEvects;
238 template <
typename Adapter>
239 Teuchos::RCP<Tpetra::MultiVector<double, typename Adapter::lno_t, typename Adapter::gno_t, typename Adapter::node_t> >
242 if(this->algorithm_!=Teuchos::null){
243 return Teuchos::rcp_dynamic_cast<Zoltan2::Sphynx<Adapter>>(this->algorithm_)->getSphynxEigenvectors();
246 return Teuchos::null;
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
Defines the PartitioningProblem class.
Defines the PartitioningSolution class.
The user parameters, debug, timing and memory profiling output objects, and error checking methods.
static RCP< Teuchos::BoolParameterEntryValidator > getBoolValidator()
Exists to make setting up validators less cluttered.
PartitioningProblem sets up partitioning problems for the user.
RCP< PartitioningSolution< Adapter > > solution_
A PartitioningSolution is a solution to a partitioning problem.
RCP< ParameterList > params_
typename Adapter::node_t node_t
typename Adapter::part_t part_t
void setUserEigenvectors(const RCP< mvector_t > &userEvects)
SphynxProblem(Adapter *A, Teuchos::ParameterList *p, RCP< Teuchos::ParameterList > sphynxParams, const RCP< const Teuchos::Comm< int > > &comm)
void createAlgorithm() override
typename Tpetra::MultiVector< scalar_t, lno_t, gno_t, node_t > mvector_t
typename Adapter::lno_t lno_t
SphynxProblem(Adapter *A, ParameterList *p, RCP< Teuchos::ParameterList > sphynxParams)
typename Adapter::gno_t gno_t
const PartitioningSolution< Adapter > & getSolution()
RCP< mvector_t > getSphynxEigenvectors()
void processAlgorithmName(const std::string &algorithm, const std::string &defString, const std::string &model, Environment &env, bool &removeSelfEdges, bool &isGraphType, bool &needConsecutiveGlobalIds) override
Adapter::base_adapter_t base_adapter_t
typename Adapter::scalar_t weight_t
Created by mbenlioglu on Aug 31, 2020.
static void getSphynxValidParameters(ParameterList &pl)
Set up validators specific to this algorithm.
static void setSphynxValidatorsInList(const Teuchos::ParameterList &plSome, const Teuchos::ParameterList &plAll, Teuchos::ParameterList &plVal)