/[escript]/branches/trilinos_from_5897/dudley/src/Mesh_optimizeDOFLabeling.cpp
ViewVC logotype

Contents of /branches/trilinos_from_5897/dudley/src/Mesh_optimizeDOFLabeling.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6009 - (show annotations)
Wed Mar 2 04:13:26 2016 UTC (3 years, 1 month ago) by caltinay
File size: 4360 byte(s)
Much needed sync with trunk...

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17 /****************************************************************************/
18
19 /* Dudley: Mesh: optimizes the labeling of the DOFs on each processor */
20
21 /****************************************************************************/
22
23 #include "Mesh.h"
24 #include "IndexList.h"
25
26 #include <boost/scoped_array.hpp>
27
28 namespace dudley {
29
30 void Dudley_Mesh_optimizeDOFLabeling(Dudley_Mesh* in, dim_t* distribution)
31 {
32 if (in == NULL)
33 return;
34 if (in->Nodes == NULL)
35 return;
36
37 index_t myFirstVertex, myLastVertex, *newGlobalDOFID = NULL, firstVertex, lastVertex;
38 index_t k;
39 dim_t mpiSize, myNumVertices, len, p, i;
40 paso::Pattern_ptr pattern;
41 int myRank, current_rank;
42 #ifdef ESYS_MPI
43 int dest, source;
44 MPI_Status status;
45 #endif
46
47 myRank = in->MPIInfo->rank;
48 mpiSize = in->MPIInfo->size;
49 myFirstVertex = distribution[myRank];
50 myLastVertex = distribution[myRank + 1];
51 myNumVertices = myLastVertex - myFirstVertex;
52 len = 0;
53 for (p = 0; p < mpiSize; ++p)
54 len = std::max(len, distribution[p + 1] - distribution[p]);
55
56 boost::scoped_array<IndexList> index_list(new IndexList[myNumVertices]);
57 newGlobalDOFID = new index_t[len];
58
59 /* create the adjacency structure xadj and adjncy */
60 #pragma omp parallel private(i)
61 {
62 /* insert contributions from element matrices into columns index index_list: */
63 Dudley_IndexList_insertElementsWithRowRangeNoMainDiagonal(index_list.get(),
64 myFirstVertex, myLastVertex, in->Elements,
65 in->Nodes->globalDegreesOfFreedom, in->Nodes->globalDegreesOfFreedom);
66 Dudley_IndexList_insertElementsWithRowRangeNoMainDiagonal(index_list.get(),
67 myFirstVertex, myLastVertex, in->FaceElements,
68 in->Nodes->globalDegreesOfFreedom,
69 in->Nodes->globalDegreesOfFreedom);
70 Dudley_IndexList_insertElementsWithRowRangeNoMainDiagonal(index_list.get(),
71 myFirstVertex, myLastVertex, in->Points,
72 in->Nodes->globalDegreesOfFreedom,
73 in->Nodes->globalDegreesOfFreedom);
74 }
75 /* create the local matrix pattern */
76 pattern = paso::Pattern::fromIndexListArray(0, myNumVertices, index_list.get(),
77 myFirstVertex, myLastVertex, -myFirstVertex);
78
79 pattern->reduceBandwidth(newGlobalDOFID);
80
81 /* shift new labeling to create a global id */
82 #pragma omp parallel for private(i)
83 for (i = 0; i < myNumVertices; ++i)
84 newGlobalDOFID[i] += myFirstVertex;
85
86 /* distribute new labeling to other processors */
87 #ifdef ESYS_MPI
88 dest = in->MPIInfo->mod_rank(myRank + 1);
89 source = in->MPIInfo->mod_rank(myRank - 1);
90 #endif
91 current_rank = myRank;
92 for (p = 0; p < mpiSize; ++p) {
93 firstVertex = distribution[current_rank];
94 lastVertex = distribution[current_rank + 1];
95 #pragma omp parallel for private(i,k)
96 for (i = 0; i < in->Nodes->numNodes; ++i) {
97 k = in->Nodes->globalDegreesOfFreedom[i];
98 if ((firstVertex <= k) && (k < lastVertex)) {
99 in->Nodes->globalDegreesOfFreedom[i] = newGlobalDOFID[k - firstVertex];
100 }
101 }
102
103 if (p < mpiSize - 1) { /* the final send can be skipped */
104 #ifdef ESYS_MPI
105 MPI_Sendrecv_replace(newGlobalDOFID, len, MPI_INT,
106 dest, in->MPIInfo->counter(),
107 source, in->MPIInfo->counter(), in->MPIInfo->comm, &status);
108 in->MPIInfo->incCounter();
109 #endif
110 current_rank = in->MPIInfo->mod_rank(current_rank - 1);
111 }
112 }
113 delete[] newGlobalDOFID;
114 #if 0
115 for (i = 0; i < in->Nodes->numNodes; ++i)
116 printf("%d ", in->Nodes->globalDegreesOfFreedom[i]);
117 printf("\n");
118 #endif
119 }
120
121 } // namespace dudley
122

Properties

Name Value
svn:mergeinfo /branches/4.0fordebian/dudley/src/Mesh_optimizeDOFLabeling.cpp:5567-5588 /branches/complex/dudley/src/Mesh_optimizeDOFLabeling.cpp:5866-5937 /branches/diaplayground/dudley/src/Mesh_optimizeDOFLabeling.cpp:4940-5147 /branches/lapack2681/finley/src/Mesh_optimizeDOFLabeling.cpp:2682-2741 /branches/pasowrap/dudley/src/Mesh_optimizeDOFLabeling.cpp:3661-3674 /branches/py3_attempt2/dudley/src/Mesh_optimizeDOFLabeling.cpp:3871-3891 /branches/restext/finley/src/Mesh_optimizeDOFLabeling.cpp:2610-2624 /branches/ripleygmg_from_3668/dudley/src/Mesh_optimizeDOFLabeling.cpp:3669-3791 /branches/stage3.0/finley/src/Mesh_optimizeDOFLabeling.cpp:2569-2590 /branches/symbolic_from_3470/dudley/src/Mesh_optimizeDOFLabeling.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/dudley/src/Mesh_optimizeDOFLabeling.cpp:3517-3974 /release/3.0/finley/src/Mesh_optimizeDOFLabeling.cpp:2591-2601 /release/4.0/dudley/src/Mesh_optimizeDOFLabeling.cpp:5380-5406 /trunk/dudley/src/Mesh_optimizeDOFLabeling.cpp:4257-4344,5898-6007 /trunk/ripley/test/python/dudley/src/Mesh_optimizeDOFLabeling.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26