/[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 6079 - (show annotations)
Mon Mar 21 12:22:38 2016 UTC (2 years, 11 months ago) by caltinay
File size: 3728 byte(s)
Big commit - making dudley much more like finley to make it more
managable. Fixed quite a few issues that had been fixed in finley.
Disposed of all ReducedNode/ReducedDOF entities that dudley never supported.
Compiles and passes tests.

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 #include "Mesh.h"
18 #include "IndexList.h"
19
20 #include <boost/scoped_array.hpp>
21
22 namespace dudley {
23
24 /// optimizes the labeling of the DOFs on each processor
25 void Mesh::optimizeDOFLabeling(const std::vector<index_t>& distribution)
26 {
27 const int myRank = MPIInfo->rank;
28 const int mpiSize = MPIInfo->size;
29 const index_t myFirstVertex = distribution[myRank];
30 const index_t myLastVertex = distribution[myRank+1];
31 const dim_t myNumVertices = myLastVertex-myFirstVertex;
32 dim_t len = 0;
33 for (int p=0; p<mpiSize; ++p)
34 len=std::max(len, distribution[p+1]-distribution[p]);
35
36 boost::scoped_array<IndexList> index_list(new IndexList[myNumVertices]);
37 std::vector<index_t> newGlobalDOFID(len);
38
39 // create the adjacency structure xadj and adjncy
40 #pragma omp parallel
41 {
42 // insert contributions from element matrices into columns index
43 IndexList_insertElementsWithRowRangeNoMainDiagonal(index_list.get(),
44 myFirstVertex, myLastVertex, Elements,
45 Nodes->globalDegreesOfFreedom);
46 IndexList_insertElementsWithRowRangeNoMainDiagonal(index_list.get(),
47 myFirstVertex, myLastVertex, FaceElements,
48 Nodes->globalDegreesOfFreedom);
49 IndexList_insertElementsWithRowRangeNoMainDiagonal(index_list.get(),
50 myFirstVertex, myLastVertex, Points,
51 Nodes->globalDegreesOfFreedom);
52 }
53 // create the local matrix pattern
54 paso::Pattern_ptr pattern = paso::Pattern::fromIndexListArray(0,
55 myNumVertices, index_list.get(), myFirstVertex, myLastVertex,
56 -myFirstVertex);
57
58 pattern->reduceBandwidth(&newGlobalDOFID[0]);
59
60 // shift new labeling to create a global id
61 #pragma omp parallel for
62 for (index_t i = 0; i < myNumVertices; ++i)
63 newGlobalDOFID[i] += myFirstVertex;
64
65 // distribute new labeling to other processors
66 #ifdef ESYS_MPI
67 const int dest = MPIInfo->mod_rank(myRank + 1);
68 const int source = MPIInfo->mod_rank(myRank - 1);
69 #endif
70 int current_rank = myRank;
71 for (int p = 0; p < mpiSize; ++p) {
72 const index_t firstVertex = distribution[current_rank];
73 const index_t lastVertex = distribution[current_rank + 1];
74 #pragma omp parallel for
75 for (index_t i = 0; i < Nodes->getNumNodes(); ++i) {
76 const index_t k = Nodes->globalDegreesOfFreedom[i];
77 if (firstVertex <= k && k < lastVertex) {
78 Nodes->globalDegreesOfFreedom[i]=newGlobalDOFID[k-firstVertex];
79 }
80 }
81
82 if (p < mpiSize - 1) { // the final send can be skipped
83 #ifdef ESYS_MPI
84 MPI_Status status;
85 MPI_Sendrecv_replace(&newGlobalDOFID[0], len, MPI_DIM_T,
86 dest, MPIInfo->counter(), source,
87 MPIInfo->counter(), MPIInfo->comm, &status);
88 MPIInfo->incCounter();
89 #endif
90 current_rank = MPIInfo->mod_rank(current_rank - 1);
91 }
92 }
93 #if 0
94 for (index_t i = 0; i < Nodes->getNumNodes(); ++i)
95 printf("%d ", Nodes->globalDegreesOfFreedom[i]);
96 printf("\n");
97 #endif
98 }
99
100 } // namespace dudley
101

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