50 #ifndef _ZOLTAN2_PROBLEM_HPP_ 51 #define _ZOLTAN2_PROBLEM_HPP_ 66 template<
typename Adapter>
70 #ifdef HAVE_ZOLTAN2_MPI 73 Problem(
const Adapter *input, ParameterList *params, MPI_Comm comm):
80 RCP<Teuchos::OpaqueWrapper<MPI_Comm> > wrapper =
81 Teuchos::opaqueWrapper(comm);
82 comm_ = rcp<const Comm<int> >(
new Teuchos::MpiComm<int>(wrapper));
83 setupProblemEnvironment(params);
90 Problem(
const Adapter *input, ParameterList *params):
97 comm_ = DefaultComm<int>::getComm();
98 setupProblemEnvironment(params);
104 Problem(
const Adapter *input, ParameterList *params,
105 RCP<
const Comm<int> > &comm):
112 setupProblemEnvironment(params);
129 virtual void solve(
bool updateInputData) = 0;
147 #ifdef Z2_OMIT_ALL_ERROR_CHECKING 153 timer_->printAndResetToZero();
203 void setupProblemEnvironment(ParameterList *pl);
207 template <
typename Adapter>
211 env_ = rcp(
new Environment(*params, Teuchos::DefaultComm<int>::getComm()));
217 ParameterList &processedParameters =
env_->getParametersNonConst();
218 params_ = rcp<ParameterList>(&processedParameters,
false);
220 #ifndef Z2_OMIT_ALL_PROFILING 224 bool haveType=
false, haveStream=
false, haveFile=
false;
227 const Teuchos::ParameterEntry *pe = pl.getEntryPtr(
"timer_type");
230 choice = pe->getValue<
int>(&choice);
237 pe = pl.getEntryPtr(
"timer_output_file");
240 fname = pe->getValue<std::string>(&fname);
241 std::ofstream *dbgFile =
new std::ofstream;
242 if (
comm_->getRank()==0){
245 dbgFile->open(fname.c_str(), std::ios::out|std::ios::trunc);
247 catch(std::exception &e){
248 throw std::runtime_error(e.what());
255 pe = pl.getEntryPtr(
"timer_output_stream");
257 choice = pe->getValue<
int>(&choice);
263 if (haveStream || haveType){
269 std::ofstream *of = NULL;
275 if (haveType || haveStream || haveFile)
276 env_->setTimer(timer_);
282 template <
typename Adapter>
285 env_ = rcp(
new Environment(*params, Teuchos::DefaultComm<int>::getComm()));
288 ParameterList &processedParameters =
env_->getParametersNonConst();
289 params_ = rcp<ParameterList>(&processedParameters,
false);
294 if (!timer_.is_null())
295 env_->setTimer(timer_);
RCP< GraphModel< base_adapter_t > > graphModel_
Time an algorithm (or other entity) as a whole.
RCP< const base_adapter_t > baseInputAdapter_
virtual void solve(bool updateInputData)=0
Method that creates a solution.
Problem(const Adapter *input, ParameterList *params)
Constructor where communicator is Teuchos default.
Adapter::base_adapter_t base_adapter_t
#define Z2_FORWARD_EXCEPTIONS
Forward an exception back through call stack.
Problem(const Adapter *input, ParameterList *params, RCP< const Comm< int > > &comm)
Constructor where Teuchos communicator is specified.
virtual ~Problem()
Destructor.
TimerType
The type of timers which should be active.
RCP< Algorithm< Adapter > > algorithm_
/dev/null: do actions but don't output results
RCP< const Comm< int > > comm_
void resetParameters(ParameterList *params)
Reset the list of parameters.
RCP< IdentifierModel< base_adapter_t > > identifierModel_
Defines the IdentifierModel interface.
OSType
Output stream types.
RCP< const Comm< int > > getComm()
Return the communicator used by the problem.
Problem base class from which other classes (PartitioningProblem, ColoringProblem, OrderingProblem, MatchingProblem, etc.) derive.
RCP< const Adapter > inputAdapter_
void printTimers() const
Return the communicator passed to the problem.
RCP< CoordinateModel< base_adapter_t > > coordinateModel_
The user parameters, debug, timing and memory profiling output objects, and error checking methods...
RCP< TimerManager > timer_
Defines the CoordinateModel classes.
Gathering definitions used in software development.
RCP< ParameterList > params_
Defines the GraphModel interface.
RCP< const Model< base_adapter_t > > baseModel_
RCP< const Environment > envConst_
Declarations for TimerManager.