34 int main(
int argc,
char* argv[] )
36 std::stringstream sstr;
40 int rank = 0, size = 1;
42 MPI_Init( &argc, &argv );
43 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
44 MPI_Comm_size( MPI_COMM_WORLD, &size );
47 std::string sourceFile, targetFile, intxFile;
48 std::string source_verif(
"outS.h5m" ), target_verif(
"outt.h5m" );
50 int oldNamesParents = 0;
51 double areaErrSource = -1;
52 double areaErrTarget = -1;
55 opts.
addOpt< std::string >(
"source,s",
"source file ", &sourceFile );
56 opts.
addOpt< std::string >(
"target,t",
"target file ", &targetFile );
57 opts.
addOpt< std::string >(
"intersection,i",
"intersection file ", &intxFile );
58 opts.
addOpt< std::string >(
"verif_source,v",
"output source verification ", &source_verif );
59 opts.
addOpt< std::string >(
"verif_target,w",
"output target verification ", &target_verif );
60 opts.
addOpt<
double >(
"threshold_source,m",
"error source threshold ", &areaErrSource );
61 opts.
addOpt<
double >(
"threshold_target,q",
"error target threshold ", &areaErrTarget );
63 opts.
addOpt<
int >(
"sphere,p",
"mesh on a sphere", &sphere );
64 opts.
addOpt<
int >(
"old_convention,n",
"old names for parent tags", &oldNamesParents );
68 std::string opts_read = ( size == 1 ?
""
69 : std::string(
"PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION" ) +
70 std::string(
";PARALLEL_RESOLVE_SHARED_ENTS" ) );
82 if( 0 == rank ) std::cout <<
"Loading source file " << sourceFile <<
"\n";
84 if( 0 == rank ) std::cout <<
"Loading target file " << targetFile <<
"\n";
87 if( 0 == rank ) std::cout <<
"Loading intersection file " << intxFile <<
"\n";
107 if( oldNamesParents )
124 std::map< int, double > sourceAreas;
125 std::map< int, double > targetAreas;
127 std::map< int, double > sourceAreasIntx;
128 std::map< int, double > targetAreasIntx;
130 std::map< int, int > sourceNbIntx;
131 std::map< int, int > targetNbIntx;
133 std::map< int, EntityHandle > sourceMap;
134 std::map< int, EntityHandle > targetMap;
142 Range non_convex_intx_cells;
150 std::vector< double > coords( 3 * num_nodes );
157 sourceAreas[sourceID] = area;
159 sourceMap[sourceID] = cell;
168 std::vector< double > coords( 3 * num_nodes );
175 targetAreas[targetID] = area;
177 targetMap[targetID] = cell;
187 std::vector< double > coords( 3 * num_nodes );
195 int sourceID, targetID;
199 std::map< int, double >::iterator sit = sourceAreasIntx.find( sourceID );
200 if( sit == sourceAreasIntx.end() )
202 sourceAreasIntx[sourceID] = intx_area;
203 sourceNbIntx[sourceID] = 1;
207 sourceAreasIntx[sourceID] += intx_area;
208 sourceNbIntx[sourceID]++;
211 std::map< int, double >::iterator tit = targetAreasIntx.find( targetID );
212 if( tit == targetAreasIntx.end() )
214 targetAreasIntx[targetID] = intx_area;
215 targetNbIntx[targetID] = 1;
219 targetAreasIntx[targetID] += intx_area;
220 targetNbIntx[targetID]++;
224 std::cout <<
"negative intx area: " << intx_area <<
" n:" << num_nodes <<
" parents: " << sourceID <<
" "
229 non_convex_intx_cells.
insert( cell );
230 std::cout <<
" non-convex polygon: " << intx_area <<
" n:" << num_nodes <<
" parents: " << sourceID <<
" "
237 Tag countIntxCellsTag;
246 double areaDiff = sourceAreas[sourceID];
247 std::map< int, double >::iterator sit = sourceAreasIntx.find( sourceID );
248 int countIntxCells = 0;
249 if( sit != sourceAreasIntx.end() )
251 areaDiff -= sourceAreasIntx[sourceID];
252 countIntxCells = sourceNbIntx[sourceID];
255 rval =
mb->
tag_set_data( countIntxCellsTag, &cell, 1, &countIntxCells );
257 if( ( areaErrSource > 0 ) && ( fabs( areaDiff ) > areaErrSource ) )
262 if( 0 == rank ) std::cout <<
"write source verification file " << source_verif <<
"\n";
264 if( areaErrSource > 0 )
266 Range sourceErrorCells;
270 if( !sourceErrorCells.
empty() )
273 std::vector< int > sourceIDs;
274 sourceIDs.resize( sourceErrorCells.
size() );
276 std::sort( sourceIDs.begin(), sourceIDs.end() );
282 std::vector< int >::iterator j = std::lower_bound( sourceIDs.begin(), sourceIDs.end(), sourceID );
283 if( ( j != sourceIDs.end() ) && ( *j == sourceID ) )
288 std::string filtersource = std::string(
"filt_" ) + source_verif;
289 rval =
mb->
write_file( filtersource.c_str(), 0, 0, &errorSourceSet, 1 );
290 std::string filterIntxsource = std::string(
"filtIntx_" ) + source_verif;
291 rval =
mb->
write_file( filterIntxsource.c_str(), 0, 0, &errorSourceIntxSet, 1 );
301 double areaDiff = targetAreas[targetID];
302 int countIntxCells = 0;
303 std::map< int, double >::iterator sit = targetAreasIntx.find( targetID );
304 if( sit != targetAreasIntx.end() )
306 areaDiff -= targetAreasIntx[targetID];
307 countIntxCells = targetNbIntx[targetID];
311 rval =
mb->
tag_set_data( countIntxCellsTag, &cell, 1, &countIntxCells );
313 if( ( areaErrTarget > 0 ) && ( fabs( areaDiff ) > areaErrTarget ) )
318 if( 0 == rank ) std::cout <<
"write target verification file " << target_verif <<
"\n";
320 if( areaErrTarget > 0 )
322 Range targetErrorCells;
324 if( !targetErrorCells.
empty() )
329 std::vector< int > targetIDs;
330 targetIDs.resize( targetErrorCells.
size() );
332 std::sort( targetIDs.begin(), targetIDs.end() );
338 std::vector< int >::iterator j = std::lower_bound( targetIDs.begin(), targetIDs.end(), targetID );
339 if( ( j != targetIDs.end() ) && ( *j == targetID ) )
344 std::string filterTarget = std::string(
"filt_" ) + target_verif;
345 rval =
mb->
write_file( filterTarget.c_str(), 0, 0, &errorTargetSet, 1 );
346 std::string filterIntxtarget = std::string(
"filtIntx_" ) + target_verif;
347 rval =
mb->
write_file( filterIntxtarget.c_str(), 0, 0, &errorTargetIntxSet, 1 );
351 if( !non_convex_intx_cells.
empty() )
359 int sourceID, targetID;
362 sourceCells.
insert( sourceMap[sourceID] );
363 targetCells.
insert( targetMap[targetID] );