@@ -31,8 +31,6 @@ static int sortSegments(Mesh mesh, struct comm *c, int dim, buffer *bfr) {
3131 s = e ;
3232 }
3333
34- comm_barrier (c );
35-
3634 // Set globalId
3735 slong out [2 ][1 ], buf [2 ][1 ], in [1 ];
3836 in [0 ] = nPoints ;
@@ -145,75 +143,58 @@ int findSegments(Mesh mesh, struct comm *c, GenmapScalar tol, int verbose, buffe
145143 // }
146144 // comm_barrier(&nonZeroRanks);
147145
148- // if (verbose > 1 && rank == 0) {
149- // printf("\tDone initializing\n");
150- // fflush(stdout);
151- // }
152- // comm_barrier(&nonZeroRanks);
153-
154146 comm_ext orig ;
155147#ifdef MPI
156148 MPI_Comm_dup (c -> c , & orig );
157149#endif
158150 struct comm nonZeroRanks ;
159151
160- int dim , bin , rank ;
161- for (dim = 0 ; dim < nDim ; dim ++ ) {
162- nPoints = mesh -> elements .n ;
163-
164- bin = 1 ;
165- if (nPoints == 0 )
166- bin = 0 ;
167-
152+ int dim , bin , rank , t ;
153+ for (t = 0 ; t < nDim ; t ++ ) {
154+ for (dim = 0 ; dim < nDim ; dim ++ ) {
155+ nPoints = mesh -> elements .n ;
156+
157+ bin = 1 ;
158+ if (nPoints == 0 )
159+ bin = 0 ;
160+
168161#ifdef MPI
169- MPI_Comm new ;
170- MPI_Comm_split (orig , bin , rank , & new );
171- comm_init (& nonZeroRanks , new );
172- MPI_Comm_free (& new );
162+ MPI_Comm new ;
163+ MPI_Comm_split (orig , bin , rank , & new );
164+ comm_init (& nonZeroRanks , new );
165+ MPI_Comm_free (& new );
173166#else
174- comm_init (& nonZeroRanks , 1 );
167+ comm_init (& nonZeroRanks , 1 );
175168#endif
176169
177- rank = nonZeroRanks .id ;
178- for (i = 0 ; i < nPoints ; i ++ )
179- points [i ].proc = rank ;
170+ rank = nonZeroRanks .id ;
171+ for (i = 0 ; i < nPoints ; i ++ )
172+ points [i ].proc = rank ;
180173
181- if (bin == 1 ) {
182- if (verbose > 0 && rank == 0 ) {
183- printf ("\tsortSegments started.\n" );
184- fflush (stdout );
185- }
186- sortSegments (mesh , & nonZeroRanks , dim , bfr );
187- comm_barrier (& nonZeroRanks );
188- if (verbose > 0 && rank == 0 )
189- printf ("\tsortSegments finished.\n" );
190-
191- findLocalSegments (mesh , dim , tolSquared );
192- comm_barrier (& nonZeroRanks );
193- if (verbose > 0 && rank == 0 )
194- printf ("\tfindLocalSegments finished.\n" );
195-
196- mergeSegments (mesh , & nonZeroRanks , dim , tolSquared , bfr );
197- comm_barrier (& nonZeroRanks );
198- if (verbose > 0 && rank == 0 )
199- printf ("\tmergeSegments finished.\n" );
200-
201- if (verbose > 0 ) {
202- nPoints = mesh -> elements .n ;
203- points = mesh -> elements .ptr ;
204- sint count = 0 ;
205- for (i = 0 ; i < nPoints ; i ++ )
206- if (points [i ].ifSegment > 0 )
207- count ++ ;
208-
209- in [0 ] = count ;
210- comm_allreduce (& nonZeroRanks , gs_long , gs_add , in , 1 , buf );
211- if (rank == 0 )
212- printf ("locglob: %d %lld\n" , dim + 1 , in [0 ] + 1 );
174+ if (bin == 1 ) {
175+ sortSegments (mesh , & nonZeroRanks , dim , bfr );
176+
177+ findLocalSegments (mesh , dim , tolSquared );
178+
179+ mergeSegments (mesh , & nonZeroRanks , dim , tolSquared , bfr );
180+
181+ if (verbose > 0 ) {
182+ nPoints = mesh -> elements .n ;
183+ points = mesh -> elements .ptr ;
184+ sint count = 0 ;
185+ for (i = 0 ; i < nPoints ; i ++ )
186+ if (points [i ].ifSegment > 0 )
187+ count ++ ;
188+
189+ in [0 ] = count ;
190+ comm_allreduce (& nonZeroRanks , gs_long , gs_add , in , 1 , buf );
191+ if (rank == 0 )
192+ printf ("\tlocglob: %d %d %lld\n" , t + 1 , dim + 1 , in [0 ] + 1 );
193+ }
213194 }
214- }
215195
216- comm_free (& nonZeroRanks );
196+ comm_free (& nonZeroRanks );
197+ }
217198 }
218199
219200#ifdef MPI
0 commit comments