58 #ifdef MOAB_HAVE_MBCOUPLER
62 #error Requires MOAB to be built with MBCoupler
73 double out = sin( M_PI * x ) * cos( M_PI * y ) * sin( M_PI * z );
78 int main(
int argc,
char* argv[] )
80 int proc_id = 0, size = 1;
82 MPI_Init( &argc, &argv );
83 MPI_Comm_rank( MPI_COMM_WORLD, &proc_id );
84 MPI_Comm_size( MPI_COMM_WORLD, &size );
91 opts.
A = opts.
B = opts.
C = 1;
92 opts.
M = opts.
N = opts.
K = 1;
104 popts.
addOpt<
int >( string(
"blockSize,b" ), string(
"Block size of mesh (default=4)" ), &opts.
blockSize );
105 popts.
addOpt<
int >( string(
"xproc,M" ), string(
"Number of processors in x dir (default=1)" ), &opts.
M );
106 popts.
addOpt<
int >( string(
"yproc,N" ), string(
"Number of processors in y dir (default=1)" ), &opts.
N );
107 popts.
addOpt<
int >( string(
"zproc,K" ), string(
"Number of processors in z dir (default=1)" ), &opts.
K );
109 popts.
addOpt<
int >( string(
"xblocks,A" ), string(
"Number of blocks on a task in x dir (default=2)" ), &opts.
A );
110 popts.
addOpt<
int >( string(
"yblocks,B" ), string(
"Number of blocks on a task in y dir (default=2)" ), &opts.
B );
111 popts.
addOpt<
int >( string(
"zblocks,C" ), string(
"Number of blocks on a task in x dir (default=2)" ), &opts.
C );
113 popts.
addOpt<
double >( string(
"xsize,x" ), string(
"Total size in x direction (default=1.)" ), &opts.
xsize );
114 popts.
addOpt<
double >( string(
"ysize,y" ), string(
"Total size in y direction (default=1.)" ), &opts.
ysize );
115 popts.
addOpt<
double >( string(
"zsize,z" ), string(
"Total size in z direction (default=1.)" ), &opts.
zsize );
119 popts.
addOpt<
void >(
"quadratic,q",
"use hex 27 elements", &opts.
quadratic );
121 popts.
addOpt<
void >(
"keep_skins,k",
"keep skins with shared entities", &opts.
keep_skins );
123 popts.
addOpt<
void >(
"tetrahedrons,t",
"generate tetrahedrons", &opts.
tetra );
125 popts.
addOpt<
void >(
"faces_edges,f",
"create all faces and edges", &opts.
adjEnts );
127 popts.
addOpt<
int >( string(
"ghost_layers,g" ), string(
"Number of ghost layers (default=0)" ), &opts.
GL );
129 popts.
addOpt<
void >(
"parallel_merge,p",
"use parallel mesh merge, not vertex ID based merge", &opts.
parmerge );
133 double toler = 1.e-6;
134 popts.
addOpt<
double >( string(
"eps,e" ), string(
"tolerance for coupling, used in locating points" ), &toler );
136 bool writeMeshes =
false;
137 popts.
addOpt<
void >(
"print,p",
"write meshes", &writeMeshes );
151 double instance_time = MPI_Wtime();
152 double current = instance_time;
153 if( !proc_id ) std::cout <<
" instantiate first mesh " << instance_time -
start_time <<
"\n";
155 std::string interpTag(
"interp_tag" );
170 double fieldValue =
physField( vertPos[0], vertPos[1], vertPos[2] );
175 double setTag_time = MPI_Wtime();
176 if( !proc_id ) std::cout <<
" set tag " << setTag_time - current;
177 current = instance_time;
190 double instance_second = MPI_Wtime();
191 if( !proc_id ) std::cout <<
" instance second mesh" << instance_second - current <<
"\n";
192 current = instance_second;
199 "Can't write in parallel mesh 1" );
202 "Can't write in parallel mesh 1" );
203 double write_files = MPI_Wtime();
204 if( !proc_id ) std::cout <<
" write files " << write_files - current <<
"\n";
205 current = write_files;
211 double instancecoupler = MPI_Wtime();
212 if( !proc_id ) std::cout <<
" instance coupler " << instancecoupler - current <<
"\n";
213 current = instancecoupler;
218 std::vector< double > vpos;
219 int numPointsOfInterest = 0;
231 targ_verts =
subtract( targ_verts, tmp_verts );
233 numPointsOfInterest = (int)targ_verts.
size();
234 vpos.resize( 3 * targ_verts.
size() );
240 double locatetime = MPI_Wtime();
241 if( !proc_id ) std::cout <<
" locate points: " << locatetime - current <<
"\n";
242 current = locatetime;
245 std::vector< double > field( numPointsOfInterest );
251 for(
int i = 0; i < numPointsOfInterest; i++ )
253 double trval =
physField( vpos[3 * i], vpos[3 * i + 1], vpos[3 * i + 2] );
254 double err2 = fabs( trval - field[i] );
255 if( err2 > err_max ) err_max = err2;
258 double interpolateTime = MPI_Wtime();
259 if( !proc_id ) std::cout <<
" interpolate points: " << interpolateTime - current <<
"\n";
260 current = interpolateTime;
263 MPI_Allreduce( &err_max, &gerr, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD );
264 if( 0 == proc_id ) std::cout <<
"max err " << gerr <<
"\n";