18 : mbImpl( impl ), myPcomm( pc ), myElems( elms ), coordsTag( ctag ), fixedTag( ftag ), absTol( at ), relTol( rt ),
19 reportIts( 0 ), numIts( 0 ), iCreatedTag( false )
37 MB_SET_ERR( MB_FAILURE,
"No elements specified to Lloyd smoother" );
41 MB_SET_ERR( MB_FAILURE,
"Elements of unequal dimension specified to Lloyd smoother" );
67 std::vector< double > vcentroids( 3 * verts.
size() );
81 Range owned_verts, shared_owned_verts;
91 if( shared_owned_verts.
empty() ) shared_owned_verts.
insert( *verts.
begin() );
99 std::vector< unsigned char > fix_tag( owned_verts.
size() );
104 vcentroids.resize( 3 * owned_verts.
size() );
108 std::vector< double > fcentroids( 3 *
myElems.
size() );
109 std::vector< double > ctag(
115 std::vector< EntityHandle > adj_elems;
118 double resid = DBL_MAX;
132 fcentroids[3 * e + 0] = fcentroids[3 * e + 1] = fcentroids[3 * e + 2] = 0.0;
133 for( v = 0; v < nconn; v++ )
135 fcentroids[3 * e + 0] += ctag[3 * v + 0];
136 fcentroids[3 * e + 1] += ctag[3 * v + 1];
137 fcentroids[3 * e + 2] += ctag[3 * v + 2];
139 for( v = 0; v < 3; v++ )
140 fcentroids[3 * e + v] /= nconn;
145 for( vit = owned_verts.
begin(), v = 0; vit != owned_verts.
end(); ++vit, v++ )
148 if( fix_tag[v] )
continue;
153 double vnew[] = { 0.0, 0.0, 0.0 };
154 for( e = 0; e < (int)adj_elems.size(); e++ )
156 vnew[0] += fcentroids[3 * e + 0];
157 vnew[1] += fcentroids[3 * e + 1];
158 vnew[2] += fcentroids[3 * e + 2];
160 for( e = 0; e < 3; e++ )
161 vnew[e] /= adj_elems.size();
163 resid = ( v ? std::max( resid, delta ) : delta );
164 for( e = 0; e < 3; e++ )
165 vcentroids[3 * v + e] = vnew[e];
182 double global_max = resid;
186 MPI_Reduce( &resid, &global_max, 1, MPI_DOUBLE, MPI_MAX, 0,
myPcomm->
comm() );
189 std::cout <<
"Max residual = " << global_max << std::endl;
214 unsigned char fixed = 0x0;
220 Range skin, skin_verts;
235 std::vector< unsigned char > marks( skin_verts.
size(), 0x1 );