14 #ifndef _ZOLTAN2_MATRIXPARTITIONINGPROBLEM_HPP_
15 #define _ZOLTAN2_MATRIXPARTITIONINGPROBLEM_HPP_
68 template<
typename Adapter>
85 const RCP<
const Teuchos::Comm<int> > &comm):
86 Problem<Adapter>(A,p,comm), solution_(),
96 #ifdef HAVE_ZOLTAN2_MPI
97 typedef Teuchos::OpaqueWrapper<MPI_Comm> mpiWrapper_t;
102 rcp<const Comm<int> >(new Teuchos::MpiComm<int>(
103 Teuchos::opaqueWrapper(mpicomm))))
146 void solve(
bool updateInputData=
true );
154 return *(solution_.getRawPtr());
172 Array<std::string> algorithm_names(1);
173 algorithm_names[0] =
"2D Cartesian";
174 RCP<Teuchos::StringValidator> algorithm_Validator = Teuchos::rcp(
175 new Teuchos::StringValidator( algorithm_names ));
176 pl.set(
"algorithm",
"2D Cartesian",
"partitioning algorithm",
177 algorithm_Validator);
193 pl.set(
"imbalance_tolerance", 1.1,
"imbalance tolerance, ratio of "
197 RCP<Teuchos::EnhancedNumberValidator<int>> num_global_parts_Validator =
198 Teuchos::rcp(
new Teuchos::EnhancedNumberValidator<int>(
199 1, Teuchos::EnhancedNumberTraits<int>::max()) );
200 pl.set(
"num_global_parts", 1,
"global number of parts to compute "
201 "(0 means use the number of processes)", num_global_parts_Validator);
204 RCP<Teuchos::EnhancedNumberValidator<int>> num_local_parts_Validator =
205 Teuchos::rcp(
new Teuchos::EnhancedNumberValidator<int>(
206 0, Teuchos::EnhancedNumberTraits<int>::max()) );
207 pl.set(
"num_local_parts", 0,
"number of parts to compute for this "
208 "process (num_global_parts == sum of all num_local_parts)",
209 num_local_parts_Validator);
233 void initializeProblem();
235 void createPartitioningProblem(
bool newData);
237 RCP<MatrixPartitioningSolution<Adapter> > solution_;
243 std::string algName_;
251 template <
typename Adapter>
252 void MatrixPartitioningProblem<Adapter>::initializeProblem()
256 this->env_->debug(
DETAILED_STATUS,
"MatrixPartitioningProblem::initializeProblem");
258 inputType_ = this->inputAdapter_->adapterType();
263 std::cerr <<
"Error: only matrix adapter type supported" << std::endl;
267 this->env_->memory(
"After initializeProblem");
273 template <
typename Adapter>
276 std::cout <<
"MatrixPartitioningProblem solve " << std::endl;
285 createPartitioningProblem(updateInputData);
309 this->baseInputAdapter_));
318 this->env_->timerStart(
MACRO_TIMERS,
"create solution");
323 this->envConst_, this->comm_,
328 solution_ = rcp(soln);
331 this->env_->memory(
"After creating Solution");
337 this->algorithm_->partitionMatrix(solution_);
347 template <
typename Adapter>
351 "MatrixPartitioningProblem::createPartitioningProblem");
353 using Teuchos::ParameterList;
376 const Teuchos::ParameterEntry *pe;
377 std::string defString(
"default");
390 std::string algorithm(defString);
391 pe = pl.getEntryPtr(
"algorithm");
393 algorithm = pe->getValue<std::string>(&algorithm);
401 if (algorithm != defString)
405 if (algorithm == std::string(
"2D Cartesian"))
407 algName_ = algorithm;
412 throw std::logic_error(
"parameter list algorithm is invalid");
Zoltan2::BaseAdapter< userTypes_t > base_adapter_t
Time an algorithm (or other entity) as a whole.
MatrixPartitioningProblem(Adapter *A, ParameterList *p, const RCP< const Teuchos::Comm< int > > &comm)
Constructor where Teuchos communicator is specified.
~MatrixPartitioningProblem()
Destructor.
static void getValidParameters(ParameterList &pl)
Set up validators specific to this Problem.
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
MatrixPartitioningProblem sets up partitioning problems for the user.
Adapter::base_adapter_t base_adapter_t
map_t::global_ordinal_type gno_t
MatrixPartitioningProblem(Adapter *A, ParameterList *p)
Constructor where communicator is the Teuchos default.
static RCP< Teuchos::AnyNumberParameterEntryValidator > getAnyDoubleValidator()
Exists to make setting up validators less cluttered.
sub-steps, each method's entry and exit
SparseMatrixAdapter_t::part_t part_t
Teuchos::ParameterList & getParametersNonConst()
Returns a reference to a non-const copy of the parameters.
A PartitioningSolution is a solution to a partitioning problem.
const PartitioningSolution< Adapter > & getSolution()
Get the solution to the problem.
BaseAdapterType
An enum to identify general types of adapters.
Problem base class from which other classes (PartitioningProblem, ColoringProblem, OrderingProblem, MatchingProblem, etc.) derive.
Defines the Problem base class.
map_t::local_ordinal_type lno_t
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
void solve(bool updateInputData=true)
Direct the problem to create a solution.
Adapter::scalar_t scalar_t
A PartitioningSolution is a solution to a partitioning problem.
Zoltan2::BasicUserTypes< zscalar_t, zlno_t, zgno_t > user_t