MueLu Version of the Day
Loading...
Searching...
No Matches
MueLu_LineDetectionFactory_def.hpp
Go to the documentation of this file.
1// @HEADER
2//
3// ***********************************************************************
4//
5// MueLu: A package for multigrid based preconditioning
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
39// Jonathan Hu (jhu@sandia.gov)
40// Andrey Prokopenko (aprokop@sandia.gov)
41// Ray Tuminaro (rstumin@sandia.gov)
42//
43// ***********************************************************************
44//
45// @HEADER
46#ifndef MUELU_LINEDETECTIONFACTORY_DEF_HPP
47#define MUELU_LINEDETECTIONFACTORY_DEF_HPP
48
49#include <Xpetra_Matrix.hpp>
50//#include <Xpetra_MatrixFactory.hpp>
51
53
54#include "MueLu_Level.hpp"
55#include "MueLu_MasterList.hpp"
56#include "MueLu_Monitor.hpp"
57
58namespace MueLu {
59
60 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
62 RCP<ParameterList> validParamList = rcp(new ParameterList());
63
64#define SET_VALID_ENTRY(name) validParamList->setEntry(name, MasterList::getEntry(name))
65 SET_VALID_ENTRY("linedetection: orientation");
66 SET_VALID_ENTRY("linedetection: num layers");
67#undef SET_VALID_ENTRY
68
69 validParamList->set< RCP<const FactoryBase> >("A", Teuchos::null, "Generating factory of the matrix A");
70 validParamList->set< RCP<const FactoryBase> >("Coordinates", Teuchos::null, "Generating factory for coorindates");
71
72 return validParamList;
73 }
74
75 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
77 Input(currentLevel, "A");
78
79 // The factory needs the information about the number of z-layers. While this information is
80 // provided by the user for the finest level, the factory itself is responsible to provide the
81 // corresponding information on the coarser levels. Since a factory cannot be dependent on itself
82 // we use the NoFactory class as generator class, but remove the UserData keep flag, such that
83 // "NumZLayers" is part of the request/release mechanism.
84 // Please note, that this prevents us from having several (independent) CoarsePFactory instances!
85 // TODO: allow factory to dependent on self-generated data for TwoLevelFactories -> introduce ExpertRequest/Release in Level
86 currentLevel.DeclareInput("NumZLayers", NoFactory::get(), this);
87 currentLevel.RemoveKeepFlag("NumZLayers", NoFactory::get(), MueLu::UserData);
88 }
89
90 template <class Scalar, class LocalOrdinal, class GlobalOrdinal, class Node>
92 FactoryMonitor m(*this, "Line detection (Ray style)", currentLevel);
93
94 LO NumZDir = 0;
95 RCP<CoordinateMultiVector> fineCoords;
96 ArrayRCP<coordinate_type> x, y, z;
97 coordinate_type *xptr = NULL, *yptr = NULL, *zptr = NULL;
98
99 // obtain general variables
100 RCP<Matrix> A = Get< RCP<Matrix> > (currentLevel, "A");
101 LO BlkSize = A->GetFixedBlockSize();
102 RCP<const Map> rowMap = A->getRowMap();
103 LO Ndofs = rowMap->getLocalNumElements();
104 LO Nnodes = Ndofs/BlkSize;
105
106 // collect information provided by user
107 const ParameterList& pL = GetParameterList();
108 const std::string lineOrientation = pL.get<std::string>("linedetection: orientation");
109
110 // interpret "line orientation" parameter provided by the user on the finest level
111 if(currentLevel.GetLevelID() == 0) {
112 if(lineOrientation=="vertical")
113 Zorientation_ = VERTICAL;
114 else if (lineOrientation=="horizontal")
115 Zorientation_ = HORIZONTAL;
116 else if (lineOrientation=="coordinates")
117 Zorientation_ = GRID_SUPPLIED;
118 else
119 TEUCHOS_TEST_FOR_EXCEPTION(false, Exceptions::RuntimeError, "LineDetectionFactory: The parameter 'semicoarsen: line orientation' must be either 'vertical', 'horizontal' or 'coordinates'.");
120 }
121
122 //TEUCHOS_TEST_FOR_EXCEPTION(Zorientation_!=VERTICAL, Exceptions::RuntimeError, "LineDetectionFactory: The 'horizontal' or 'coordinates' have not been tested!!!. Please remove this exception check and carefully test these modes!");
123
124 // obtain number of z layers (variable over levels)
125 // This information is user-provided on the finest level and transferred to the coarser
126 // levels by the SemiCoarsenPFactor using the internal "NumZLayers" variable.
127 if(currentLevel.GetLevelID() == 0) {
128 if(currentLevel.IsAvailable("NumZLayers", NoFactory::get())) {
129 NumZDir = currentLevel.Get<LO>("NumZLayers", NoFactory::get()); //obtain info
130 GetOStream(Runtime1) << "Number of layers for line detection: " << NumZDir << " (information from Level(0))" << std::endl;
131 } else {
132 // check whether user provides information or it can be reconstructed from coordinates
133 NumZDir = pL.get<LO>("linedetection: num layers");
134 if(NumZDir == -1) {
135 bool CoordsAvail = currentLevel.IsAvailable("Coordinates");
136
137 if (CoordsAvail == true) {
138 // try to reconstruct the number of layers from coordinates
139 fineCoords = Get< RCP<CoordinateMultiVector> > (currentLevel, "Coordinates");
140 TEUCHOS_TEST_FOR_EXCEPTION(fineCoords->getNumVectors() != 3, Exceptions::RuntimeError, "Three coordinates arrays must be supplied if line detection orientation not given.");
141 x = fineCoords->getDataNonConst(0);
142 y = fineCoords->getDataNonConst(1);
143 z = fineCoords->getDataNonConst(2);
144 xptr = x.getRawPtr();
145 yptr = y.getRawPtr();
146 zptr = z.getRawPtr();
147
148 LO NumCoords = Ndofs/BlkSize;
149
150 /* sort coordinates so that we can order things according to lines */
151 Teuchos::ArrayRCP<LO> TOrigLoc= Teuchos::arcp<LO>(NumCoords); LO* OrigLoc= TOrigLoc.getRawPtr();
152 Teuchos::ArrayRCP<coordinate_type> Txtemp = Teuchos::arcp<coordinate_type>(NumCoords); coordinate_type* xtemp = Txtemp.getRawPtr();
153 Teuchos::ArrayRCP<coordinate_type> Tytemp = Teuchos::arcp<coordinate_type>(NumCoords); coordinate_type* ytemp = Tytemp.getRawPtr();
154 Teuchos::ArrayRCP<coordinate_type> Tztemp = Teuchos::arcp<coordinate_type>(NumCoords); coordinate_type* ztemp = Tztemp.getRawPtr();
155
156 // sort coordinates in {x,y,z}vals (returned in {x,y,z}temp) so that we can order things according to lines
157 // switch x and y coordinates for semi-coarsening...
158 sort_coordinates(NumCoords, OrigLoc, xptr, yptr, zptr, xtemp, ytemp, ztemp, true);
159
160 /* go through each vertical line and populate blockIndices so all */
161 /* dofs within a PDE within a vertical line correspond to one block.*/
162 LO NumBlocks = 0;
163 LO NumNodesPerVertLine = 0;
164 LO index = 0;
165
166 while ( index < NumCoords ) {
167 coordinate_type xfirst = xtemp[index]; coordinate_type yfirst = ytemp[index];
168 LO next = index+1;
169 while ( (next != NumCoords) && (xtemp[next] == xfirst) &&
170 (ytemp[next] == yfirst))
171 next++;
172 if (NumBlocks == 0) {
173 NumNodesPerVertLine = next-index;
174 }
175 // the number of vertical lines must be the same on all processors
176 // TAW: Sep 14 2015: or zero as we allow "empty" processors
177 //TEUCHOS_TEST_FOR_EXCEPTION(next-index != NumNodesPerVertLine,Exceptions::RuntimeError, "Error code only works for constant block size now!!!\n");
178 NumBlocks++;
179 index = next;
180 }
181
182 NumZDir = NumNodesPerVertLine;
183 GetOStream(Runtime1) << "Number of layers for line detection: " << NumZDir << " (information reconstructed from provided node coordinates)" << std::endl;
184 } else {
185 TEUCHOS_TEST_FOR_EXCEPTION(false, Exceptions::RuntimeError, "LineDetectionFactory: BuildP: User has to provide valid number of layers (e.g. using the 'line detection: num layers' parameter).");
186 }
187 } else {
188 GetOStream(Runtime1) << "Number of layers for line detection: " << NumZDir << " (information provided by user through 'line detection: num layers')" << std::endl;
189 }
190 } // end else (user provides information or can be reconstructed) on finest level
191 } else {
192 // coarse level information
193 // TODO get rid of NoFactory here and use SemiCoarsenPFactory as source of NumZLayers instead.
194 if(currentLevel.IsAvailable("NumZLayers", NoFactory::get())) {
195 NumZDir = currentLevel.Get<LO>("NumZLayers", NoFactory::get()); //obtain info
196 GetOStream(Runtime1) << "Number of layers for line detection: " << NumZDir << std::endl;
197 } else {
198 TEUCHOS_TEST_FOR_EXCEPTION(false, Exceptions::RuntimeError, "LineDetectionFactory: BuildP: No NumZLayers variable found. This cannot be.");
199 }
200 }
201
202 // plausibility check and further variable collection
203 if (Zorientation_ == GRID_SUPPLIED) { // On finest level, fetch user-provided coordinates if available...
204 bool CoordsAvail = currentLevel.IsAvailable("Coordinates");
205
206 if (CoordsAvail == false) {
207 if (currentLevel.GetLevelID() == 0)
208 throw Exceptions::RuntimeError("Coordinates must be supplied if line detection orientation not given.");
209 else
210 throw Exceptions::RuntimeError("Coordinates not generated by previous invocation of LineDetectionFactory's BuildP() method.");
211 }
212 fineCoords = Get< RCP<CoordinateMultiVector> > (currentLevel, "Coordinates");
213 TEUCHOS_TEST_FOR_EXCEPTION(fineCoords->getNumVectors() != 3, Exceptions::RuntimeError, "Three coordinates arrays must be supplied if line detection orientation not given.");
214 x = fineCoords->getDataNonConst(0);
215 y = fineCoords->getDataNonConst(1);
216 z = fineCoords->getDataNonConst(2);
217 xptr = x.getRawPtr();
218 yptr = y.getRawPtr();
219 zptr = z.getRawPtr();
220 }
221
222 // perform line detection
223 if (NumZDir > 0) {
224 LO *LayerId, *VertLineId;
225 Teuchos::ArrayRCP<LO> TLayerId = Teuchos::arcp<LO>(Nnodes); LayerId = TLayerId.getRawPtr();
226 Teuchos::ArrayRCP<LO> TVertLineId= Teuchos::arcp<LO>(Nnodes); VertLineId = TVertLineId.getRawPtr();
227
228 NumZDir = ML_compute_line_info(LayerId, VertLineId, Ndofs, BlkSize,
229 Zorientation_, NumZDir,xptr,yptr,zptr, *(rowMap->getComm()));
230 //it is NumZDir=NCLayers*NVertLines*DofsPerNode;
231
232 // store output data on current level
233 // The line detection data is used by the SemiCoarsenPFactory and the line smoothers in Ifpack/Ifpack2
234 Set(currentLevel, "CoarseNumZLayers", NumZDir);
235 Set(currentLevel, "LineDetection_Layers", TLayerId);
236 Set(currentLevel, "LineDetection_VertLineIds", TVertLineId);
237 } else {
238 Teuchos::ArrayRCP<LO> TLayerId = Teuchos::arcp<LO>(0);
239 Teuchos::ArrayRCP<LO> TVertLineId = Teuchos::arcp<LO>(0);
240 Teuchos::ArrayRCP<LO> TVertLineIdSmoo= Teuchos::arcp<LO>(0);
241
242 // store output data on current level
243 // The line detection data is used by the SemiCoarsenPFactory and the line smoothers in Ifpack/Ifpack2
244 Set(currentLevel, "CoarseNumZLayers", NumZDir);
245 Set(currentLevel, "LineDetection_Layers", TLayerId);
246 Set(currentLevel, "LineDetection_VertLineIds", TVertLineId);
247 }
248
249 // automatically switch to vertical mode on the coarser levels
250 if(Zorientation_ != VERTICAL)
251 Zorientation_ = VERTICAL;
252 }
253
254 template <class Scalar,class LocalOrdinal, class GlobalOrdinal, class Node>
255 LocalOrdinal LineDetectionFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::ML_compute_line_info(LocalOrdinal LayerId[], LocalOrdinal VertLineId[], LocalOrdinal Ndof, LocalOrdinal DofsPerNode, LocalOrdinal MeshNumbering, LocalOrdinal NumNodesPerVertLine, typename Teuchos::ScalarTraits<Scalar>::coordinateType *xvals, typename Teuchos::ScalarTraits<Scalar>::coordinateType *yvals, typename Teuchos::ScalarTraits<Scalar>::coordinateType *zvals, const Teuchos::Comm<int>& /* comm */) const {
256
257 LO Nnodes, NVertLines, MyNode;
258 LO NumCoords, next; //, subindex, subnext;
259 coordinate_type xfirst, yfirst;
260 coordinate_type *xtemp, *ytemp, *ztemp;
261 LO *OrigLoc;
262 LO i,j,count;
263 LO RetVal;
264
265 RetVal = 0;
266 if ((MeshNumbering != VERTICAL) && (MeshNumbering != HORIZONTAL)) {
267 if ( (xvals == NULL) || (yvals == NULL) || (zvals == NULL)) RetVal = -1;
268 }
269 else {
270 if (NumNodesPerVertLine == -1) RetVal = -4;
271 if ( ((Ndof/DofsPerNode)%NumNodesPerVertLine) != 0) RetVal = -3;
272 }
273 if ( (Ndof%DofsPerNode) != 0) RetVal = -2;
274
275 TEUCHOS_TEST_FOR_EXCEPTION(RetVal == -1, Exceptions::RuntimeError, "Not semicoarsening as no mesh numbering information or coordinates are given\n");
276 TEUCHOS_TEST_FOR_EXCEPTION(RetVal == -4, Exceptions::RuntimeError, "Not semicoarsening as the number of z nodes is not given.\n");
277 TEUCHOS_TEST_FOR_EXCEPTION(RetVal == -3, Exceptions::RuntimeError, "Not semicoarsening as the total number of nodes is not evenly divisible by the number of z direction nodes .\n");
278 TEUCHOS_TEST_FOR_EXCEPTION(RetVal == -2, Exceptions::RuntimeError, "Not semicoarsening as something is off with the number of degrees-of-freedom per node.\n");
279
280 Nnodes = Ndof/DofsPerNode;
281 for (MyNode = 0; MyNode < Nnodes; MyNode++) VertLineId[MyNode] = -1;
282 for (MyNode = 0; MyNode < Nnodes; MyNode++) LayerId[MyNode] = -1;
283
284 if (MeshNumbering == VERTICAL) {
285 for (MyNode = 0; MyNode < Nnodes; MyNode++) {
286 LayerId[MyNode]= MyNode%NumNodesPerVertLine;
287 VertLineId[MyNode]= (MyNode- LayerId[MyNode])/NumNodesPerVertLine;
288 }
289 }
290 else if (MeshNumbering == HORIZONTAL) {
291 NVertLines = Nnodes/NumNodesPerVertLine;
292 for (MyNode = 0; MyNode < Nnodes; MyNode++) {
293 VertLineId[MyNode] = MyNode%NVertLines;
294 LayerId[MyNode] = (MyNode- VertLineId[MyNode])/NVertLines;
295 }
296 }
297 else {
298 // coordinates mode: we distinguish between vertical line numbering for semi-coarsening and line smoothing
299 NumCoords = Ndof/DofsPerNode;
300
301 // reserve temporary memory
302 Teuchos::ArrayRCP<LO> TOrigLoc= Teuchos::arcp<LO>(NumCoords); OrigLoc= TOrigLoc.getRawPtr();
303 Teuchos::ArrayRCP<coordinate_type> Txtemp = Teuchos::arcp<coordinate_type>(NumCoords); xtemp = Txtemp.getRawPtr();
304 Teuchos::ArrayRCP<coordinate_type> Tytemp = Teuchos::arcp<coordinate_type>(NumCoords); ytemp = Tytemp.getRawPtr();
305 Teuchos::ArrayRCP<coordinate_type> Tztemp = Teuchos::arcp<coordinate_type>(NumCoords); ztemp = Tztemp.getRawPtr();
306
307 // build vertical line info for semi-coarsening
308
309 // sort coordinates in {x,y,z}vals (returned in {x,y,z}temp) so that we can order things according to lines
310 // switch x and y coordinates for semi-coarsening...
311 sort_coordinates(NumCoords, OrigLoc, xvals, yvals, zvals, xtemp, ytemp, ztemp, /*true*/ true);
312
313 LO NumBlocks = 0;
314 LO index = 0;
315
316 while ( index < NumCoords ) {
317 xfirst = xtemp[index]; yfirst = ytemp[index];
318 next = index+1;
319 while ( (next != NumCoords) && (xtemp[next] == xfirst) &&
320 (ytemp[next] == yfirst))
321 next++;
322 if (NumBlocks == 0) {
323 NumNodesPerVertLine = next-index;
324 }
325 // The number of vertical lines must be the same on all processors
326 // TAW: Sep 14, 2015: or zero as we allow for empty processors.
327 //TEUCHOS_TEST_FOR_EXCEPTION(next-index != NumNodesPerVertLine,Exceptions::RuntimeError, "Error code only works for constant block size now!!!\n");
328 count = 0;
329 for (j= index; j < next; j++) {
330 VertLineId[OrigLoc[j]] = NumBlocks;
331 LayerId[OrigLoc[j]] = count++;
332 }
333 NumBlocks++;
334 index = next;
335 }
336 }
337
338 /* check that everyone was assigned */
339
340 for (i = 0; i < Nnodes; i++) {
341 if (VertLineId[i] == -1) {
342 GetOStream(Warnings1) << "Warning: did not assign " << i << " to a vertical line?????\n" << std::endl;
343 }
344 if (LayerId[i] == -1) {
345 GetOStream(Warnings1) << "Warning: did not assign " << i << " to a Layer?????\n" << std::endl;
346 }
347 }
348
349 // TAW: Sep 14 2015: relax plausibility checks as we allow for empty processors
350 //MueLu_maxAll(&comm, NumNodesPerVertLine, i);
351 //if (NumNodesPerVertLine == -1) NumNodesPerVertLine = i;
352 //TEUCHOS_TEST_FOR_EXCEPTION(NumNodesPerVertLine != i,Exceptions::RuntimeError, "Different processors have different z direction line lengths?\n");
353
354 return NumNodesPerVertLine;
355 }
356
357 /* Private member function to sort coordinates in arrays. This is an expert routine. Do not use or change.*/
358 template <class Scalar,class LocalOrdinal, class GlobalOrdinal, class Node>
360 typename Teuchos::ScalarTraits<Scalar>::coordinateType* xvals,
361 typename Teuchos::ScalarTraits<Scalar>::coordinateType* yvals,
362 typename Teuchos::ScalarTraits<Scalar>::coordinateType* zvals,
363 typename Teuchos::ScalarTraits<Scalar>::coordinateType* xtemp,
364 typename Teuchos::ScalarTraits<Scalar>::coordinateType* ytemp,
365 typename Teuchos::ScalarTraits<Scalar>::coordinateType* ztemp,
366 bool flipXY) const {
367
368 if( flipXY == false ) { // for line-smoothing
369 for (LO i = 0; i < numCoords; i++) xtemp[i]= xvals[i];
370 } else { // for semi-coarsening
371 for (LO i = 0; i < numCoords; i++) xtemp[i]= yvals[i];
372 }
373 for (LO i = 0; i < numCoords; i++) OrigLoc[i]= i;
374
375 ML_az_dsort2(xtemp,numCoords,OrigLoc);
376 if( flipXY == false ) { // for line-smoothing
377 for (LO i = 0; i < numCoords; i++) ytemp[i]= yvals[OrigLoc[i]];
378 } else {
379 for (LO i = 0; i < numCoords; i++) ytemp[i]= xvals[OrigLoc[i]];
380 }
381
382 LO index = 0;
383
384 while ( index < numCoords ) {
385 coordinate_type xfirst = xtemp[index];
386 LO next = index+1;
387 while ( (next != numCoords) && (xtemp[next] == xfirst))
388 next++;
389 ML_az_dsort2(&(ytemp[index]),next-index,&(OrigLoc[index]));
390 for (LO i = index; i < next; i++) ztemp[i]= zvals[OrigLoc[i]];
391 /* One final sort so that the ztemps are in order */
392 LO subindex = index;
393 while (subindex != next) {
394 coordinate_type yfirst = ytemp[subindex];
395 LO subnext = subindex+1;
396 while ( (subnext != next) && (ytemp[subnext] == yfirst)) subnext++;
397 ML_az_dsort2(&(ztemp[subindex]),subnext-subindex,&(OrigLoc[subindex]));
398 subindex = subnext;
399 }
400 index = next;
401 }
402
403 }
404
405 /* Sort coordinates and additional array accordingly (if provided). This is an expert routine borrowed from ML. Do not change.*/
406 template <class Scalar,class LocalOrdinal, class GlobalOrdinal, class Node>
407 void LineDetectionFactory<Scalar, LocalOrdinal, GlobalOrdinal, Node>::ML_az_dsort2(typename Teuchos::ScalarTraits<Scalar>::coordinateType dlist[], LocalOrdinal N, LocalOrdinal list2[]) const {
408 LO l, r, j, i, flag;
409 LO RR2;
410 coordinate_type dRR, dK;
411
412 // note: we use that routine for sorting coordinates only. No complex coordinates are assumed...
413 typedef Teuchos::ScalarTraits<SC> STS;
414
415 if (N <= 1) return;
416
417 l = N / 2 + 1;
418 r = N - 1;
419 l = l - 1;
420 dRR = dlist[l - 1];
421 dK = dlist[l - 1];
422
423 if (list2 != NULL) {
424 RR2 = list2[l - 1];
425 while (r != 0) {
426 j = l;
427 flag = 1;
428
429 while (flag == 1) {
430 i = j;
431 j = j + j;
432
433 if (j > r + 1)
434 flag = 0;
435 else {
436 if (j < r + 1)
437 if (STS::real(dlist[j]) > STS::real(dlist[j - 1])) j = j + 1;
438
439 if (STS::real(dlist[j - 1]) > STS::real(dK)) {
440 dlist[ i - 1] = dlist[ j - 1];
441 list2[i - 1] = list2[j - 1];
442 }
443 else {
444 flag = 0;
445 }
446 }
447 }
448 dlist[ i - 1] = dRR;
449 list2[i - 1] = RR2;
450
451 if (l == 1) {
452 dRR = dlist [r];
453 RR2 = list2[r];
454 dK = dlist[r];
455 dlist[r ] = dlist[0];
456 list2[r] = list2[0];
457 r = r - 1;
458 }
459 else {
460 l = l - 1;
461 dRR = dlist[ l - 1];
462 RR2 = list2[l - 1];
463 dK = dlist[l - 1];
464 }
465 }
466 dlist[ 0] = dRR;
467 list2[0] = RR2;
468 }
469 else {
470 while (r != 0) {
471 j = l;
472 flag = 1;
473 while (flag == 1) {
474 i = j;
475 j = j + j;
476 if (j > r + 1)
477 flag = 0;
478 else {
479 if (j < r + 1)
480 if (STS::real(dlist[j]) > STS::real(dlist[j - 1])) j = j + 1;
481 if (STS::real(dlist[j - 1]) > STS::real(dK)) {
482 dlist[ i - 1] = dlist[ j - 1];
483 }
484 else {
485 flag = 0;
486 }
487 }
488 }
489 dlist[ i - 1] = dRR;
490 if (l == 1) {
491 dRR = dlist [r];
492 dK = dlist[r];
493 dlist[r ] = dlist[0];
494 r = r - 1;
495 }
496 else {
497 l = l - 1;
498 dRR = dlist[ l - 1];
499 dK = dlist[l - 1];
500 }
501 }
502 dlist[ 0] = dRR;
503 }
504
505 }
506} //namespace MueLu
507
508#endif // MUELU_LINEDETECTIONFACTORY_DEF_HPP
#define SET_VALID_ENTRY(name)
MueLu::DefaultLocalOrdinal LocalOrdinal
Exception throws to report errors in the internal logical of the program.
Timer to be used in factories. Similar to Monitor but with additional timers.
Class that holds all level-specific information.
bool IsAvailable(const std::string &ename, const FactoryBase *factory=NoFactory::get()) const
Test whether a need's value has been saved.
void DeclareInput(const std::string &ename, const FactoryBase *factory, const FactoryBase *requestedBy=NoFactory::get())
Callback from FactoryBase::CallDeclareInput() and FactoryBase::DeclareInput()
void RemoveKeepFlag(const std::string &ename, const FactoryBase *factory, KeepType keep=MueLu::All)
int GetLevelID() const
Return level number.
T & Get(const std::string &ename, const FactoryBase *factory=NoFactory::get())
Get data without decrementing associated storage counter (i.e., read-only access)....
RCP< const ParameterList > GetValidParameterList() const
Return a const parameter list of valid parameters that setParameterList() will accept.
void sort_coordinates(LO numCoords, LO *OrigLoc, coordinate_type *xvals, coordinate_type *yvals, coordinate_type *zvals, coordinate_type *xtemp, coordinate_type *ytemp, coordinate_type *ztemp, bool flipXY=false) const
void ML_az_dsort2(coordinate_type dlist[], LO N, LO list2[]) const
void DeclareInput(Level &currentLevel) const
Input.
typename Teuchos::ScalarTraits< SC >::coordinateType coordinate_type
void Build(Level &currentLevel) const
Build method.
LO ML_compute_line_info(LO LayerId[], LO VertLineId[], LO Ndof, LO DofsPerNode, LO MeshNumbering, LO NumNodesPerVertLine, coordinate_type *xvals, coordinate_type *yvals, coordinate_type *zvals, const Teuchos::Comm< int > &comm) const
static const NoFactory * get()
Namespace for MueLu classes and methods.
@ UserData
User data are always kept. This flag is set automatically when Level::Set("data", data) is used....
@ Runtime1
Description of what is happening (more verbose)
@ Warnings1
Additional warnings.