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

Contents of /branches/trilinos_from_5897/dudley/src/Mesh_resolveNodeIds.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: 3647 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 "Util.h"
19
20 namespace dudley {
21
22 void Mesh::resolveNodeIds()
23 {
24 // find the minimum and maximum id used by elements
25 index_t min_id = escript::DataTypes::index_t_max();
26 index_t max_id = -escript::DataTypes::index_t_max();
27 std::pair<index_t,index_t> range(Elements->getNodeRange());
28 max_id = std::max(max_id, range.second);
29 min_id = std::min(min_id, range.first);
30 range = FaceElements->getNodeRange();
31 max_id = std::max(max_id, range.second);
32 min_id = std::min(min_id, range.first);
33 range = Points->getNodeRange();
34 max_id = std::max(max_id, range.second);
35 min_id = std::min(min_id, range.first);
36 #ifdef Dudley_TRACE
37 index_t global_min_id, global_max_id;
38 #ifdef ESYS_MPI
39 index_t id_range[2], global_id_range[2];
40 id_range[0] = -min_id;
41 id_range[1] = max_id;
42 MPI_Allreduce(id_range, global_id_range, 2, MPI_DIM_T, MPI_MAX, MPIInfo->comm);
43 global_min_id = -global_id_range[0];
44 global_max_id = global_id_range[1];
45 #else
46 global_min_id = min_id;
47 global_max_id = max_id;
48 #endif
49 printf("Node id range used by elements is %d:%d\n", global_min_id, global_max_id);
50 #endif
51 if (min_id > max_id) {
52 max_id = -1;
53 min_id = 0;
54 }
55
56 // allocate mappings for new local node labeling to global node labeling
57 // (newLocalToGlobalNodeLabels) and global node labeling to the new local
58 // node labeling (globalToNewLocalNodeLabels[i-min_id] is the new local id
59 // of global node i)
60 index_t len = (max_id >= min_id) ? max_id - min_id + 1 : 0;
61
62 // mark the nodes referred by elements in usedMask
63 std::vector<short> usedMask(len, -1);
64 markNodes(usedMask, min_id);
65
66 // create a local labeling newLocalToGlobalNodeLabels of the local nodes
67 // by packing the mask usedMask
68 std::vector<index_t> newLocalToGlobalNodeLabels = util::packMask(usedMask);
69 const dim_t newNumNodes = newLocalToGlobalNodeLabels.size();
70 usedMask.clear();
71
72 // invert the new labeling and shift the index newLocalToGlobalNodeLabels
73 // to global node IDs
74 index_t* globalToNewLocalNodeLabels = new index_t[len];
75
76 #pragma omp parallel for
77 for (index_t n = 0; n < newNumNodes; n++) {
78 #ifdef BOUNDS_CHECK
79 if (newLocalToGlobalNodeLabels[n] >= len || newLocalToGlobalNodeLabels[n] < 0) {
80 printf("BOUNDS_CHECK %s %d n=%d\n", __FILE__, __LINE__, n);
81 exit(1);
82 }
83 #endif
84 globalToNewLocalNodeLabels[newLocalToGlobalNodeLabels[n]] = n;
85 newLocalToGlobalNodeLabels[n] += min_id;
86 }
87 // create a new node file
88 NodeFile* newNodeFile = new NodeFile(getDim(), MPIInfo);
89 newNodeFile->allocTable(newNumNodes);
90 if (len)
91 newNodeFile->gather_global(&newLocalToGlobalNodeLabels[0], Nodes);
92 else
93 newNodeFile->gather_global(NULL, Nodes);
94
95 delete Nodes;
96 Nodes = newNodeFile;
97 // relabel nodes of the elements
98 relabelElementNodes(globalToNewLocalNodeLabels, min_id);
99 delete[] globalToNewLocalNodeLabels;
100 }
101
102 } // namespace dudley
103

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision
svn:mergeinfo /branches/4.0fordebian/dudley/src/Mesh_resolveNodeIds.cpp:5567-5588 /branches/lapack2681/finley/src/Mesh_resolveNodeIds.cpp:2682-2741 /branches/pasowrap/dudley/src/Mesh_resolveNodeIds.cpp:3661-3674 /branches/py3_attempt2/dudley/src/Mesh_resolveNodeIds.cpp:3871-3891 /branches/restext/finley/src/Mesh_resolveNodeIds.cpp:2610-2624 /branches/ripleygmg_from_3668/dudley/src/Mesh_resolveNodeIds.cpp:3669-3791 /branches/stage3.0/finley/src/Mesh_resolveNodeIds.cpp:2569-2590 /branches/symbolic_from_3470/dudley/src/Mesh_resolveNodeIds.cpp:3471-3974 /branches/symbolic_from_3470/ripley/test/python/dudley/src/Mesh_resolveNodeIds.cpp:3517-3974 /release/3.0/finley/src/Mesh_resolveNodeIds.cpp:2591-2601 /release/4.0/dudley/src/Mesh_resolveNodeIds.cpp:5380-5406 /trunk/dudley/src/Mesh_resolveNodeIds.cpp:4257-4344,5898-6007 /trunk/ripley/test/python/dudley/src/Mesh_resolveNodeIds.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26