/[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 5963 - (show annotations)
Mon Feb 22 06:59:27 2016 UTC (3 years, 3 months ago) by caltinay
File size: 5552 byte(s)
sync and fix.

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 */
20
21 /* at input the element nodes refers to the numbering defined the global Id assigned to the nodes in the */
22 /* NodeFile. It is also not ensured that all nodes referred to by an element are actually available */
23 /* on the process. At the output, a local node labelling is used and all nodes are available */
24 /* In particular the numbering of the element nodes is between 0 and in->NodeFile->numNodes */
25 /* The function does not create a distribution of the degrees of freedom. */
26
27 /************************************************************************************/
28
29 #define ESNEEDPYTHON
30 #include "esysUtils/first.h"
31
32 #include "Mesh.h"
33 #include "Util.h"
34
35 /************************************************************************************/
36
37 void Dudley_Mesh_resolveNodeIds(Dudley_Mesh * in)
38 {
39
40 index_t min_id, max_id, min_id2, max_id2, global_min_id, global_max_id,
41 *globalToNewLocalNodeLabels = NULL, *newLocalToGlobalNodeLabels = NULL;
42 dim_t len, n, newNumNodes, numDim;
43 Dudley_NodeFile *newNodeFile = NULL;
44 #ifdef ESYS_MPI
45 index_t id_range[2], global_id_range[2];
46 #endif
47 numDim = Dudley_Mesh_getDim(in);
48 /* find the minimum and maximum id used by elements: */
49 min_id = escript::DataTypes::index_t_max();
50 max_id = -escript::DataTypes::index_t_max();
51 Dudley_ElementFile_setNodeRange(&min_id2, &max_id2, in->Elements);
52 max_id = MAX(max_id, max_id2);
53 min_id = MIN(min_id, min_id2);
54 Dudley_ElementFile_setNodeRange(&min_id2, &max_id2, in->FaceElements);
55 max_id = MAX(max_id, max_id2);
56 min_id = MIN(min_id, min_id2);
57 Dudley_ElementFile_setNodeRange(&min_id2, &max_id2, in->Points);
58 max_id = MAX(max_id, max_id2);
59 min_id = MIN(min_id, min_id2);
60 #ifdef ESYS_MPI
61 id_range[0] = -min_id;
62 id_range[1] = max_id;
63 MPI_Allreduce(id_range, global_id_range, 2, MPI_INT, MPI_MAX, in->MPIInfo->comm);
64 global_min_id = -global_id_range[0];
65 global_max_id = global_id_range[1];
66 #else
67 global_min_id = min_id;
68 global_max_id = max_id;
69 #endif
70 #ifdef Dudley_TRACE
71 printf("Node id range used by elements is %d:%d\n", global_min_id, global_max_id);
72 #else
73 /* avoid unused var warning if Dudley_TRACE is not defined */
74 (void)global_min_id;
75 (void)global_max_id;
76 #endif
77 if (min_id > max_id)
78 {
79 max_id = -1;
80 min_id = 0;
81 }
82
83 /* allocate mappings for new local node labelling to global node labelling (newLocalToGlobalNodeLabels)
84 and global node labelling to the new local node labelling (globalToNewLocalNodeLabels[i-min_id] is the
85 new local id of global node i) */
86 len = (max_id >= min_id) ? max_id - min_id + 1 : 0;
87 globalToNewLocalNodeLabels = new index_t[len]; /* local mask for used nodes */
88 newLocalToGlobalNodeLabels = new index_t[len];
89 if (!((Dudley_checkPtr(globalToNewLocalNodeLabels) && Dudley_checkPtr(newLocalToGlobalNodeLabels))))
90 {
91
92 #pragma omp parallel
93 {
94 #pragma omp for private(n) schedule(static)
95 for (n = 0; n < len; n++)
96 newLocalToGlobalNodeLabels[n] = -1;
97 #pragma omp for private(n) schedule(static)
98 for (n = 0; n < len; n++)
99 globalToNewLocalNodeLabels[n] = -1;
100 }
101
102 /* mark the nodes referred by elements in globalToNewLocalNodeLabels which is currently used as a mask: */
103 Dudley_Mesh_markNodes(globalToNewLocalNodeLabels, min_id, in, FALSE);
104
105 /* create a local labelling newLocalToGlobalNodeLabels of the local nodes by packing the mask globalToNewLocalNodeLabels */
106
107 newNumNodes = Dudley_Util_packMask(len, globalToNewLocalNodeLabels, newLocalToGlobalNodeLabels);
108
109 /* invert the new labelling and shift the index newLocalToGlobalNodeLabels to global node ids */
110 #pragma omp parallel for private(n) schedule(static)
111 for (n = 0; n < newNumNodes; n++)
112 {
113 #ifdef BOUNDS_CHECK
114 if (n >= len || n < 0)
115 {
116 printf("BOUNDS_CHECK %s %d n=%d\n", __FILE__, __LINE__, n);
117 exit(1);
118 }
119 if (newLocalToGlobalNodeLabels[n] >= len || newLocalToGlobalNodeLabels[n] < 0)
120 {
121 printf("BOUNDS_CHECK %s %d n=%d\n", __FILE__, __LINE__, n);
122 exit(1);
123 }
124 #endif
125 globalToNewLocalNodeLabels[newLocalToGlobalNodeLabels[n]] = n;
126 newLocalToGlobalNodeLabels[n] += min_id;
127 }
128 /* create a new table */
129 newNodeFile = Dudley_NodeFile_alloc(numDim, in->MPIInfo);
130 if (Dudley_noError())
131 {
132 Dudley_NodeFile_allocTable(newNodeFile, newNumNodes);
133 }
134 if (Dudley_noError())
135 {
136 Dudley_NodeFile_gather_global(newLocalToGlobalNodeLabels, in->Nodes, newNodeFile);
137 }
138 if (Dudley_noError())
139 {
140 Dudley_NodeFile_free(in->Nodes);
141 in->Nodes = newNodeFile;
142 /* relabel nodes of the elements: */
143 Dudley_Mesh_relableElementNodes(globalToNewLocalNodeLabels, min_id, in);
144 }
145 }
146 delete[] globalToNewLocalNodeLabels;
147 delete[] newLocalToGlobalNodeLabels;
148 if (!Dudley_noError())
149 {
150 Dudley_NodeFile_free(newNodeFile);
151 }
152 }

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-5962 /trunk/ripley/test/python/dudley/src/Mesh_resolveNodeIds.cpp:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26