Zoltan2
Toggle main menu visibility
Loading...
Searching...
No Matches
Zoltan2_ProblemFactory.hpp
Go to the documentation of this file.
1
// @HEADER
2
//
3
// ***********************************************************************
4
//
5
// Zoltan2: A package of combinatorial algorithms for scientific computing
6
// Copyright 2012 Sandia Corporation
7
//
8
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
9
// the U.S. Government retains certain rights in this software.
10
//
11
// Redistribution and use in source and binary forms, with or without
12
// modification, are permitted provided that the following conditions are
13
// met:
14
//
15
// 1. Redistributions of source code must retain the above copyright
16
// notice, this list of conditions and the following disclaimer.
17
//
18
// 2. Redistributions in binary form must reproduce the above copyright
19
// notice, this list of conditions and the following disclaimer in the
20
// documentation and/or other materials provided with the distribution.
21
//
22
// 3. Neither the name of the Corporation nor the names of the
23
// contributors may be used to endorse or promote products derived from
24
// this software without specific prior written permission.
25
//
26
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
//
38
// Questions? Contact Karen Devine (kddevin@sandia.gov)
39
// Erik Boman (egboman@sandia.gov)
40
// Siva Rajamanickam (srajama@sandia.gov)
41
//
42
// ***********************************************************************
43
//
44
// @HEADER
45
50
#ifndef ZOLTAN2_PROBLEM_FACTORY_HPP
51
#define ZOLTAN2_PROBLEM_FACTORY_HPP
52
#include <
Zoltan2_TestHelpers.hpp
>
53
#include <
Zoltan2_Problem.hpp
>
54
#include <
Zoltan2_PartitioningProblem.hpp
>
55
#include <
Zoltan2_OrderingProblem.hpp
>
56
#include <
Zoltan2_ColoringProblem.hpp
>
57
#include <
Zoltan2_Typedefs.hpp
>
58
59
using namespace
Zoltan2_TestingFramework
;
60
using namespace
Zoltan2
;
61
62
namespace
Zoltan2_TestingFramework
{
64
class
ProblemFactory
{
65
public
:
75
ProblemFactory
(
const
std::string & problemName,
76
RCP<AdapterFactory> adapterFactory,
77
ParameterList *params
78
#ifdef HAVE_ZOLTAN2_MPI
79
, MPI_Comm comm
80
#endif
81
) {
82
83
problem_name = problemName;
84
adapterType = adapterFactory->getMainAdapterType();
85
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));
94
#else
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));
102
#endif
103
104
#define MAKE_PARTITION_PROBLEM(adapterClass) \
105
CREATE_PRBLM(PartitioningProblem, adapterClass);
106
107
#define MAKE_ORDERING_PROBLEM(adapterClass) \
108
CREATE_PRBLM(OrderingProblem, adapterClass);
109
110
// PartitioningProblem
111
if
(problem_name ==
"partitioning"
) {
112
Z2_TEST_UPCAST
(adapterType,
MAKE_PARTITION_PROBLEM
)
113
}
114
else
if
(problem_name ==
"ordering"
) {
115
Z2_TEST_UPCAST
(adapterType,
MAKE_ORDERING_PROBLEM
)
116
}
117
118
if
(problem == Teuchos::null) {
119
throw
std::logic_error(
"ProblemFactory failed to create Problem!"
);
120
}
121
}
122
123
RCP<ProblemRoot>
getProblem
() {
return
problem; }
124
const
std::string &
getProblemName
()
const
{
return
problem_name; }
125
EAdapterType
getAdapterType
()
const
{
return
adapterType; }
126
127
private
:
128
std::string problem_name;
// string converts to a problem type
129
EAdapterType
adapterType;
// converts to an adapter type
130
RCP<ProblemRoot> problem;
131
};
132
}
133
#endif
// ZOLTAN2_PROBLEM_FACTORY_HPP
134
Zoltan2_ColoringProblem.hpp
Defines the ColoringProblem class.
Zoltan2_OrderingProblem.hpp
Defines the OrderingProblem class.
Zoltan2_PartitioningProblem.hpp
Defines the PartitioningProblem class.
MAKE_PARTITION_PROBLEM
#define MAKE_PARTITION_PROBLEM(adapterClass)
MAKE_ORDERING_PROBLEM
#define MAKE_ORDERING_PROBLEM(adapterClass)
Zoltan2_Problem.hpp
Defines the Problem base class.
Zoltan2_TestHelpers.hpp
common code used by tests
Zoltan2_Typedefs.hpp
keep typedefs that commonly appear in many places localized
Z2_TEST_UPCAST
#define Z2_TEST_UPCAST(adptr, TEMPLATE_ACTION)
Definition
Zoltan2_Typedefs.hpp:216
Zoltan2_TestingFramework::ProblemFactory::ProblemFactory
ProblemFactory(const std::string &problemName, RCP< AdapterFactory > adapterFactory, ParameterList *params)
\brif Zoltan2::Problem factory method
Definition
Zoltan2_ProblemFactory.hpp:75
Zoltan2_TestingFramework::ProblemFactory::getAdapterType
EAdapterType getAdapterType() const
Definition
Zoltan2_ProblemFactory.hpp:125
Zoltan2_TestingFramework::ProblemFactory::getProblem
RCP< ProblemRoot > getProblem()
Definition
Zoltan2_ProblemFactory.hpp:123
Zoltan2_TestingFramework::ProblemFactory::getProblemName
const std::string & getProblemName() const
Definition
Zoltan2_ProblemFactory.hpp:124
Zoltan2_TestingFramework
Definition
Zoltan2_EvaluateFactory.hpp:62
Zoltan2_TestingFramework::EAdapterType
EAdapterType
Definition
Zoltan2_Typedefs.hpp:201
Zoltan2
Created by mbenlioglu on Aug 31, 2020.
Definition
Zoltan2_AlgHybrid2GL.hpp:38
test
core
helpers
Zoltan2_ProblemFactory.hpp
Generated by
1.17.0