12 #include <stk_algsup/AlgorithmRunner.hpp> 20 #include <stk_mesh/base/BulkData.hpp> 21 #include <stk_mesh/base/Bucket.hpp> 22 #include <stk_mesh/base/GetBuckets.hpp> 30 const mesh::Selector & selector ;
32 const std::vector<mesh::Bucket*> & buckets ;
33 const AlgorithmInterface & alg ;
35 RunTPI(
const mesh::Selector & arg_selector ,
37 const std::vector<mesh::Bucket*> & arg_buckets ,
38 const AlgorithmInterface & arg_alg )
39 : selector( arg_selector ),
40 union_parts(arg_union_parts),
41 buckets( arg_buckets ),
51 static void RunTPI_join( TPI_Work * work ,
const void * reduce )
53 const RunTPI & myself = * ((
const RunTPI *) work->info );
55 myself.alg.join( work->reduce , reduce );
58 static void RunTPI_init( TPI_Work * work )
60 const RunTPI & myself = * ((
const RunTPI *) work->info );
62 myself.alg.init( work->reduce );
65 static void RunTPI_apply( TPI_Work * work )
67 const RunTPI & myself = * ((
const RunTPI *) work->info );
69 myself.alg.apply_one( myself.selector ,
71 * myself.buckets[ work->rank ] ,
78 class AlgorithmRunnerTPI :
public AlgorithmRunnerInterface {
81 void run_alg(
const mesh::Selector & selector ,
83 const std::vector< mesh::Bucket * > & buckets ,
84 const AlgorithmInterface & alg ,
85 void * reduce )
const ;
87 AlgorithmRunnerTPI(
int nthreads ) : result( 0 <= TPI_Init( nthreads ) ) {}
92 void AlgorithmRunnerTPI::run_alg(
93 const mesh::Selector & selector ,
95 const std::vector< mesh::Bucket * > & buckets ,
96 const AlgorithmInterface & alg ,
99 if ( reduce && ! alg.m_reduce_allocation_size ) {
100 std::string msg(
"AlgorithmRunnerTPI: ERROR reduce value with zero size");
101 throw std::invalid_argument(msg);
104 if ( ! buckets.empty() ) {
106 RunTPI tmp( selector, union_parts, buckets , alg );
109 TPI_Run_reduce( RunTPI_apply , & tmp ,
113 alg.m_reduce_allocation_size ,
117 TPI_Run( RunTPI_apply , & tmp , buckets.size() , 0 );
128 static AlgorithmRunnerTPI runner( nthreads );
130 return runner.result ? & runner : NULL ;
AlgorithmRunnerInterface * algorithm_runner_tpi(int nthreads)
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.