/[escript]/trunk/dudley/src/Mesh_optimizeDOFLabeling.cpp
ViewVC logotype

Annotation of /trunk/dudley/src/Mesh_optimizeDOFLabeling.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4803 - (hide annotations)
Wed Mar 26 06:52:28 2014 UTC (5 years, 11 months ago) by caltinay
File size: 4855 byte(s)
Removed obsolete wrappers for malloc and friends.
Paso_Pattern -> paso::Pattern

1 ksteube 1315
2 jfenwick 3981 /*****************************************************************************
3 ksteube 1811 *
4 jfenwick 4657 * Copyright (c) 2003-2014 by University of Queensland
5 jfenwick 3981 * http://www.uq.edu.au
6 ksteube 1811 *
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 jfenwick 3981 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 * Development 2012-2013 by School of Earth Sciences
13     * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 jfenwick 3981 *
15     *****************************************************************************/
16 ksteube 1315
17 jfenwick 3981 /**********************************************************************************************/
18 ksteube 1315
19 jfenwick 3086 /* Dudley: Mesh: optimizes the labeling of the DOFs on each processor */
20 ksteube 1315
21 jfenwick 3981 /**********************************************************************************************/
22 ksteube 1315
23     #include "Mesh.h"
24     #include "IndexList.h"
25    
26 jfenwick 3981 /************************************************************************************/
27 ksteube 1315
28 jfenwick 3224 void Dudley_Mesh_optimizeDOFLabeling(Dudley_Mesh * in, dim_t * distribution)
29     {
30 ksteube 1315
31 jfenwick 3224 index_t myFirstVertex, myLastVertex, *newGlobalDOFID = NULL, firstVertex, lastVertex;
32     register index_t k;
33     dim_t mpiSize, myNumVertices, len, p, i;
34 caltinay 4803 paso::Pattern *pattern = NULL;
35 caltinay 3603 Esys_MPI_rank myRank, current_rank;
36 jfenwick 3224 Dudley_IndexList *index_list = NULL;
37 jfenwick 3231 #ifdef ESYS_MPI
38 caltinay 3603 Esys_MPI_rank dest, source;
39 jfenwick 3224 MPI_Status status;
40     #endif
41 ksteube 1315
42 jfenwick 3224 if (in == NULL)
43     return;
44     if (in->Nodes == NULL)
45     return;
46 ksteube 1315
47 jfenwick 3224 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 = MAX(len, distribution[p + 1] - distribution[p]);
55 ksteube 1315
56 jfenwick 4332 index_list = new Dudley_IndexList[myNumVertices];
57     newGlobalDOFID = new index_t[len];
58 jfenwick 3224 /* create the adjacency structure xadj and adjncy */
59     if (!(Dudley_checkPtr(index_list) || Dudley_checkPtr(newGlobalDOFID)))
60     {
61     #pragma omp parallel private(i)
62     {
63     #pragma omp for schedule(static)
64     for (i = 0; i < myNumVertices; ++i)
65     {
66     index_list[i].extension = NULL;
67     index_list[i].n = 0;
68     }
69 jfenwick 4345 /* insert contributions from element matrices into columns index index_list: */
70 jfenwick 3224 Dudley_IndexList_insertElementsWithRowRangeNoMainDiagonal(index_list, myFirstVertex, myLastVertex,
71     in->Elements, in->Nodes->globalDegreesOfFreedom,
72     in->Nodes->globalDegreesOfFreedom);
73     Dudley_IndexList_insertElementsWithRowRangeNoMainDiagonal(index_list, myFirstVertex, myLastVertex,
74     in->FaceElements,
75     in->Nodes->globalDegreesOfFreedom,
76     in->Nodes->globalDegreesOfFreedom);
77     Dudley_IndexList_insertElementsWithRowRangeNoMainDiagonal(index_list, myFirstVertex, myLastVertex,
78     in->Points, in->Nodes->globalDegreesOfFreedom,
79     in->Nodes->globalDegreesOfFreedom);
80     }
81     /* create the local matrix pattern */
82     pattern =
83     Dudley_IndexList_createPattern(0, myNumVertices, index_list, myFirstVertex, myLastVertex, -myFirstVertex);
84 ksteube 1315
85 jfenwick 3224 /* clean up index list */
86     if (index_list != NULL)
87     {
88     #pragma omp parallel for private(i)
89     for (i = 0; i < myNumVertices; ++i)
90     Dudley_IndexList_free(index_list[i].extension);
91     }
92 ksteube 1315
93 jfenwick 3224 if (Dudley_noError())
94 caltinay 4803 paso::Pattern_reduceBandwidth(pattern, newGlobalDOFID);
95 ksteube 1315
96 caltinay 4803 paso::Pattern_free(pattern);
97 jfenwick 3224 }
98 jfenwick 3227 Esys_MPIInfo_noError(in->MPIInfo);
99 jfenwick 3224 if (Dudley_noError())
100     {
101     /* shift new labeling to create a global id */
102     #pragma omp parallel for private(i)
103     for (i = 0; i < myNumVertices; ++i)
104     newGlobalDOFID[i] += myFirstVertex;
105 ksteube 1315
106 jfenwick 3224 /* distribute new labeling to other processors */
107 caltinay 3603 #ifdef ESYS_MPI
108 jfenwick 3227 dest = Esys_MPIInfo_mod(mpiSize, myRank + 1);
109     source = Esys_MPIInfo_mod(mpiSize, myRank - 1);
110 caltinay 3603 #endif
111 jfenwick 3224 current_rank = myRank;
112     for (p = 0; p < mpiSize; ++p)
113     {
114     firstVertex = distribution[current_rank];
115     lastVertex = distribution[current_rank + 1];
116     #pragma omp parallel for private(i,k)
117     for (i = 0; i < in->Nodes->numNodes; ++i)
118     {
119     k = in->Nodes->globalDegreesOfFreedom[i];
120     if ((firstVertex <= k) && (k < lastVertex))
121     {
122     in->Nodes->globalDegreesOfFreedom[i] = newGlobalDOFID[k - firstVertex];
123     }
124     }
125 ksteube 1315
126 jfenwick 3224 if (p < mpiSize - 1)
127     { /* the final send can be skipped */
128 jfenwick 3231 #ifdef ESYS_MPI
129 jfenwick 3224 MPI_Sendrecv_replace(newGlobalDOFID, len, MPI_INT,
130     dest, in->MPIInfo->msg_tag_counter,
131     source, in->MPIInfo->msg_tag_counter, in->MPIInfo->comm, &status);
132     #endif
133     in->MPIInfo->msg_tag_counter++;
134 jfenwick 3227 current_rank = Esys_MPIInfo_mod(mpiSize, current_rank - 1);
135 jfenwick 3224 }
136     }
137     }
138 jfenwick 4332 delete[] index_list;
139     delete[] newGlobalDOFID;
140 ksteube 1315 #if 0
141 jfenwick 3224 for (i = 0; i < in->Nodes->numNodes; ++i)
142     printf("%d ", in->Nodes->globalDegreesOfFreedom[i]);
143     printf("\n");
144 ksteube 1315 #endif
145 jfenwick 3224 return;
146 ksteube 1315 }

Properties

Name Value
svn:mergeinfo /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 /trunk/dudley/src/Mesh_optimizeDOFLabeling.cpp:4257-4344 /trunk/ripley/test/python/dudley/src/Mesh_optimizeDOFLabeling.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26