59 int proc_id = 0,
size = 1;
61 MPI_Init( &argc, &argv );
62 MPI_Comm_rank( MPI_COMM_WORLD, &proc_id );
63 MPI_Comm_size( MPI_COMM_WORLD, &
size );
70 opts.
A = opts.
B = opts.
C = 1;
71 opts.
M = opts.
N = opts.
K = 1;
83 popts.
addOpt<
int >( string(
"blockSize,b" ), string(
"Block size of mesh (default=4)" ), &opts.
blockSize );
84 popts.
addOpt<
int >( string(
"xproc,M" ), string(
"Number of processors in x dir (default=1)" ), &opts.
M );
85 popts.
addOpt<
int >( string(
"yproc,N" ), string(
"Number of processors in y dir (default=1)" ), &opts.
N );
86 popts.
addOpt<
int >( string(
"zproc,K" ), string(
"Number of processors in z dir (default=1)" ), &opts.
K );
88 popts.
addOpt<
int >( string(
"xblocks,A" ), string(
"Number of blocks on a task in x dir (default=2)" ), &opts.
A );
89 popts.
addOpt<
int >( string(
"yblocks,B" ), string(
"Number of blocks on a task in y dir (default=2)" ), &opts.
B );
90 popts.
addOpt<
int >( string(
"zblocks,C" ), string(
"Number of blocks on a task in x dir (default=2)" ), &opts.
C );
92 popts.
addOpt<
double >( string(
"xsize,x" ), string(
"Total size in x direction (default=1.)" ), &opts.
xsize );
93 popts.
addOpt<
double >( string(
"ysize,y" ), string(
"Total size in y direction (default=1.)" ), &opts.
ysize );
94 popts.
addOpt<
double >( string(
"zsize,z" ), string(
"Total size in z direction (default=1.)" ), &opts.
zsize );
98 popts.
addOpt<
void >(
"quadratic,q",
"use hex 27 elements", &opts.
quadratic );
100 popts.
addOpt<
void >(
"keep_skins,k",
"keep skins with shared entities", &opts.
keep_skins );
102 popts.
addOpt<
void >(
"tetrahedrons,t",
"generate tetrahedrons", &opts.
tetra );
104 popts.
addOpt<
void >(
"faces_edges,f",
"create all faces and edges", &opts.
adjEnts );
106 popts.
addOpt<
int >( string(
"ghost_layers,g" ), string(
"Number of ghost layers (default=0)" ), &opts.
GL );
108 popts.
addOpt<
void >(
"parallel_merge,p",
"use parallel mesh merge, not vertex ID based merge", &opts.
parmerge );
112 double toler = 1.e-6;
113 popts.
addOpt<
double >( string(
"eps,e" ), string(
"tolerance for coupling, used in locating points" ), &toler );
115 bool writeMeshes =
false;
116 popts.
addOpt<
void >(
"print,p",
"write meshes", &writeMeshes );
130 double instance_time = MPI_Wtime();
131 double current = instance_time;
132 if( !proc_id ) std::cout <<
" instantiate first mesh " << instance_time -
start_time <<
"\n";
134 std::string interpTag(
"interp_tag" );
149 double fieldValue =
physField( vertPos[0], vertPos[1], vertPos[2] );
154 double setTag_time = MPI_Wtime();
155 if( !proc_id ) std::cout <<
" set tag " << setTag_time - current;
156 current = instance_time;
169 double instance_second = MPI_Wtime();
170 if( !proc_id ) std::cout <<
" instance second mesh" << instance_second - current <<
"\n";
171 current = instance_second;
176 rval =
mb->
write_file(
"mesh1.h5m", 0,
";;PARALLEL=WRITE_PART;CPUTIME;PARALLEL_COMM=0;", &fileset1, 1 );
MB_CHK_SET_ERR( rval,
"Can't write in parallel mesh 1" );
177 rval =
mb->
write_file(
"mesh2.h5m", 0,
";;PARALLEL=WRITE_PART;CPUTIME;PARALLEL_COMM=1;", &fileset2, 1 );
MB_CHK_SET_ERR( rval,
"Can't write in parallel mesh 1" );
178 double write_files = MPI_Wtime();
179 if( !proc_id ) std::cout <<
" write files " << write_files - current <<
"\n";
180 current = write_files;
186 double instancecoupler = MPI_Wtime();
187 if( !proc_id ) std::cout <<
" instance coupler " << instancecoupler - current <<
"\n";
188 current = instancecoupler;
193 std::vector< double > vpos;
194 int numPointsOfInterest = 0;
206 targ_verts =
subtract( targ_verts, tmp_verts );
208 numPointsOfInterest = (int)targ_verts.
size();
209 vpos.resize( 3 * targ_verts.
size() );
213 rval = mbc.locate_points( &vpos[0], numPointsOfInterest, 0, toler );
MB_CHK_ERR( rval );
215 double locatetime = MPI_Wtime();
216 if( !proc_id ) std::cout <<
" locate points: " << locatetime - current <<
"\n";
217 current = locatetime;
220 std::vector< double > field( numPointsOfInterest );
222 rval = mbc.interpolate( method, interpTag, &field[0] );
MB_CHK_ERR( rval );
226 for(
int i = 0; i < numPointsOfInterest; i++ )
228 double trval =
physField( vpos[3 * i], vpos[3 * i + 1], vpos[3 * i + 2] );
229 double err2 = fabs( trval - field[i] );
230 if( err2 > err_max ) err_max = err2;
233 double interpolateTime = MPI_Wtime();
234 if( !proc_id ) std::cout <<
" interpolate points: " << interpolateTime - current <<
"\n";
235 current = interpolateTime;
238 MPI_Allreduce( &err_max, &gerr, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD );
239 if( 0 == proc_id ) std::cout <<
"max err " << gerr <<
"\n";