50 #ifndef ZOLTAN2_PROBLEM_FACTORY_HPP
51 #define ZOLTAN2_PROBLEM_FACTORY_HPP
59 using namespace Zoltan2_TestingFramework;
60 using namespace Zoltan2;
62 namespace Zoltan2_TestingFramework {
76 RCP<AdapterFactory> adapterFactory,
78 #ifdef HAVE_ZOLTAN2_MPI
83 problem_name = problemName;
84 adapterType = adapterFactory->getMainAdapterType();
86 #ifdef HAVE_ZOLTAN2_MPI
87 #define CREATE_PRBLM(problemClass, adapterClass) \
88 adapterClass * pCast = dynamic_cast<adapterClass *> \
89 (adapterFactory->getMainAdapter()); \
90 if(!pCast) { throw std::logic_error( \
91 "ProblemFactory adapter dynamic_cast failed for problem name " \
92 + problem_name + " and adapterClass " + #adapterClass ); } \
93 problem = rcp(new problemClass<adapterClass>(pCast, params, comm));
95 #define CREATE_PRBLM(problemClass, adapterClass) \
96 adapterClass * pCast = dynamic_cast<adapterClass *> \
97 (adapterFactory->getMainAdapter()); \
98 if(!pCast) { throw std::logic_error( \
99 "ProblemFactory adapter dynamic_cast failed for problem name " \
100 + problem_name + " and adapterClass " + #adapterClass ); } \
101 problem = rcp(new problemClass<adapterClass>(pCast, params));
104 #define MAKE_PARTITION_PROBLEM(adapterClass) \
105 CREATE_PRBLM(PartitioningProblem, adapterClass);
107 #define MAKE_ORDERING_PROBLEM(adapterClass) \
108 CREATE_PRBLM(OrderingProblem, adapterClass);
111 if(problem_name ==
"partitioning") {
114 else if(problem_name ==
"ordering") {
118 if(problem == Teuchos::null) {
119 throw std::logic_error(
"ProblemFactory failed to create Problem!");
128 std::string problem_name;
130 RCP<ProblemRoot> problem;
133 #endif // ZOLTAN2_PROBLEM_FACTORY_HPP
keep typedefs that commonly appear in many places localized
Defines the ColoringProblem class.
ProblemFactory class contains 1 static factory method.
common code used by tests
RCP< ProblemRoot > getProblem()
#define MAKE_PARTITION_PROBLEM(adapterClass)
#define Z2_TEST_UPCAST(adptr, TEMPLATE_ACTION)
EAdapterType getAdapterType() const
#define MAKE_ORDERING_PROBLEM(adapterClass)
Defines the Problem base class.
Defines the OrderingProblem class.
ProblemFactory(const std::string &problemName, RCP< AdapterFactory > adapterFactory, ParameterList *params)
Zoltan2::Problem factory method
Defines the PartitioningProblem class.
const std::string & getProblemName() const