38 int main(
int argc,
char** argv )
44 MPI_Init( &argc, &argv );
56 if( NULL ==
mb )
return 1;
61 int nprocs = pcomm->
size();
67 options =
"PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARALLEL_RESOLVE_SHARED_ENTS;"
68 "PARALLEL_GHOSTS=2.0.1;DEBUG_IO=0;DEBUG_PIO=0";
80 Range verts, faces, skin_verts;
91 vector< int > fix_tag( skin_verts.
size(), 1 );
103 options =
"PARALLEL=WRITE_PART";
124 int nprocs = pcomm->
size();
134 vector< double > vcentroids( 3 * verts.
size() );
142 Range owned_verts, shared_owned_verts;
151 vector< int > fix_tag( owned_verts.
size() );
156 vcentroids.resize( 3 * owned_verts.
size() );
164 if( shared_owned_verts.
empty() ) shared_owned_verts.
insert( *verts.
begin() );
168 vector< double > fcentroids( 3 * faces.
size() );
174 vector< EntityHandle > adj_faces;
177 for(
int nit = 0; nit < num_its; nit++ )
179 double mxdelta = 0.0;
182 for( fit = faces.
begin(), f = 0; fit != faces.
end(); ++fit, f++ )
188 fcentroids[3 * f + 0] = fcentroids[3 * f + 1] = fcentroids[3 * f + 2] = 0.0;
189 for( v = 0; v < nconn; v++ )
191 fcentroids[3 * f + 0] += ctag[3 * v + 0];
192 fcentroids[3 * f + 1] += ctag[3 * v + 1];
193 fcentroids[3 * f + 2] += ctag[3 * v + 2];
195 for( v = 0; v < 3; v++ )
196 fcentroids[3 * f + v] /= nconn;
201 for( vit = owned_verts.
begin(), v = 0; vit != owned_verts.
end(); ++vit, v++ )
204 if( fix_tag[v] )
continue;
209 double vnew[] = { 0.0, 0.0, 0.0 };
210 for( f = 0; f < (int)adj_faces.size(); f++ )
212 vnew[0] += fcentroids[3 * f + 0];
213 vnew[1] += fcentroids[3 * f + 1];
214 vnew[2] += fcentroids[3 * f + 2];
216 for( f = 0; f < 3; f++ )
217 vnew[f] /= adj_faces.size();
219 mxdelta = std::max( delta, mxdelta );
220 for( f = 0; f < 3; f++ )
221 vcentroids[3 * v + f] = vnew[f];
236 if( !( nit % report_its ) )
239 double global_max = mxdelta;
242 if( nprocs > 1 ) MPI_Reduce( &mxdelta, &global_max, 1, MPI_DOUBLE, MPI_MAX, 0, pcomm->
comm() );
243 myrank = pcomm->
rank();
245 if( 1 == nprocs || 0 == myrank ) cout <<
"Max delta = " << global_max << endl;