63 #include "Tpetra_DefaultPlatform.hpp" 66 #include "Teuchos_RCP.hpp" 67 #include "Teuchos_GlobalMPISession.hpp" 68 #include "Teuchos_XMLParameterListHelpers.hpp" 71 #include "create_inline_mesh.h" 74 using Teuchos::ParameterList;
81 typedef Tpetra::DefaultPlatform::DefaultPlatformType
Platform;
82 typedef Tpetra::MultiVector<double, int, int>
tMVector_t;
90 int main(
int narg,
char *arg[]) {
92 Teuchos::GlobalMPISession mpiSession(&narg, &arg,0);
93 Platform &platform = Tpetra::DefaultPlatform::getDefaultPlatform();
94 RCP<const Teuchos::Comm<int> > CommT = platform.getComm();
96 int me = CommT->getRank();
97 int numProcs = CommT->getSize();
101 <<
"====================================================================\n" 103 <<
"| Example: Partition Pamgen Hexahedral Mesh |\n" 105 <<
"| Questions? Contact Karen Devine (kddevin@sandia.gov), |\n" 106 <<
"| Erik Boman (egboman@sandia.gov), |\n" 107 <<
"| Siva Rajamanickam (srajama@sandia.gov). |\n" 109 <<
"| Pamgen's website: http://trilinos.sandia.gov/packages/pamgen |\n" 110 <<
"| Zoltan2's website: http://trilinos.sandia.gov/packages/zoltan2 |\n" 111 <<
"| Trilinos website: http://trilinos.sandia.gov |\n" 113 <<
"====================================================================\n";
119 cout <<
"PARALLEL executable \n";
123 cout <<
"SERIAL executable \n";
132 std::string xmlMeshInFileName(
"Poisson.xml");
133 std::string action(
"mj");
134 int nParts = CommT->getSize();
137 Teuchos::CommandLineProcessor cmdp (
false,
false);
138 cmdp.setOption(
"xmlfile", &xmlMeshInFileName,
139 "XML file with PamGen specifications");
140 cmdp.setOption(
"action", &action,
141 "Method to use: mj, scotch, zoltan_rcb, zoltan_hg, hg_ghost, " 143 cmdp.setOption(
"nparts", &nParts,
144 "Number of parts to create");
145 cmdp.parse(narg, arg);
148 ParameterList inputMeshList;
150 if(xmlMeshInFileName.length()) {
152 cout <<
"\nReading parameter list from the XML file \"" 153 <<xmlMeshInFileName<<
"\" ...\n\n";
155 Teuchos::updateParametersFromXmlFile(xmlMeshInFileName,
156 Teuchos::inoutArg(inputMeshList));
158 inputMeshList.print(cout,2,
true,
true);
163 cout <<
"Cannot read input file: " << xmlMeshInFileName <<
"\n";
168 std::string meshInput = Teuchos::getParameter<std::string>(inputMeshList,
182 if (me == 0) cout <<
"Generating mesh ... \n\n";
185 long long maxInt = 9223372036854775807LL;
186 Create_Pamgen_Mesh(meshInput.c_str(), dim, me, numProcs, maxInt);
189 if (me == 0) cout <<
"Creating mesh adapter ... \n\n";
193 inputAdapter_t ia(*CommT,
"region");
197 if (me == 0) cout <<
"Creating parameter list ... \n\n";
199 Teuchos::ParameterList params(
"test params");
200 params.set(
"timer_output_stream" ,
"std::cout");
202 bool do_partitioning =
false;
203 if (action ==
"mj") {
204 do_partitioning =
true;
205 params.set(
"debug_level",
"basic_status");
206 params.set(
"imbalance_tolerance", 1.1);
207 params.set(
"num_global_parts", nParts);
208 params.set(
"algorithm",
"multijagged");
209 params.set(
"rectilinear",
"yes");
211 else if (action ==
"scotch") {
212 do_partitioning =
true;
213 params.set(
"debug_level",
"verbose_detailed_status");
214 params.set(
"imbalance_tolerance", 1.1);
215 params.set(
"num_global_parts", nParts);
216 params.set(
"partitioning_approach",
"partition");
217 params.set(
"algorithm",
"scotch");
219 else if (action ==
"zoltan_rcb") {
220 do_partitioning =
true;
221 params.set(
"debug_level",
"verbose_detailed_status");
222 params.set(
"imbalance_tolerance", 1.1);
223 params.set(
"num_global_parts", nParts);
224 params.set(
"partitioning_approach",
"partition");
225 params.set(
"algorithm",
"zoltan");
227 else if (action ==
"zoltan_hg") {
228 do_partitioning =
true;
229 params.set(
"debug_level",
"verbose_detailed_status");
230 params.set(
"imbalance_tolerance", 1.1);
231 params.set(
"num_global_parts", nParts);
232 params.set(
"partitioning_approach",
"partition");
233 params.set(
"algorithm",
"zoltan");
234 Teuchos::ParameterList &zparams = params.sublist(
"zoltan_parameters",
false);
235 zparams.set(
"LB_METHOD",
"phg");
236 zparams.set(
"FINAL_OUTPUT",
"1");
238 else if (action==
"hg_ghost") {
239 do_partitioning =
true;
240 params.set(
"debug_level",
"no_status");
241 params.set(
"imbalance_tolerance", 1.1);
242 params.set(
"algorithm",
"zoltan");
243 params.set(
"num_global_parts", nParts);
244 params.set(
"hypergraph_model_type",
"ghosting");
245 params.set(
"ghost_layers",2);
246 Teuchos::ParameterList &zparams = params.sublist(
"zoltan_parameters",
false);
247 zparams.set(
"LB_METHOD",
"HYPERGRAPH");
248 zparams.set(
"LB_APPROACH",
"PARTITION");
249 zparams.set(
"PHG_EDGE_SIZE_THRESHOLD",
"1.0");
252 else if (action ==
"parma") {
253 do_partitioning =
true;
254 params.set(
"debug_level",
"basic_status");
255 params.set(
"imbalance_tolerance", 1.05);
256 params.set(
"algorithm",
"parma");
257 Teuchos::ParameterList &pparams = params.sublist(
"parma_parameters",
false);
258 pparams.set(
"parma_method",
"VtxElm");
260 else if (action==
"zoltan_hg") {
261 do_partitioning =
true;
262 params.set(
"debug_level",
"no_status");
263 params.set(
"imbalance_tolerance", 1.1);
264 params.set(
"algorithm",
"zoltan");
265 params.set(
"num_global_parts", nParts);
266 Teuchos::ParameterList &zparams = params.sublist(
"zoltan_parameters",
false);
267 zparams.set(
"LB_METHOD",
"HYPERGRAPH");
268 params.set(
"compute_metrics",
"yes");
272 else if (action ==
"color") {
273 params.set(
"debug_level",
"verbose_detailed_status");
274 params.set(
"debug_output_file",
"kdd");
275 params.set(
"debug_procs",
"all");
278 if(me == 0) cout <<
"Action: " << action << endl;
280 if (do_partitioning) {
281 if (me == 0) cout <<
"Creating partitioning problem ... \n\n";
286 if (me == 0) cout <<
"Calling the partitioner ... \n\n";
293 if (me == 0) cout <<
"Creating coloring problem ... \n\n";
298 if (me == 0) cout <<
"Calling the coloring algorithm ... \n\n";
306 if (me == 0) cout <<
"Deleting the mesh ... \n\n";
308 Delete_Pamgen_Mesh();
311 std::cout <<
"PASS" << std::endl;
ColoringProblem sets up coloring problems for the user.
Defines the ColoringProblem class.
void solve(bool updateInputData=true)
Direct the problem to create a solution.
Defines the PamgenMeshAdapter class.
Tpetra::DefaultPlatform::DefaultPlatformType Platform
int main(int narg, char *arg[])
void printMetrics(std::ostream &os) const
Print the array of metrics.
void printTimers() const
Return the communicator passed to the problem.
PartitioningProblem sets up partitioning problems for the user.
Defines the Environment class.
Defines the PartitioningProblem class.
This class represents a mesh.
Tpetra::MultiVector< double, int, int > tMVector_t
void solve(bool updateInputData=true)
Direct the problem to create a solution.