Debian Codegraph @

packages/muelu/research/luc/region_algorithms/Driver_Structured_Regions.cpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // MueLu: A package for multigrid based preconditioning
4 //
5 // Copyright 2012 NTESS and the MueLu contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #include <cstdio>
11 #include <iomanip>
12 #include <iostream>
13 #include <unistd.h>
14
15 #include <Teuchos_XMLParameterListHelpers.hpp>
16 #include <Teuchos_YamlParameterListHelpers.hpp>
17 #include <Teuchos_StandardCatchMacros.hpp>
18
19 // Xpetra
20 #include <Xpetra_MultiVectorFactory.hpp>
21 #include <Xpetra_ImportFactory.hpp>
22 #include <Xpetra_Operator.hpp>
23 #include <Xpetra_Map.hpp>
24 #include <Xpetra_MultiVector.hpp>
25 #include <Xpetra_IO.hpp>
26
27 // Galeri
28 #include <Galeri_XpetraParameters.hpp>
29 #include <Galeri_XpetraProblemFactory.hpp>
30 #include <Galeri_XpetraUtils.hpp>
31 #include <Galeri_XpetraMaps.hpp>
32
33 #include <MueLu.hpp>
34
35 #include <MueLu_BaseClass.hpp>
36 #ifdef HAVE_MUELU_EXPLICIT_INSTANTIATION
37 #include <MueLu_ExplicitInstantiation.hpp>
38 #endif
39 #include <MueLu_Level.hpp>
40 #include <MueLu_MutuallyExclusiveTime.hpp>
41 #include <MueLu_ParameterListInterpreter.hpp>
42 #include <MueLu_Utilities.hpp>
43
44 #ifdef HAVE_MUELU_BELOS
45 #include <BelosConfigDefs.hpp>
46 #include <BelosBiCGStabSolMgr.hpp>
47 #include <BelosBlockCGSolMgr.hpp>
48 #include <BelosBlockGmresSolMgr.hpp>
49 #include <BelosLinearProblem.hpp>
50 #include <BelosPseudoBlockCGSolMgr.hpp>
51 #include <BelosXpetraAdapter.hpp> // => This header defines Belos::XpetraOp
52 #include <BelosMueLuAdapter.hpp> // => This header defines Belos::MueLuOp
53 #include <BelosTpetraAdapter.hpp> // => This header defines Belos::TpetraOp
54 #endif
55
56 #ifdef HAVE_MUELU_CUDA
57 #include "cuda_profiler_api.h"
58 #endif
59
60 #include <MueLu_TpetraOperator.hpp>
61 #include <MueLu_CreateTpetraPreconditioner.hpp>
62 #include <Xpetra_TpetraOperator.hpp>
63 #include "Xpetra_TpetraMultiVector.hpp"
64 #include <KokkosBlas1_abs.hpp>
65 #include <Tpetra_leftAndOrRightScaleCrsMatrix.hpp>
66 #include <Tpetra_computeRowAndColumnOneNorms.hpp>
67
68 #ifdef HAVE_MUELU_EPETRA
69 #include "Xpetra_EpetraMultiVector.hpp"
70 #endif
71
72 #include <MueLu_CreateXpetraPreconditioner.hpp>
73
74 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
75 int main_(Teuchos::CommandLineProcessor &clp, Xpetra::UnderlyingLib &lib, int argc, char *argv[]) {
76 #include <MueLu_UseShortNames.hpp>
77 using Teuchos::ArrayRCP;
78 using Teuchos::ParameterList;
79 using Teuchos::RCP;
80 using Teuchos::rcp;
81 using Teuchos::TimeMonitor;
82
83 // =========================================================================
84 // MPI initialization using Teuchos
85 // =========================================================================
86 RCP<const Teuchos::Comm<int> > comm = Teuchos::DefaultComm<int>::getComm();
87 const int myRank = comm->getRank();
88
89 // =========================================================================
90 // Convenient definitions
91 // =========================================================================
92 typedef Teuchos::ScalarTraits<SC> STS;
93 SC zero = STS::zero(), one = STS::one();
94 typedef typename STS::magnitudeType real_type;
95 typedef Xpetra::MultiVector<real_type, LO, GO, NO> RealValuedMultiVector;
96
97 // =========================================================================
98 // Parameters initialization
99 // =========================================================================
100 GO nx = 10, ny = 10, nz = 10;
101 Galeri::Xpetra::Parameters<GO> galeriParameters(clp, nx, ny, nz, "Laplace2D"); // manage parameters of the test case
102 Xpetra::Parameters xpetraParameters(clp); // manage parameters of Xpetra
103
104 std::string xmlFileName = "";
105 clp.setOption("xml", &xmlFileName, "read parameters from an xml file");
106 std::string yamlFileName = "";
107 clp.setOption("yaml", &yamlFileName, "read parameters from a yaml file");
108 int maxIts = 200;
109 clp.setOption("its", &maxIts, "maximum number of solver iterations");
110 double tol = 1e-12;
111 clp.setOption("tol", &tol, "solver convergence tolerance");
112 bool scaleResidualHist = true;
113 clp.setOption("scale", "noscale", &scaleResidualHist, "scaled Krylov residual history");
114 bool solvePreconditioned = true;
115 clp.setOption("solve-preconditioned", "no-solve-preconditioned", &solvePreconditioned, "use MueLu preconditioner in solve");
116 std::string equilibrate = "no";
117 clp.setOption("equilibrate", &equilibrate, "equilibrate the system (no | diag | 1-norm)");
118 #ifdef HAVE_MUELU_CUDA
119 bool profileSetup = false;
120 clp.setOption("cuda-profile-setup", "no-cuda-profile-setup", &profileSetup, "enable CUDA profiling for setup");
121 bool profileSolve = false;
122 clp.setOption("cuda-profile-solve", "no-cuda-profile-solve", &profileSolve, "enable CUDA profiling for solve");
123 #endif
124 int cacheSize = 0;
125 clp.setOption("cachesize", &cacheSize, "cache size (in KB)");
126
127 clp.recogniseAllOptions(true);
128 switch (clp.parse(argc, argv)) {
129 case Teuchos::CommandLineProcessor::PARSE_HELP_PRINTED: return EXIT_SUCCESS;
130 case Teuchos::CommandLineProcessor::PARSE_ERROR:
131 case Teuchos::CommandLineProcessor::PARSE_UNRECOGNIZED_OPTION: return EXIT_FAILURE;
132 case Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL: break;
133 }
134
135 TEUCHOS_TEST_FOR_EXCEPTION(xmlFileName != "" && yamlFileName != "", std::runtime_error,
136 "Cannot provide both xml and yaml input files");
137
138 // Instead of checking each time for rank, create a rank 0 stream
139 RCP<Teuchos::FancyOStream> fancy = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
140 Teuchos::FancyOStream &out = *fancy;
141 out.setOutputToRootOnly(0);
142
143 ParameterList paramList;
144 auto inst = xpetraParameters.GetInstantiation();
145
146 if (yamlFileName != "") {
147 Teuchos::updateParametersFromYamlFileAndBroadcast(yamlFileName, Teuchos::Ptr<ParameterList>(&paramList), *comm);
148 } else {
149 if (inst == Xpetra::COMPLEX_INT_INT)
150 xmlFileName = (xmlFileName != "" ? xmlFileName : "structured_1dof-complex.xml");
151 else
152 xmlFileName = (xmlFileName != "" ? xmlFileName : "structured_1dof.xml");
153 Teuchos::updateParametersFromXmlFileAndBroadcast(xmlFileName, Teuchos::Ptr<ParameterList>(&paramList), *comm);
154 }
155
156 // Retrieve matrix parameters (they may have been changed on the command line)
157 // [for instance, if we changed matrix type from 2D to 3D we need to update nz]
158 ParameterList galeriList = galeriParameters.GetParameterList();
159
160 // =========================================================================
161 // Problem construction
162 // =========================================================================
163 std::ostringstream galeriStream;
164 #ifdef HAVE_MUELU_OPENMP
165 std::string node_name = Node::name();
166 if (!comm->getRank() && !node_name.compare("OpenMP/Wrapper"))
167 galeriStream << "OpenMP Max Threads = " << omp_get_max_threads() << std::endl;
168 #endif
169
170 comm->barrier();
171 Teuchos::TimeMonitor::setStackedTimer(Teuchos::null);
172 RCP<TimeMonitor> globalTimeMonitor = rcp(new TimeMonitor(*TimeMonitor::getNewTimer("Driver: S - Global Time")));
173 RCP<TimeMonitor> tm = rcp(new TimeMonitor(*TimeMonitor::getNewTimer("Driver: 1 - Matrix Build")));
174
175 RCP<Matrix> A;
176 RCP<const Map> map;
177 RCP<RealValuedMultiVector> coordinates;
178 typedef typename RealValuedMultiVector::scalar_type Real;
179 RCP<Xpetra::MultiVector<SC, LO, GO, NO> > nullspace;
180 RCP<MultiVector> X, B;
181
182 galeriStream << "========================================================\n"
183 << xpetraParameters << galeriParameters;
184
185 // Galeri will attempt to create a square-as-possible distribution of subdomains di, e.g.,
186 // d1 d2 d3
187 // d4 d5 d6
188 // d7 d8 d9
189 // d10 d11 d12
190 // A perfect distribution is only possible when the #processors is a perfect square.
191 // This *will* result in "strip" distribution if the #processors is a prime number or if the factors are very different in
192 // size. For example, np=14 will give a 7-by-2 distribution.
193 // If you don't want Galeri to do this, specify mx or my on the galeriList.
194 std::string matrixType = galeriParameters.GetMatrixType();
195 int numDimensions = 0;
196 int numDofsPerNode = 1;
197 Teuchos::Array<GO> procsPerDim(3);
198 Teuchos::Array<GO> gNodesPerDim(3);
199 Teuchos::Array<LO> lNodesPerDim(3);
200
201 // Create map and coordinates
202 // In the future, we hope to be able to first create a Galeri problem, and then request map and coordinates from it
203 // At the moment, however, things are fragile as we hope that the Problem uses same map and coordinates inside
204 if (matrixType == "Laplace1D") {
205 numDimensions = 1;
206 map = Galeri::Xpetra::CreateMap<LO, GO, Node>(xpetraParameters.GetLib(), "Cartesian1D", comm, galeriList);
207 coordinates = Galeri::Xpetra::Utils::CreateCartesianCoordinates<double, LO, GO, Map, RealValuedMultiVector>("1D", map, galeriList);
208
209 } else if (matrixType == "Laplace2D" || matrixType == "Star2D" ||
210 matrixType == "BigStar2D" || matrixType == "Elasticity2D") {
211 numDimensions = 2;
212 map = Galeri::Xpetra::CreateMap<LO, GO, Node>(xpetraParameters.GetLib(), "Cartesian2D", comm, galeriList);
213 coordinates = Galeri::Xpetra::Utils::CreateCartesianCoordinates<double, LO, GO, Map, RealValuedMultiVector>("2D", map, galeriList);
214
215 } else if (matrixType == "Laplace3D" || matrixType == "Brick3D" || matrixType == "Elasticity3D") {
216 numDimensions = 3;
217 map = Galeri::Xpetra::CreateMap<LO, GO, Node>(xpetraParameters.GetLib(), "Cartesian3D", comm, galeriList);
218 coordinates = Galeri::Xpetra::Utils::CreateCartesianCoordinates<double, LO, GO, Map, RealValuedMultiVector>("3D", map, galeriList);
219 }
220
221 // Expand map to do multiple DOF per node for block problems
222 if (matrixType == "Elasticity2D")
223 map = Xpetra::MapFactory<LO, GO, Node>::Build(map, 2);
224 if (matrixType == "Elasticity3D")
225 map = Xpetra::MapFactory<LO, GO, Node>::Build(map, 3);
226
227 galeriStream << "Processor subdomains in x direction: " << galeriList.get<GO>("mx") << std::endl
228 << "Processor subdomains in y direction: " << galeriList.get<GO>("my") << std::endl
229 << "Processor subdomains in z direction: " << galeriList.get<GO>("mz") << std::endl
230 << "========================================================" << std::endl;
231
232 if (matrixType == "Elasticity2D" || matrixType == "Elasticity3D") {
233 // Our default test case for elasticity: all boundaries of a square/cube have Neumann b.c. except left which has Dirichlet
234 galeriList.set("right boundary", "Neumann");
235 galeriList.set("bottom boundary", "Neumann");
236 galeriList.set("top boundary", "Neumann");
237 galeriList.set("front boundary", "Neumann");
238 galeriList.set("back boundary", "Neumann");
239 }
240
241 RCP<Galeri::Xpetra::Problem<Map, CrsMatrixWrap, MultiVector> > Pr =
242 Galeri::Xpetra::BuildProblem<SC, LO, GO, Map, CrsMatrixWrap, MultiVector>(galeriParameters.GetMatrixType(), map, galeriList);
243 A = Pr->BuildMatrix();
244
245 if (matrixType == "Elasticity2D") {
246 numDofsPerNode = 2;
247 } else if (matrixType == "Elasticity3D") {
248 numDofsPerNode = 3;
249 }
250
251 A->SetFixedBlockSize(numDofsPerNode);
252
253 X = VectorFactory::Build(map);
254 B = VectorFactory::Build(map);
255
256 // we set seed for reproducibility
257 Utilities::SetRandomSeed(*comm);
258 X->randomize();
259 A->apply(*X, *B, Teuchos::NO_TRANS, one, zero);
260
261 Teuchos::Array<typename STS::magnitudeType> norms(1);
262 B->norm2(norms);
263 B->scale(one / norms[0]);
264 galeriStream << "Galeri complete.\n========================================================" << std::endl;
265
266 out << galeriStream.str();
267
268 comm->barrier();
269 tm = Teuchos::null;
270
271 tm = rcp(new TimeMonitor(*TimeMonitor::getNewTimer("Driver: 2 - Compute region data")));
272
273 // Loading geometric info from galeri
274 if (numDimensions == 1) {
275 gNodesPerDim[0] = galeriList.get<GO>("nx");
276 gNodesPerDim[1] = 1;
277 gNodesPerDim[2] = 1;
278
279 lNodesPerDim[0] = galeriList.get<LO>("lnx");
280 lNodesPerDim[1] = 1;
281 lNodesPerDim[2] = 1;
282
283 procsPerDim[0] = galeriList.get<GO>("mx");
284 procsPerDim[1] = 1;
285 procsPerDim[2] = 1;
286 } else if (numDimensions == 2) {
287 gNodesPerDim[0] = galeriList.get<GO>("nx");
288 gNodesPerDim[1] = galeriList.get<GO>("ny");
289 gNodesPerDim[2] = 1;
290
291 lNodesPerDim[0] = galeriList.get<LO>("lnx");
292 lNodesPerDim[1] = galeriList.get<LO>("lny");
293 lNodesPerDim[2] = 1;
294
295 procsPerDim[0] = galeriList.get<GO>("mx");
296 procsPerDim[1] = galeriList.get<GO>("my");
297 procsPerDim[2] = 1;
298 } else if (numDimensions == 3) {
299 gNodesPerDim[0] = galeriList.get<GO>("nx");
300 gNodesPerDim[1] = galeriList.get<GO>("ny");
301 gNodesPerDim[2] = galeriList.get<GO>("nz");
302
303 lNodesPerDim[0] = galeriList.get<LO>("lnx");
304 lNodesPerDim[1] = galeriList.get<LO>("lny");
305 lNodesPerDim[2] = galeriList.get<LO>("lnz");
306
307 procsPerDim[0] = galeriList.get<GO>("mx");
308 procsPerDim[1] = galeriList.get<GO>("my");
309 procsPerDim[2] = galeriList.get<GO>("mz");
310 }
311
312 Teuchos::Array<GO> startIndices(3);
313 Teuchos::Array<GO> endIndices(3);
314 const GO startGID = map->getMinGlobalIndex();
315 startIndices[2] = startGID / (gNodesPerDim[1] * gNodesPerDim[0]);
316 const GO rem = startGID % (gNodesPerDim[1] * gNodesPerDim[0]);
317 startIndices[1] = rem / gNodesPerDim[0];
318 startIndices[0] = rem % gNodesPerDim[0];
319 endIndices[0] = startIndices[0] + lNodesPerDim[0] - 1;
320 endIndices[1] = startIndices[1] + lNodesPerDim[1] - 1;
321 endIndices[2] = startIndices[2] + lNodesPerDim[2] - 1;
322
323 int leftBC = 0, rightBC = 0, frontBC = 0, backBC = 0, bottomBC = 0, topBC = 0;
324 if (startIndices[0] == 0) {
325 leftBC = 1;
326 }
327 if (startIndices[1] == 0) {
328 frontBC = 1;
329 }
330 if (startIndices[2] == 0) {
331 bottomBC = 1;
332 }
333
334 if (endIndices[0] == gNodesPerDim[0] - 1) {
335 rightBC = 1;
336 }
337 if (endIndices[1] == gNodesPerDim[1] - 1) {
338 backBC = 1;
339 }
340 if (endIndices[2] == gNodesPerDim[2] - 1) {
341 topBC = 1;
342 }
343
344 std::cout << "p=" << myRank << " | startGID= " << startGID
345 << ", startIndices: " << startIndices
346 << ", endIndices: " << endIndices
347 << ", gNodesPerDim: " << gNodesPerDim
348 << ", BCs={" << leftBC << ", " << rightBC << ", "
349 << frontBC << ", " << backBC << ", "
350 << bottomBC << ", " << topBC << "}" << std::endl;
351
352 // Rule for boundary duplication
353 // For any two ranks that share an interface:
354 // the lowest ranks owns the interface and the highest rank gets extra nodes
355
356 // First we count how many nodes the region needs to send and receive
357 // and allocate arrays accordingly
358 LO numReceive = 0, numSend = 0;
359 Teuchos::Array<GO> receiveGIDs;
360 Teuchos::Array<int> receivePIDs;
361 Teuchos::Array<GO> sendGIDs;
362 Teuchos::Array<int> sendPIDs;
363 if (numDimensions == 1) {
364 if (leftBC == 0) {
365 numReceive = 1;
366 receiveGIDs.resize(numReceive);
367 receivePIDs.resize(numReceive);
368
369 receiveGIDs[0] = startIndices[0] - 1;
370 receivePIDs[0] = myRank - 1;
371 }
372 if (rightBC == 0) {
373 numSend = 1;
374 sendGIDs.resize(numSend);
375 sendPIDs.resize(numSend);
376
377 sendGIDs[0] = endIndices[0];
378 sendGIDs[0] = myRank + 1;
379 }
380 } else if (numDimensions == 2) {
381 // Received nodes
382 if (frontBC == 0 && leftBC == 0) {
383 numReceive = lNodesPerDim[0] + lNodesPerDim[1] + 1;
384 receiveGIDs.resize(numReceive);
385 receivePIDs.resize(numReceive);
386
387 LO countIDs = 0;
388 // Receive front-left corner node
389 receiveGIDs[countIDs] = startGID - gNodesPerDim[0] - 1;
390 receivePIDs[countIDs] = myRank - procsPerDim[0] - 1;
391 ++countIDs;
392 // Receive front edge nodes
393 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
394 receiveGIDs[countIDs] = startGID - gNodesPerDim[0] + i;
395 receivePIDs[countIDs] = myRank - procsPerDim[0];
396 ++countIDs;
397 }
398 // Receive left edge nodes
399 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
400 receiveGIDs[countIDs] = startGID - 1 + j * gNodesPerDim[0];
401 receivePIDs[countIDs] = myRank - 1;
402 ++countIDs;
403 }
404 } else if (frontBC == 0) {
405 numReceive = lNodesPerDim[0];
406 receiveGIDs.resize(numReceive);
407 receivePIDs.resize(numReceive);
408
409 LO countIDs = 0;
410 // Receive front edge nodes
411 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
412 receiveGIDs[countIDs] = startGID - gNodesPerDim[0] + i;
413 receivePIDs[countIDs] = myRank - procsPerDim[0];
414 ++countIDs;
415 }
416 } else if (leftBC == 0) {
417 numReceive = lNodesPerDim[1];
418 receiveGIDs.resize(numReceive);
419 receivePIDs.resize(numReceive);
420
421 LO countIDs = 0;
422 // Receive left edge nodes
423 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
424 receiveGIDs[countIDs] = startGID - 1 + j * gNodesPerDim[0];
425 receivePIDs[countIDs] = myRank - 1;
426 ++countIDs;
427 }
428 }
429
430 // Sent nodes
431 if (rightBC == 0 && backBC == 0) {
432 numSend = lNodesPerDim[0] + lNodesPerDim[1] + 1;
433 sendGIDs.resize(numSend);
434 sendPIDs.resize(numSend);
435
436 LO countIDs = 0;
437 // Send nodes of right edge
438 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
439 sendGIDs[countIDs] = j * gNodesPerDim[0] + startGID + lNodesPerDim[0] - 1;
440 sendPIDs[countIDs] = myRank + 1;
441 ++countIDs;
442 }
443 // Send nodes of back edge
444 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
445 sendGIDs[countIDs] = i + startGID + (lNodesPerDim[1] - 1) * gNodesPerDim[0];
446 sendPIDs[countIDs] = myRank + procsPerDim[0];
447 ++countIDs;
448 }
449 // Send node of back-right corner
450 sendGIDs[countIDs] = startGID + (lNodesPerDim[1] - 1) * gNodesPerDim[0] + lNodesPerDim[0] - 1;
451 sendPIDs[countIDs] = myRank + procsPerDim[1] + 1;
452 ++countIDs;
453 } else if (backBC == 0) {
454 numSend = lNodesPerDim[0];
455
456 sendGIDs.resize(numSend);
457 sendPIDs.resize(numSend);
458
459 LO countIDs = 0;
460 // Send nodes of back edge
461 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
462 sendGIDs[countIDs] = i + startGID + (lNodesPerDim[1] - 1) * gNodesPerDim[0];
463 sendPIDs[countIDs] = myRank + procsPerDim[0];
464 ++countIDs;
465 }
466 } else if (rightBC == 0) {
467 numSend = lNodesPerDim[1];
468 sendGIDs.resize(numSend);
469 sendPIDs.resize(numSend);
470
471 LO countIDs = 0;
472 // Send nodes of right edge
473 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
474 sendGIDs[countIDs] = j * gNodesPerDim[0] + startGID + lNodesPerDim[0] - 1;
475 sendPIDs[countIDs] = myRank + 1;
476 ++countIDs;
477 }
478 }
479 } else if (numDimensions == 3) {
480 // Received nodes
481 if ((bottomBC == 0) && (frontBC == 0) && (leftBC == 0)) {
482 numReceive = lNodesPerDim[0] * lNodesPerDim[1] // bottom face
483 + (lNodesPerDim[0] + 1) * lNodesPerDim[2] // front face
484 + (lNodesPerDim[1] + 1) * (lNodesPerDim[2] + 1); // left face
485 receiveGIDs.resize(numReceive);
486 receivePIDs.resize(numReceive);
487
488 LO countIDs = 0;
489 // Receive front-left-bottom corner node
490 receiveGIDs[countIDs] = startGID - gNodesPerDim[0] - 1 - gNodesPerDim[1] * gNodesPerDim[0];
491 receivePIDs[countIDs] = myRank - procsPerDim[0] - 1 - procsPerDim[1] * procsPerDim[0];
492 ++countIDs;
493 // Receive front-bottom edge nodes
494 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
495 receiveGIDs[countIDs] = startGID - gNodesPerDim[0] * gNodesPerDim[1] - gNodesPerDim[0] + i;
496 receivePIDs[countIDs] = myRank - procsPerDim[0] * procsPerDim[1] - procsPerDim[0];
497 ++countIDs;
498 }
499 // Receive left-bottom edge nodes
500 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
501 receiveGIDs[countIDs] = startGID - gNodesPerDim[0] * gNodesPerDim[1] - 1 + j * gNodesPerDim[0];
502 receivePIDs[countIDs] = myRank - procsPerDim[0] * procsPerDim[1] - 1;
503 ++countIDs;
504 }
505 // Receive bottom face nodes
506 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
507 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
508 receiveGIDs[countIDs] = startGID - gNodesPerDim[0] * gNodesPerDim[1] + i + j * gNodesPerDim[0];
509 receivePIDs[countIDs] = myRank - procsPerDim[0] * procsPerDim[1];
510 ++countIDs;
511 }
512 }
513 // Receive front-left edge nodes
514 for (LO k = 0; k < lNodesPerDim[1]; ++k) {
515 receiveGIDs[countIDs] = startGID - gNodesPerDim[0] - 1 + k * gNodesPerDim[0] * gNodesPerDim[1];
516 receivePIDs[countIDs] = myRank - procsPerDim[0] - 1;
517 ++countIDs;
518 }
519 // Receive front face nodes
520 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
521 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
522 receiveGIDs[countIDs] = startGID - gNodesPerDim[0] + i + k * (gNodesPerDim[1] * gNodesPerDim[0]);
523 receivePIDs[countIDs] = myRank - procsPerDim[0];
524 ++countIDs;
525 }
526 }
527 // Receive left face nodes
528 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
529 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
530 receiveGIDs[countIDs] = startGID - 1 + j * gNodesPerDim[0] + k * (gNodesPerDim[1] * gNodesPerDim[0]);
531 receivePIDs[countIDs] = myRank - 1;
532 ++countIDs;
533 }
534 }
535
536 // Two faces received
537 } else if ((bottomBC == 0) && (frontBC == 0)) {
538 numReceive = lNodesPerDim[0] * lNodesPerDim[1] // bottom face
539 + lNodesPerDim[0] * (lNodesPerDim[2] + 1); // front face;
540 receiveGIDs.resize(numReceive);
541 receivePIDs.resize(numReceive);
542
543 LO countIDs = 0;
544 // Receive front-bottom edge nodes
545 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
546 receiveGIDs[countIDs] = startGID - gNodesPerDim[0] * gNodesPerDim[1] - gNodesPerDim[0] + i;
547 receivePIDs[countIDs] = myRank - procsPerDim[0] * procsPerDim[1] - procsPerDim[0];
548 ++countIDs;
549 }
550 // Receive bottom face nodes
551 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
552 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
553 receiveGIDs[countIDs] = startGID - gNodesPerDim[0] * gNodesPerDim[1] + i + j * gNodesPerDim[0];
554 receivePIDs[countIDs] = myRank - procsPerDim[0] * procsPerDim[1];
555 ++countIDs;
556 }
557 }
558 // Receive front face nodes
559 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
560 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
561 receiveGIDs[countIDs] = startGID - gNodesPerDim[0] + i + k * (gNodesPerDim[1] * gNodesPerDim[0]);
562 receivePIDs[countIDs] = myRank - procsPerDim[0];
563 ++countIDs;
564 }
565 }
566
567 } else if ((bottomBC == 0) && (leftBC == 0)) {
568 numReceive = lNodesPerDim[1] * (lNodesPerDim[0] + lNodesPerDim[2] + 1);
569 receiveGIDs.resize(numReceive);
570 receivePIDs.resize(numReceive);
571
572 LO countIDs = 0;
573 // Receive left-bottom edge nodes
574 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
575 receiveGIDs[countIDs] = j * gNodesPerDim[0] + startGID - gNodesPerDim[1] * gNodesPerDim[0] - 1;
576 receivePIDs[countIDs] = myRank - procsPerDim[1] * procsPerDim[0] - 1;
577 ++countIDs;
578 }
579 // Receive bottom face nodes
580 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
581 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
582 receiveGIDs[countIDs] = j * gNodesPerDim[0] + i + startGID - gNodesPerDim[1] * gNodesPerDim[0];
583 receivePIDs[countIDs] = myRank - procsPerDim[1] * procsPerDim[0];
584 ++countIDs;
585 }
586 }
587 // Receive left face nodes
588 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
589 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
590 receiveGIDs[countIDs] = k * gNodesPerDim[1] * gNodesPerDim[0] + j * gNodesPerDim[0] + startGID - 1;
591 receivePIDs[countIDs] = myRank - 1;
592 ++countIDs;
593 }
594 }
595
596 } else if ((frontBC == 0) && (leftBC == 0)) {
597 numReceive = lNodesPerDim[2] * (lNodesPerDim[1] + lNodesPerDim[0] + 1);
598 receiveGIDs.resize(numReceive);
599 receivePIDs.resize(numReceive);
600
601 LO countIDs = 0;
602 // Receive front-left edge nodes
603 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
604 receiveGIDs[countIDs] = k * gNodesPerDim[1] * gNodesPerDim[0] + startGID - gNodesPerDim[0] - 1;
605 receivePIDs[countIDs] = myRank - procsPerDim[0] - 1;
606 ++countIDs;
607 }
608 // Receive front face nodes
609 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
610 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
611 receiveGIDs[countIDs] = k * gNodesPerDim[1] * gNodesPerDim[0] + i + startGID - gNodesPerDim[0];
612 receivePIDs[countIDs] = myRank - procsPerDim[0];
613 ++countIDs;
614 }
615 }
616 // Receive left face nodes
617 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
618 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
619 receiveGIDs[countIDs] = k * gNodesPerDim[1] * gNodesPerDim[0] + j * gNodesPerDim[0] + startGID - 1;
620 receivePIDs[countIDs] = myRank - 1;
621 ++countIDs;
622 }
623 }
624
625 // Single face received
626 } else if (bottomBC == 0) {
627 numReceive = lNodesPerDim[0] * lNodesPerDim[1];
628 receiveGIDs.resize(numReceive);
629 receivePIDs.resize(numReceive);
630
631 LO countIDs = 0;
632 // Receive bottom face nodes
633 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
634 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
635 receiveGIDs[countIDs] = j * gNodesPerDim[0] + i + startGID - gNodesPerDim[1] * gNodesPerDim[0];
636 receivePIDs[countIDs] = myRank - procsPerDim[1] * procsPerDim[0];
637 ++countIDs;
638 }
639 }
640
641 } else if (frontBC == 0) {
642 numReceive = lNodesPerDim[0] * lNodesPerDim[2];
643 receiveGIDs.resize(numReceive);
644 receivePIDs.resize(numReceive);
645
646 LO countIDs = 0;
647 // Receive front face nodes
648 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
649 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
650 receiveGIDs[countIDs] = k * gNodesPerDim[1] * gNodesPerDim[0] + i + startGID - gNodesPerDim[0];
651 receivePIDs[countIDs] = myRank - procsPerDim[0];
652 ++countIDs;
653 }
654 }
655
656 } else if (leftBC == 0) {
657 numReceive = lNodesPerDim[1] * lNodesPerDim[2];
658 receiveGIDs.resize(numReceive);
659 receivePIDs.resize(numReceive);
660
661 LO countIDs = 0;
662 // Recive left face nodes
663 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
664 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
665 receiveGIDs[countIDs] = k * gNodesPerDim[1] * gNodesPerDim[0] + j * gNodesPerDim[0] + startGID - 1;
666 receivePIDs[countIDs] = myRank - 1;
667 ++countIDs;
668 }
669 }
670 }
671
672 // Sent nodes
673 if ((topBC == 0) && (backBC == 0) && (rightBC == 0)) {
674 numSend = (lNodesPerDim[0]) * (lNodesPerDim[1]) + (lNodesPerDim[0]) * (lNodesPerDim[2]) + (lNodesPerDim[1]) * (lNodesPerDim[2]) + lNodesPerDim[0] + lNodesPerDim[1] + lNodesPerDim[2] + 1;
675 sendGIDs.resize(numSend);
676 sendPIDs.resize(numSend);
677
678 LO countIDs = 0;
679 // Send nodes of right face
680 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
681 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
682 sendGIDs[countIDs] = k * (gNodesPerDim[1] * gNodesPerDim[0]) + j * gNodesPerDim[0] + startGID + lNodesPerDim[0] - 1;
683 sendPIDs[countIDs] = myRank + 1;
684 ++countIDs;
685 }
686 }
687 // Send nodes of back face
688 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
689 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
690 sendGIDs[countIDs] = k * (gNodesPerDim[1] * gNodesPerDim[0]) + i + startGID + (lNodesPerDim[1] - 1) * gNodesPerDim[0];
691 sendPIDs[countIDs] = myRank + procsPerDim[0];
692 ++countIDs;
693 }
694 }
695 // Send nodes of right-back edge
696 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
697 sendGIDs[countIDs] = k * (gNodesPerDim[1] * gNodesPerDim[0]) + startGID + (lNodesPerDim[1] - 1) * gNodesPerDim[0] + lNodesPerDim[0] - 1;
698 sendPIDs[countIDs] = myRank + procsPerDim[0] + 1;
699 ++countIDs;
700 }
701 // Send nodes of top face
702 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
703 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
704 sendGIDs[countIDs] = j * gNodesPerDim[0] + i + startGID + (lNodesPerDim[2] - 1) * gNodesPerDim[1] * gNodesPerDim[0];
705 sendPIDs[countIDs] = myRank + procsPerDim[1] * procsPerDim[0];
706 ++countIDs;
707 }
708 }
709 // Send nodes of top-right edge
710 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
711 sendGIDs[countIDs] = j * gNodesPerDim[0] + startGID + (lNodesPerDim[2] - 1) * gNodesPerDim[1] * gNodesPerDim[0] + lNodesPerDim[0] - 1;
712 sendPIDs[countIDs] = myRank + procsPerDim[1] * procsPerDim[0] + 1;
713 ++countIDs;
714 }
715 // Send nodes of top-back edge
716 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
717 sendGIDs[countIDs] = i + startGID + (lNodesPerDim[2] - 1) * gNodesPerDim[1] * gNodesPerDim[0] + (lNodesPerDim[0] - 1) * gNodesPerDim[0];
718 sendPIDs[countIDs] = myRank + procsPerDim[1] * procsPerDim[0] + procsPerDim[1];
719 ++countIDs;
720 }
721 // Send node of top-back-right corner
722 sendGIDs[countIDs] = startGID + (lNodesPerDim[2] - 1) * gNodesPerDim[1] * gNodesPerDim[0] + (lNodesPerDim[0] - 1) * gNodesPerDim[0] + lNodesPerDim[0] - 1;
723 sendPIDs[countIDs] = myRank + procsPerDim[1] * procsPerDim[0] + procsPerDim[1] + 1;
724 ++countIDs;
725
726 } else if ((topBC == 0) && (backBC == 0)) {
727 numSend = (lNodesPerDim[0] * lNodesPerDim[2]) // back face
728 + (lNodesPerDim[0] * lNodesPerDim[1]) // Top face
729 + (lNodesPerDim[0]); // top-back edge
730 sendGIDs.resize(numSend);
731 sendPIDs.resize(numSend);
732
733 LO countIDs = 0;
734 // Send nodes of back face
735 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
736 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
737 sendGIDs[countIDs] = k * (gNodesPerDim[1] * gNodesPerDim[0]) + i + startGID + (lNodesPerDim[1] - 1) * gNodesPerDim[0];
738 sendPIDs[countIDs] = myRank + procsPerDim[0];
739 ++countIDs;
740 }
741 }
742 // Send nodes of top face
743 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
744 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
745 sendGIDs[countIDs] = j * gNodesPerDim[0] + i + startGID + (lNodesPerDim[2] - 1) * gNodesPerDim[1] * gNodesPerDim[0];
746 sendPIDs[countIDs] = myRank + procsPerDim[1] * procsPerDim[0];
747 ++countIDs;
748 }
749 }
750 // Send nodes of top-back edge
751 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
752 sendGIDs[countIDs] = i + startGID + (lNodesPerDim[2] - 1) * gNodesPerDim[1] * gNodesPerDim[0] + (lNodesPerDim[0] - 1) * gNodesPerDim[0];
753 sendPIDs[countIDs] = myRank + procsPerDim[1] * procsPerDim[0] + procsPerDim[1];
754 ++countIDs;
755 }
756
757 } else if ((topBC == 0) && (rightBC == 0)) {
758 numSend = (lNodesPerDim[1] * lNodesPerDim[2]) // right face
759 + (lNodesPerDim[0] * lNodesPerDim[1]) // Top face
760 + (lNodesPerDim[1]); // top-right edge
761 sendGIDs.resize(numSend);
762 sendPIDs.resize(numSend);
763
764 LO countIDs = 0;
765 // Send nodes of right face
766 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
767 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
768 sendGIDs[countIDs] = k * (gNodesPerDim[1] * gNodesPerDim[0]) + j * gNodesPerDim[0] + startGID + lNodesPerDim[0] - 1;
769 sendPIDs[countIDs] = myRank + 1;
770 ++countIDs;
771 }
772 }
773 // Send nodes of top face
774 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
775 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
776 sendGIDs[countIDs] = j * gNodesPerDim[0] + i + startGID + (lNodesPerDim[2] - 1) * gNodesPerDim[1] * gNodesPerDim[0];
777 sendPIDs[countIDs] = myRank + procsPerDim[1] * procsPerDim[0];
778 ++countIDs;
779 }
780 }
781 // Send nodes of top-right edge
782 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
783 sendGIDs[countIDs] = j * gNodesPerDim[0] + startGID + (lNodesPerDim[2] - 1) * gNodesPerDim[1] * gNodesPerDim[0] + lNodesPerDim[0] - 1;
784 sendPIDs[countIDs] = myRank + procsPerDim[1] * procsPerDim[0] + 1;
785 ++countIDs;
786 }
787
788 } else if ((backBC == 0) && (rightBC == 0)) {
789 numSend = lNodesPerDim[2] * (lNodesPerDim[0] + lNodesPerDim[1] + 1);
790 sendGIDs.resize(numSend);
791 sendPIDs.resize(numSend);
792
793 LO countIDs = 0;
794 // Send nodes of right face
795 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
796 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
797 sendGIDs[countIDs] = k * gNodesPerDim[1] * gNodesPerDim[0] + j * gNodesPerDim[0] + startGID + lNodesPerDim[0] - 1;
798 sendPIDs[countIDs] = myRank + 1;
799 ++countIDs;
800 }
801 }
802 // Send nodes of back face
803 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
804 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
805 sendGIDs[countIDs] = k * gNodesPerDim[1] * gNodesPerDim[0] + i + startGID + (lNodesPerDim[1] - 1) * gNodesPerDim[0];
806 sendPIDs[countIDs] = myRank + procsPerDim[0];
807 ++countIDs;
808 }
809 }
810 // Send nodes of back-right edge
811 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
812 sendGIDs[countIDs] = k * gNodesPerDim[1] * gNodesPerDim[0] + startGID + (lNodesPerDim[1] - 1) * gNodesPerDim[0] + lNodesPerDim[0] - 1;
813 sendPIDs[countIDs] = myRank + procsPerDim[0] + 1;
814 ++countIDs;
815 }
816
817 } else if (topBC == 0) {
818 numSend = lNodesPerDim[0] * lNodesPerDim[1];
819 sendGIDs.resize(numSend);
820 sendPIDs.resize(numSend);
821
822 LO countIDs = 0;
823 // Send nodes of top face
824 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
825 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
826 sendGIDs[countIDs] = j * gNodesPerDim[0] + i + startGID + (lNodesPerDim[2] - 1) * gNodesPerDim[0] * gNodesPerDim[0];
827 sendPIDs[countIDs] = myRank + procsPerDim[1] * procsPerDim[0];
828 ++countIDs;
829 }
830 }
831
832 } else if (backBC == 0) {
833 numSend = lNodesPerDim[0] * lNodesPerDim[2];
834 sendGIDs.resize(numSend);
835 sendPIDs.resize(numSend);
836
837 LO countIDs = 0;
838 // Send nodes of back face
839 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
840 for (LO i = 0; i < lNodesPerDim[0]; ++i) {
841 sendGIDs[countIDs] = k * gNodesPerDim[1] * gNodesPerDim[0] + i + startGID + (lNodesPerDim[1] - 1) * gNodesPerDim[0];
842 sendPIDs[countIDs] = myRank + procsPerDim[0];
843 ++countIDs;
844 }
845 }
846
847 } else if (rightBC == 0) {
848 numSend = lNodesPerDim[1] * lNodesPerDim[2];
849 sendGIDs.resize(numSend);
850 sendPIDs.resize(numSend);
851
852 LO countIDs = 0;
853 // Send nodes of right face
854 for (LO k = 0; k < lNodesPerDim[2]; ++k) {
855 for (LO j = 0; j < lNodesPerDim[1]; ++j) {
856 sendGIDs[countIDs] = k * gNodesPerDim[1] * gNodesPerDim[0] + j * gNodesPerDim[0] + startGID + lNodesPerDim[0] - 1;
857 sendPIDs[countIDs] = myRank + 1;
858 ++countIDs;
859 }
860 }
861 }
862 }
863
864 // Second we actually fill the send and receive arrays with appropriate data
865 // which will allow us to compute the region and composite maps.
866
867 std::cout << "p=" << myRank << " | numReceive=" << numReceive
868 << ", numSend=" << numSend << std::endl;
869 std::cout << "p=" << myRank << " | receiveGIDs: " << receiveGIDs << std::endl;
870 std::cout << "p=" << myRank << " | receivePIDs: " << receivePIDs << std::endl;
871 std::cout << "p=" << myRank << " | sendGIDs: " << sendGIDs << std::endl;
872 std::cout << "p=" << myRank << " | sendPIDs: " << sendPIDs << std::endl;
873
874 comm->barrier();
875 tm = Teuchos::null;
876
877 // #ifdef HAVE_MUELU_CUDA
878 // if(profileSetup) cudaProfilerStart();
879 // #endif
880
881 // tm = rcp(new TimeMonitor(*TimeMonitor::getNewTimer("Driver: 2 - MueLu Setup")));
882 // RCP<Hierarchy> H;
883 // RCP<Operator> Prec;
884 // A->SetMaxEigenvalueEstimate(-Teuchos::ScalarTraits<SC>::one());
885
886 // const std::string userName = "user data";
887 // Teuchos::ParameterList& userParamList = paramList.sublist(userName);
888 // userParamList.set<int>("int numDimensions", numDimensions);
889 // userParamList.set<Teuchos::Array<LO> >("Array<LO> lNodesPerDim", lNodesPerDim);
890 // userParamList.set<RCP<RealValuedMultiVector> >("Coordinates", coordinates);
891 // H = MueLu::CreateXpetraPreconditioner(A, paramList, paramList);
892
893 // comm->barrier();
894 // tm = Teuchos::null;
895
896 // #ifdef HAVE_MUELU_CUDA
897 // if(profileSolve) cudaProfilerStop();
898 // #endif
899
900 // tm = rcp(new TimeMonitor(*TimeMonitor::getNewTimer("Driver: 3 - LHS and RHS initialization")));
901 // X->putScalar(zero);
902 // tm = Teuchos::null;
903
904 // #ifdef HAVE_MUELU_BELOS
905 // tm = rcp(new TimeMonitor(*TimeMonitor::getNewTimer("Driver: 5 - Belos Solve")));
906 // #ifdef HAVE_MUELU_CUDA
907 // if(profileSolve) cudaProfilerStart();
908 // #endif
909 // // Operator and Multivector type that will be used with Belos
910 // typedef MultiVector MV;
911 // typedef Belos::OperatorT<MV> OP;
912
913 // // Define Operator and Preconditioner
914 // Teuchos::RCP<OP> belosOp = Teuchos::rcp(new Belos::XpetraOp<SC, LO, GO, NO>(A)); // Turns a Xpetra::Matrix object into a Belos operator
915 // Teuchos::RCP<OP> belosPrec; // Turns a MueLu::Hierarchy object into a Belos operator
916 // H->IsPreconditioner(true);
917 // belosPrec = Teuchos::rcp(new Belos::MueLuOp <SC, LO, GO, NO>(H)); // Turns a MueLu::Hierarchy object into a Belos operator
918
919 // // Construct a Belos LinearProblem object
920 // RCP<Belos::LinearProblem<SC, MV, OP> > belosProblem = rcp(new Belos::LinearProblem<SC, MV, OP>(belosOp, X, B));
921 // if(solvePreconditioned) belosProblem->setRightPrec(belosPrec);
922
923 // bool set = belosProblem->setProblem();
924 // if (set == false) {
925 // out << "\nERROR: Belos::LinearProblem failed to set up correctly!" << std::endl;
926 // return EXIT_FAILURE;
927 // }
928
929 // // Belos parameter list
930 // Teuchos::ParameterList belosList;
931 // belosList.set("Maximum Iterations", maxIts); // Maximum number of iterations allowed
932 // belosList.set("Convergence Tolerance", tol); // Relative convergence tolerance requested
933 // belosList.set("Verbosity", Belos::Errors + Belos::Warnings + Belos::StatusTestDetails);
934 // belosList.set("Output Frequency", 1);
935 // belosList.set("Output Style", Belos::Brief);
936 // if (!scaleResidualHist)
937 // belosList.set("Implicit Residual Scaling", "None");
938
939 // // Create an iterative solver manager
940 // RCP< Belos::SolverManager<SC, MV, OP> > solver;
941 // solver = rcp(new Belos::BlockGmresSolMgr<SC, MV, OP>(belosProblem, rcp(&belosList, false)));
942
943 // // Perform solve
944 // Belos::ReturnType retStatus = Belos::Unconverged;
945 // retStatus = solver->solve();
946
947 // // Get the number of iterations for this solve.
948 // out << "Number of iterations performed for this solve: " << solver->getNumIters() << std::endl;
949 // // Check convergence
950 // if (retStatus != Belos::Converged)
951 // out << std::endl << "ERROR: Belos did not converge! " << std::endl;
952 // else
953 // out << std::endl << "SUCCESS: Belos converged!" << std::endl;
954 // #ifdef HAVE_MUELU_CUDA
955 // if(profileSolve) cudaProfilerStop();
956 // #endif
957 // #endif //ifdef HAVE_MUELU_BELOS
958
959 comm->barrier();
960 tm = Teuchos::null;
961 globalTimeMonitor = Teuchos::null;
962
963 RCP<ParameterList> reportParams = rcp(new ParameterList);
964 const std::string filter = "";
965 std::ios_base::fmtflags ff(out.flags());
966 TimeMonitor::report(comm.ptr(), out, filter, reportParams);
967 out << std::setiosflags(ff);
968
969 TimeMonitor::clearCounters();
970
971 return EXIT_SUCCESS;
972 }
973
974 //- -- --------------------------------------------------------
975 #define MUELU_AUTOMATIC_TEST_ETI_NAME main_
976 #include "MueLu_Test_ETI.hpp"
977
978 int main(int argc, char *argv[]) {
979 return Automatic_Test_ETI(argc, argv);
980 }