/[escript]/trunk/dudley/src/NodeFile_setIdRange.c
ViewVC logotype

Contents of /trunk/dudley/src/NodeFile_setIdRange.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (9 years, 3 months ago) by jfenwick
File MIME type: text/plain
File size: 6332 byte(s)
Merging dudley and scons updates from branches

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2010 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14 /**************************************************************/
15
16 /* Dudley: Mesh: NodeFile */
17
18 /* returns the maximum and minimum node id number of nodes: */
19
20 /**************************************************************/
21
22 #include "NodeFile.h"
23 #include "Util.h"
24
25 /**************************************************************/
26
27 void Dudley_NodeFile_setGlobalIdRange(index_t * min_id, index_t * max_id, Dudley_NodeFile * in)
28 {
29 index_t min_id_local, max_id_local;
30 #ifdef ESYS_MPI
31 index_t global_id_range[2], id_range[2];
32 #endif
33
34 min_id_local = Dudley_Util_getMinInt(1, in->numNodes, in->Id);
35 max_id_local = Dudley_Util_getMaxInt(1, in->numNodes, in->Id);
36
37 #ifdef ESYS_MPI
38 id_range[0] = -min_id_local;
39 id_range[1] = max_id_local;
40 MPI_Allreduce(id_range, global_id_range, 2, MPI_INT, MPI_MAX, in->MPIInfo->comm);
41 *min_id = -global_id_range[0];
42 *max_id = global_id_range[1];
43 #else
44 *min_id = min_id_local;
45 *max_id = max_id_local;
46 #endif
47 if (*max_id < *min_id)
48 {
49 *max_id = 0;
50 *min_id = -1;
51 }
52 }
53
54 void Dudley_NodeFile_setIdRange(index_t * min_id, index_t * max_id, Dudley_NodeFile * in)
55 {
56 *min_id = Dudley_Util_getMinInt(1, in->numNodes, in->Id);
57 *max_id = Dudley_Util_getMaxInt(1, in->numNodes, in->Id);
58 if (*max_id < *min_id)
59 {
60 *max_id = 0;
61 *min_id = -1;
62 }
63 }
64
65 void Dudley_NodeFile_setGlobalDOFRange(index_t * min_id, index_t * max_id, Dudley_NodeFile * in)
66 {
67 index_t min_id_local, max_id_local;
68 #ifdef ESYS_MPI
69 index_t global_id_range[2], id_range[2];
70 #endif
71
72 min_id_local = Dudley_Util_getMinInt(1, in->numNodes, in->globalDegreesOfFreedom);
73 max_id_local = Dudley_Util_getMaxInt(1, in->numNodes, in->globalDegreesOfFreedom);
74
75 #ifdef ESYS_MPI
76 id_range[0] = -min_id_local;
77 id_range[1] = max_id_local;
78 MPI_Allreduce(id_range, global_id_range, 2, MPI_INT, MPI_MAX, in->MPIInfo->comm);
79 *min_id = -global_id_range[0];
80 *max_id = global_id_range[1];
81 #else
82 *min_id = min_id_local;
83 *max_id = max_id_local;
84 #endif
85 if (*max_id < *min_id)
86 {
87 *max_id = 0;
88 *min_id = -1;
89 }
90 }
91
92 void Dudley_NodeFile_setDOFRange(index_t * min_id, index_t * max_id, Dudley_NodeFile * in)
93 {
94 *min_id = Dudley_Util_getMinInt(1, in->numNodes, in->globalDegreesOfFreedom);
95 *max_id = Dudley_Util_getMaxInt(1, in->numNodes, in->globalDegreesOfFreedom);
96 if (*max_id < *min_id)
97 {
98 *max_id = 0;
99 *min_id = -1;
100 }
101 }
102
103 void Dudley_NodeFile_setReducedDOFRange(index_t * min_id, index_t * max_id, Dudley_NodeFile * in)
104 {
105 *min_id = Dudley_Util_getFlaggedMinInt(1, in->numNodes, in->globalReducedDOFIndex, -1);
106 *max_id = Dudley_Util_getFlaggedMaxInt(1, in->numNodes, in->globalReducedDOFIndex, -1);
107 if (*max_id < *min_id)
108 {
109 *max_id = 0;
110 *min_id = -1;
111 }
112 }
113
114 index_t Dudley_NodeFile_maxGlobalDegreeOfFreedomIndex(Dudley_NodeFile * in)
115 {
116 index_t min_id, max_id;
117 Dudley_NodeFile_setGlobalDOFRange(&min_id, &max_id, in);
118 return max_id;
119 }
120
121 index_t Dudley_NodeFile_maxGlobalReducedDegreeOfFreedomIndex(Dudley_NodeFile * in)
122 {
123 index_t min_id, max_id;
124 Dudley_NodeFile_setGlobalReducedDegreeOfFreedomRange(&min_id, &max_id, in);
125 return max_id;
126 }
127
128 void Dudley_NodeFile_setGlobalReducedDegreeOfFreedomRange(index_t * min_id, index_t * max_id, Dudley_NodeFile * in)
129 {
130 index_t min_id_local, max_id_local;
131 #ifdef ESYS_MPI
132 index_t global_id_range[2], id_range[2];
133 #endif
134
135 min_id_local = Dudley_Util_getFlaggedMaxInt(1, in->numNodes, in->globalReducedDOFIndex, -1);
136 max_id_local = Dudley_Util_getFlaggedMinInt(1, in->numNodes, in->globalReducedDOFIndex, -1);
137
138 #ifdef ESYS_MPI
139 id_range[0] = -min_id_local;
140 id_range[1] = max_id_local;
141 MPI_Allreduce(id_range, global_id_range, 2, MPI_INT, MPI_MAX, in->MPIInfo->comm);
142 *min_id = -global_id_range[0];
143 *max_id = global_id_range[1];
144 #else
145 *min_id = min_id_local;
146 *max_id = max_id_local;
147 #endif
148 if (*max_id < *min_id)
149 {
150 *max_id = 0;
151 *min_id = -1;
152 }
153 }
154
155 index_t Dudley_NodeFile_maxGlobalNodeIDIndex(Dudley_NodeFile * in)
156 {
157 index_t min_id, max_id;
158 Dudley_NodeFile_setGlobalNodeIDIndexRange(&min_id, &max_id, in);
159 return max_id;
160 }
161
162 void Dudley_NodeFile_setGlobalNodeIDIndexRange(index_t * min_id, index_t * max_id, Dudley_NodeFile * in)
163 {
164 index_t min_id_local, max_id_local;
165 #ifdef ESYS_MPI
166 index_t global_id_range[2], id_range[2];
167 #endif
168
169 max_id_local = Dudley_Util_getMaxInt(1, in->numNodes, in->globalNodesIndex);
170 min_id_local = Dudley_Util_getMinInt(1, in->numNodes, in->globalNodesIndex);
171
172 #ifdef ESYS_MPI
173 id_range[0] = -min_id_local;
174 id_range[1] = max_id_local;
175 MPI_Allreduce(id_range, global_id_range, 2, MPI_INT, MPI_MAX, in->MPIInfo->comm);
176 *min_id = -global_id_range[0];
177 *max_id = global_id_range[1];
178 #else
179 *min_id = min_id_local;
180 *max_id = max_id_local;
181 #endif
182 if (*max_id < *min_id)
183 {
184 *max_id = 0;
185 *min_id = -1;
186 }
187 }
188
189 index_t Dudley_NodeFile_maxGlobalReducedNodeIDIndex(Dudley_NodeFile * in)
190 {
191 index_t min_id, max_id;
192 Dudley_NodeFile_setGlobalReducedNodeIDIndexRange(&min_id, &max_id, in);
193 return max_id;
194 }
195
196 void Dudley_NodeFile_setGlobalReducedNodeIDIndexRange(index_t * min_id, index_t * max_id, Dudley_NodeFile * in)
197 {
198 index_t min_id_local, max_id_local;
199 #ifdef ESYS_MPI
200 index_t global_id_range[2], id_range[2];
201 #endif
202
203 max_id_local = Dudley_Util_getFlaggedMaxInt(1, in->numNodes, in->globalReducedNodesIndex, -1);
204 min_id_local = Dudley_Util_getFlaggedMinInt(1, in->numNodes, in->globalReducedNodesIndex, -1);
205
206 #ifdef ESYS_MPI
207 id_range[0] = -min_id_local;
208 id_range[1] = max_id_local;
209 MPI_Allreduce(id_range, global_id_range, 2, MPI_INT, MPI_MAX, in->MPIInfo->comm);
210 *min_id = -global_id_range[0];
211 *max_id = global_id_range[1];
212 #else
213 *min_id = min_id_local;
214 *max_id = max_id_local;
215 #endif
216 if (*max_id < *min_id)
217 {
218 *max_id = 0;
219 *min_id = -1;
220 }
221 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26