14 #ifndef ZOLTAN2_PROBLEM_FACTORY_HPP
15 #define ZOLTAN2_PROBLEM_FACTORY_HPP
23 using namespace Zoltan2_TestingFramework;
24 using namespace Zoltan2;
26 namespace Zoltan2_TestingFramework {
40 RCP<AdapterFactory> adapterFactory,
42 #ifdef HAVE_ZOLTAN2_MPI
47 problem_name = problemName;
48 adapterType = adapterFactory->getMainAdapterType();
50 #ifdef HAVE_ZOLTAN2_MPI
51 #define CREATE_PRBLM(problemClass, adapterClass) \
52 adapterClass * pCast = dynamic_cast<adapterClass *> \
53 (adapterFactory->getMainAdapter()); \
54 if(!pCast) { throw std::logic_error( \
55 "ProblemFactory adapter dynamic_cast failed for problem name " \
56 + problem_name + " and adapterClass " + #adapterClass ); } \
57 problem = rcp(new problemClass<adapterClass>(pCast, params, comm));
59 #define CREATE_PRBLM(problemClass, adapterClass) \
60 adapterClass * pCast = dynamic_cast<adapterClass *> \
61 (adapterFactory->getMainAdapter()); \
62 if(!pCast) { throw std::logic_error( \
63 "ProblemFactory adapter dynamic_cast failed for problem name " \
64 + problem_name + " and adapterClass " + #adapterClass ); } \
65 problem = rcp(new problemClass<adapterClass>(pCast, params));
68 #define MAKE_PARTITION_PROBLEM(adapterClass) \
69 CREATE_PRBLM(PartitioningProblem, adapterClass);
71 #define MAKE_ORDERING_PROBLEM(adapterClass) \
72 CREATE_PRBLM(OrderingProblem, adapterClass);
75 if(problem_name ==
"partitioning") {
78 else if(problem_name ==
"ordering") {
82 if(problem == Teuchos::null) {
83 throw std::logic_error(
"ProblemFactory failed to create Problem!");
92 std::string problem_name;
94 RCP<ProblemRoot> problem;
97 #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