int main(int argc, char *argv[]){ double num[6][5]; double exa[6][5]; double *num_[6] = {&num[0][0],&num[1][0],&num[2][0],&num[3][0],&num[4][0],&num[5][0]}; double *exa_[6] = {&exa[0][0],&exa[1][0],&exa[2][0],&exa[3][0],&exa[4][0],&exa[5][0]}; for (int i = 0 ; i < 6 ; i++) for (int j = 0 ; j < 5 ; j++){ num[i][j] = i+j; exa[i][j] = i-j; } printf("NUM:\n"); array_print_2d(num_,6,5); printf("EXAC:\n"); array_print_2d(exa_,6,5); write_vtk(4,3,num_,exa_,"vtk_test_both"); write_vtk(4,3,num_,NULL,"vtk_test_num"); }
int main(int argc, char ** argv){ int i,j; Image * a; Image * b; Image * res; Image * res_den; Image * p_res; real saturation = 250; if(argc < 4){ printf("Usage: %s <saturation> <img1.h5> ... <imgN.h5>\n",argv[0]); return 0; } saturation = atof(argv[1]); for(j = 3;j<argc;j++){ a = read_imagefile(argv[j-1]); if(!res){ res = create_empty_img(a); res_den = create_empty_img(a); } b = read_imagefile(argv[j]); p_res = create_empty_img(a); if(sp_cmatrix_size(a->image) != sp_cmatrix_size(b->image)){ printf("Error: images should have the same dimensions!\n"); return 1; } for(i = 0;i<sp_cmatrix_size(a->image);i++){ if(b->image->data[i] && a->image->data[i] && creal(b->image->data[i]) < saturation && creal(a->image->data[i]) < saturation){ p_res->image->data[i] = a->image->data[i]/b->image->data[i]; res_den->image->data[i] += 1; }else{ p_res->image->data[i] = 0; } } add_image(res,p_res); freeimg(p_res); freeimg(a); freeimg(b); } for(i = 0;i<sp_cmatrix_size(res->image);i++){ if(res_den->image->data[i]){ res->image->data[i] /= res_den->image->data[i]; } } write_vtk(res,"analyze_image.vtk"); write_png(res,"analyze_image.png",COLOR_JET); return 0; }
int main (int argc, char** argv) /* ------------------------------------------------------------------------- * * Driver. * ------------------------------------------------------------------------- */ { char fname[STR_MAX]; char buf [STR_MAX]; FILE *fp, *fp_tec; fp_msh = stdin; strcpy(fname, "tmp.XXXXXX"); if ((fp = fdopen(mkstemp(fname), "w+")) == (FILE *) NULL) { fprintf (stderr, "sem2vtk: unable to open a temporary file\n"); exit (EXIT_FAILURE); } parse_args (argc, argv); read_mesh (fp_msh); while (dump--) read_data (fp_fld); interpolate (); wrap (); write_vtk (fp); if (preplot_it) { sprintf (buf, "preplot %s %s > /dev/null", fname, vtkfile); system (buf); remove (fname); } else { rewind (fp); fp_tec = fopen (vtkfile, "w"); while (fgets(buf, STR_MAX, fp)) fputs(buf, fp_tec); fclose (fp_tec); fclose (fp); } return EXIT_SUCCESS; }
void write_vtk(FILE * ht, double complex wi[], const double t) { // Write the data in the file handler *ht int i,j,k; float q0; DEBUG_START_FUNC; #ifdef MPI_SUPPORT double * chunk = NULL; if(rank==0) { chunk = (double *) malloc( NX * sizeof(double)); if (chunk == NULL) ERROR_HANDLER( ERROR_CRITICAL, "No memory for chunk allocation"); } #endif for( i = 0 ; i < NTOTAL_COMPLEX ; i++) { w1[i] = wi[i]; } gfft_c2r(w1); for( i = 0 ; i < 2 * NTOTAL_COMPLEX ; i++) { wr1[i] = wr1[i] / ((double) NTOTAL ); } #ifdef WITH_SHEAR remap_output(wr1,t); #endif #ifdef BOUNDARY_C for( k = 0 ; k < NZ / 2 ; k++) { #else for( k = 0 ; k < NZ; k++) { #endif for( j = 0; j < NY; j++) { #ifdef MPI_SUPPORT // We have to transpose manually to be Fortran compliant for(i = 0; i < NX/NPROC; i++) { wr2[i] = wr1[k + j * (NZ + 2) + i * NY * (NZ + 2) ]; // Transfer the chunk of data to wr2 } MPI_Gather(wr2, NX/NPROC, MPI_DOUBLE, chunk, NX/NPROC, MPI_DOUBLE, 0, MPI_COMM_WORLD); // Put the full chunk in chunk in the root process #endif for( i = 0; i < NX; i++) { #ifdef MPI_SUPPORT if(rank==0) { q0 = big_endian( (float) chunk[ i ] ); fwrite(&q0, sizeof(float), 1, ht); } #else #ifdef WITH_2D q0 = big_endian( (float) wr1[j + i * (NY + 2)] ); #else q0 = big_endian( (float) wr1[k + j * (NZ + 2) + i * NY * (NZ + 2) ] ); #endif fwrite(&q0, sizeof(float), 1, ht); if(ferror(ht)) ERROR_HANDLER( ERROR_CRITICAL, "Error writing VTK file"); #endif } #ifdef MPI_SUPPORT MPI_Barrier(MPI_COMM_WORLD); #endif } } #ifdef MPI_SUPPORT if(rank==0) free(chunk); #endif DEBUG_END_FUNC; return; } // Geo's personnal VTK writer, using structured data points /***********************************************************/ /** Output a legacy VTK file readable by Paraview. This routine will output all the variables in files data/v****.vtk. @param n Number of the file in which the output will done. @param t Current time of the simulation. */ /***********************************************************/ void output_vtk(struct Field fldi, const int n, double t) { FILE *ht = NULL; char filename[50]; int num_remain_field; int array_size, i; DEBUG_START_FUNC; sprintf(filename,"data/v%04i.vtk",n); #ifdef BOUNDARY_C array_size=NX*NY*NZ/2; // Remove half of the vertical direction for symmetry reason when using walls in z #else array_size=NX*NY*NZ; #endif if(rank==0) { ht=fopen(filename,"w"); fprintf(ht, "# vtk DataFile Version 2.0\n"); fprintf(ht, "t= %015.15e Snoopy Code v5.0\n",t); fprintf(ht, "BINARY\n"); fprintf(ht, "DATASET STRUCTURED_POINTS\n"); #ifdef BOUNDARY_C fprintf(ht, "DIMENSIONS %d %d %d\n", NX, NY, NZ / 2); #else fprintf(ht, "DIMENSIONS %d %d %d\n", NX, NY, NZ); #endif fprintf(ht, "ORIGIN %g %g %g\n", -param.lx/2.0, -param.ly/2.0, -param.lz/2.0); fprintf(ht, "SPACING %g %g %g\n", param.lx/NX, param.ly/NY, param.lz/NZ); // Write the primary scalar (f***ing VTK legacy format...) fprintf(ht, "POINT_DATA %d\n",array_size); fprintf(ht, "SCALARS %s float\n",fldi.fname[0]); fprintf(ht, "LOOKUP_TABLE default\n"); } write_vtk(ht,fldi.farray[0],t); num_remain_field = fldi.nfield - 1; // we have already written the first one if(param.output_vorticity) num_remain_field +=3; #ifndef MPI_SUPPORT #ifdef WITH_PARTICLES num_remain_field++; #endif #endif if(rank==0) fprintf(ht, "FIELD FieldData %d\n",num_remain_field); // Write all the remaining fields for(i = 1 ; i < fldi.nfield ; i++) { if(rank==0) fprintf(ht, "%s 1 %d float\n",fldi.fname[i],array_size); write_vtk(ht,fldi.farray[i],t); } if(param.output_vorticity) { // Compute the vorticity field for( i = 0 ; i < NTOTAL_COMPLEX ; i++) { w4[i] = I * (ky[i] * fldi.vz[i] - kz[i] * fldi.vy[i]); w5[i] = I * (kz[i] * fldi.vx[i] - kxt[i] * fldi.vz[i]); w6[i] = I * (kxt[i] * fldi.vy[i] - ky[i] * fldi.vx[i]); } if(rank==0) fprintf(ht, "wx 1 %d float\n",array_size); write_vtk(ht,w4,t); if(rank==0) fprintf(ht, "wy 1 %d float\n",array_size); write_vtk(ht,w5,t); if(rank==0) fprintf(ht, "wz 1 %d float\n",array_size); write_vtk(ht,w6,t); } #ifndef MPI_SUPPORT #ifdef WITH_PARTICLES if(rank==0) fprintf(ht, "particules 1 %d float\n",array_size); write_vtk_particles(fldi, ht, t); #endif #endif if(rank==0) { if(ferror(ht)) ERROR_HANDLER( ERROR_CRITICAL, "Error writing VTK file"); fclose(ht); } DEBUG_END_FUNC; return; }
int main() { Triangulation triangulation; boost::filesystem::path input_pathname = "C:/Carleton/CGAL-4.4/demo/Polyhedron/data/elephant.off"; // create_cubes(triangulation, 2, 2, 1 ); read_off( triangulation, input_pathname.string() ); // read_off(triangulation, "C:/Carleton/Meshes/holmes_off/geometry/octahedron.off"); // read_off(triangulation, "C:/Carleton/CGAL-4.4/demo/Polyhedron/data/cube.off"); // read_off(triangulation, "C:/Carleton/CGAL-4.4/demo/Polyhedron/data/ellipsoid.off"); #if 0 for (auto cell = triangulation.finite_cells_begin(); cell != triangulation.finite_cells_end(); ++cell) { for (int i = 0; i < 4; ++i) { Point p = cell->vertex(i)->point(); assert(-10.0 < p.x() && p.x() < +10.0); assert(-10.0 < p.y() && p.y() < +10.0); assert(-10.0 < p.z() && p.z() < +10.0); } } #endif set_cell_and_vertex_ids(triangulation); set_random_weights(triangulation); propagate_weights(triangulation); std::cout << "Number of finite vertices : " << triangulation.number_of_vertices() << std::endl; std::cout << "Number of finite edges : " << triangulation.number_of_finite_edges() << std::endl; std::cout << "Number of finite facets : " << triangulation.number_of_finite_facets() << std::endl; std::cout << "Number of finite cells : " << triangulation.number_of_finite_cells() << std::endl; std::string filename = input_pathname.filename().stem().string() + "_tet.vtk"; write_vtk( triangulation, filename ); if (triangulation.number_of_finite_cells() < 100) { dump_triangulation(triangulation); } Graph graph; create_steiner_points(graph,triangulation); // the distances are temporary, so we choose an external property for that std::vector<double> distances(num_vertices(graph)); std::vector<GraphNode_descriptor> predecessors(num_vertices(graph)); boost::dijkstra_shortest_paths( graph, *vertices(graph).first, boost::weight_map(get(&GraphEdge::weight, graph)). distance_map(boost::make_iterator_property_map(distances.begin(), get(boost::vertex_index, graph))). predecessor_map(boost::make_iterator_property_map(predecessors.begin(), get(boost::vertex_index, graph))) ); filename = input_pathname.filename().stem().string() + "_wsp.vtk"; write_shortest_path_vtk( graph, predecessors, distances, filename ); // write_graph_dot("graph.dot", graph); std::cout << "This is the end..." << std::endl; return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { FILE *ascii; struct Option *input, *output, *type_opt, *dp_opt, *layer_opt, *scale; struct Flag *coorcorr, *numatts, *labels; int itype, *types = NULL, typenum = 0, dp, i; struct Map_info Map; struct bound_box box; struct GModule *module; int layer, level; double zscale = 1.0, llscale = 1.0; G_gisinit(argv[0]); module = G_define_module(); G_add_keyword(_("vector")); G_add_keyword(_("export")); G_add_keyword("VTK"); module->description = _("Converts a vector map to VTK ASCII output."); input = G_define_standard_option(G_OPT_V_INPUT); output = G_define_standard_option(G_OPT_F_OUTPUT); output->required = NO; output->description = _("Name for output VTK file"); type_opt = G_define_standard_option(G_OPT_V_TYPE); type_opt->answer = "point,kernel,centroid,line,boundary,area,face"; type_opt->options = "point,kernel,centroid,line,boundary,area,face"; dp_opt = G_define_option(); dp_opt->key = "dp"; dp_opt->type = TYPE_INTEGER; dp_opt->required = NO; dp_opt->description = _("Number of significant digits (floating point only)"); scale = G_define_option(); scale->key = "scale"; scale->type = TYPE_DOUBLE; scale->required = NO; scale->description = _("Scale factor for elevation"); scale->answer = "1.0"; layer_opt = G_define_option(); layer_opt->key = "layer"; layer_opt->type = TYPE_INTEGER; layer_opt->required = NO; layer_opt->answer = "1"; layer_opt->description = _("Layer number"); coorcorr = G_define_flag(); coorcorr->key = 'c'; coorcorr->description = _("Correct the coordinates to fit the VTK-OpenGL precision"); numatts = G_define_flag(); numatts->key = 'n'; numatts->description = _("Export numeric attribute table fields as VTK scalar variables"); labels = NULL; /* to avoid compiler warning about "unused variable"*/ /* not yet supported labels = G_define_flag(); labels->key = 'l'; labels->description = _("Export text attribute table fields as VTK labels"); */ if (G_parser(argc, argv)) exit(EXIT_FAILURE); for (i = 0; type_opt->answers && type_opt->answers[i]; i++) typenum++; if (typenum > 0) { types = (int *)calloc(typenum, sizeof(int)); } else { G_fatal_error("Usage: Wrong vector type"); } i = 0; while (type_opt->answers[i]) { types[i] = -1; switch (type_opt->answers[i][0]) { case 'p': types[i] = GV_POINT; break; case 'k': types[i] = GV_KERNEL; break; case 'c': types[i] = GV_CENTROID; break; case 'l': types[i] = GV_LINE; break; case 'b': types[i] = GV_BOUNDARY; break; case 'a': types[i] = GV_AREA; break; case 'f': types[i] = GV_FACE; break; } i++; } itype = Vect_option_to_types(type_opt); /* read and compute the scale factor */ sscanf(scale->answer, "%lf", &zscale); /*if LL projection, convert the elevation values to degrees */ if (G_projection() == PROJECTION_LL) { llscale = M_PI / (180) * 6378137; zscale /= llscale; printf("Scale %g\n", zscale); } /*The precision of the output */ if (dp_opt->answer) { if (sscanf(dp_opt->answer, "%d", &dp) != 1) G_fatal_error(_("Failed to interpret 'dp' parameter as an integer")); if (dp > 8 || dp < 0) G_fatal_error(_("dp has to be from 0 to 8")); } else { dp = 8; /*This value is taken from the lib settings in G_feature_easting */ } /*The Layer */ if (layer_opt->answer) { if (sscanf(layer_opt->answer, "%d", &layer) != 1) G_fatal_error(_("Failed to interpret 'layer' parameter as an integer")); } else { layer = 1; } if (output->answer) { ascii = fopen(output->answer, "w"); if (ascii == NULL) { G_fatal_error(_("Unable to open file <%s>"), output->answer); } } else { ascii = stdout; } /* Open input vector */ level = Vect_open_old(&Map, input->answer, ""); if (level < 2 && (itype & GV_AREA)) G_fatal_error(_("Export of areas requires topology. " "Please adjust '%s' option or rebuild topology."), type_opt->key); if (level == 2) Vect_get_map_box(&Map, &box); else { int i, type, first = TRUE; struct line_pnts *Points = Vect_new_line_struct(); Vect_rewind(&Map); while ((type = Vect_read_next_line(&Map, Points, NULL)) > 0) { if (first) { box.E = box.W = Points->x[0]; box.N = box.S = Points->y[0]; box.B = box.T = Points->z[0]; first = FALSE; } for (i = 1; i < Points->n_points; i++) { if (Points->x[i] > box.E) box.E = Points->x[i]; else if (Points->x[i] < box.W) box.W = Points->x[i]; if (Points->y[i] > box.N) box.N = Points->y[i]; else if (Points->y[i] < box.S) box.S = Points->y[i]; if (Points->z[i] > box.T) box.T = Points->z[i]; else if (Points->z[i] < box.B) box.B = Points->z[i]; } } Vect_destroy_line_struct(Points); } /*Correct the coordinates, so the precision of VTK is not hurt :( */ if (coorcorr->answer) { /*Use the center of the vector's bbox as extent */ y_extent = (box.N + box.S) / 2; x_extent = (box.W + box.E) / 2; } else { x_extent = 0; y_extent = 0; } /*Write the header */ write_vtk_head(ascii, &Map); /*Write the geometry and data */ write_vtk(ascii, &Map, layer, types, typenum, dp, zscale, numatts->answer, 0 ); /* change to this, when labels get supported: write_vtk(ascii, &Map, layer, types, typenum, dp, zscale, numatts->answer, labels->answer ); */ if (ascii != NULL) fclose(ascii); Vect_close(&Map); exit(EXIT_SUCCESS); }
int main( int argc, char *argv[] ) { int Events[] = { #ifdef CACHE_PROFILE PAPI_L2_TCM, PAPI_L3_TCM, PAPI_L2_TCA, PAPI_L3_TCA #else PAPI_FP_OPS #endif }; long long values[SIZE( Events )]; long long tic; if( argc != 4 ) { printf( "Usage: %s input_format input_file output_prefix\n", argv[0] ); return EXIT_FAILURE; } char *input_format = argv[1]; char *input_file = argv[2]; char *output_prefix = argv[3]; int status = 0; /** internal cells start and end index*/ int nintci, nintcf; /** external cells start and end index. * The external cells are only ghost cells. They are accessed only through internal cells*/ int nextci, nextcf; /** link cell-to-cell array. Stores topology information*/ int **lcc; /** red-black colouring of the cells*/ int *nboard; /** boundary coefficients for each volume cell */ double *bs, *be, *bn, *bw, *bl, *bh, *bp, *su; char pstats_filename[strlen( output_prefix ) + strlen( "pstats.dat" ) + 1]; strcpy( pstats_filename, output_prefix ); strcat( pstats_filename, "pstats.dat" ); FILE *pstats = fopen( pstats_filename, "w" ); if( pstats == NULL ) { printf( "Cannot open file for writing: %s\n", pstats_filename ); return EXIT_FAILURE; } /* Start counting events */ if( PAPI_start_counters( Events, SIZE( Events ) ) != PAPI_OK ) { handle_error( 1 ); } /** start measuring wall clock time */ tic = PAPI_get_real_usec(); /* initialization */ // read-in the input file if( !strcmp( "bin", input_format ) ) { status = read_binary( input_file, &nintci, &nintcf, &nextci, &nextcf, &lcc, &bs, &be, &bn, &bw, &bl, &bh, &bp, &su, &nboard ); } else if( !strcmp( "text", input_format ) ) { status = read_formatted( input_file, &nintci, &nintcf, &nextci, &nextcf, &lcc, &bs, &be, &bn, &bw, &bl, &bh, &bp, &su, &nboard ); } else { printf( "valid input_format values: text, bin\n" ); return EXIT_FAILURE; } if( status != 0 ) { printf( "failed to initialize data!\n" ); return EXIT_FAILURE; } /* Print profile data for phase INPUT */ log_counters( pstats, "INPUT", &tic, values ); // allocate arrays used in gccg int nomax = 3; /** the reference residual*/ double resref = 0.0; /** the ratio between the reference and the current residual*/ double ratio; /** array storing residuals */ double *resvec = ( double * ) calloc( sizeof( double ), ( nintcf + 1 ) ); /** the variation vector -> keeps the result in the end */ double *var = ( double * ) calloc( sizeof( double ), ( nextcf + 1 ) ); /** the computation vectors */ double *direc1 = ( double * ) calloc( sizeof( double ), ( nextcf + 1 ) ); double *direc2 = ( double * ) calloc( sizeof( double ), ( nextcf + 1 ) ); /** additional vectors */ double *cgup = ( double * ) calloc( sizeof( double ), ( nextcf + 1 ) ); double *oc = ( double * ) calloc( sizeof( double ), ( nintcf + 1 ) ); double *cnorm = ( double * ) calloc( sizeof( double ), ( nintcf + 1 ) ); double *adxor1 = ( double * ) calloc( sizeof( double ), ( nintcf + 1 ) ); double *adxor2 = ( double * ) calloc( sizeof( double ), ( nintcf + 1 ) ); double *dxor1 = ( double * ) calloc( sizeof( double ), ( nintcf + 1 ) ); double *dxor2 = ( double * ) calloc( sizeof( double ), ( nintcf + 1 ) ); // initialize the reference residual for( int nc = nintci; nc <= nintcf; nc++ ) { resvec[nc] = su[nc]; resref = resref + resvec[nc] * resvec[nc]; } resref = sqrt( resref ); if( resref < 1.0e-15 ) { printf( "i/o - error: residue sum less than 1.e-15 - %lf\n", resref ); return EXIT_FAILURE; } // initialize the arrays for( int nc = 0; nc <= 10; nc++ ) { oc[nc] = 0.0; cnorm[nc] = 1.0; } for( int nc = nintci; nc <= nintcf; nc++ ) { cgup[nc] = 0.0; var[nc] = 0.0; } for( int nc = nextci; nc <= nextcf; nc++ ) { var[nc] = 0.0; cgup[nc] = 0.0; direc1[nc] = 0.0; bs[nc] = 0.0; be[nc] = 0.0; bn[nc] = 0.0; bw[nc] = 0.0; bl[nc] = 0.0; bh[nc] = 0.0; } for( int nc = nintci; nc <= nintcf; nc++ ) { cgup[nc] = 1.0 / bp[nc]; } int if1 = 0; int if2 = 0; int iter = 1; int nor = 1; int nor1 = nor - 1; /* finished initalization */ /* start computation loop */ while( iter < 10000 ) { /* start phase 1 */ // update the old values of direc for( int nc = nintci; nc <= nintcf; nc++ ) { direc1[nc] = direc1[nc] + resvec[nc] * cgup[nc]; } // compute new guess (approximation) for direc for( int nc = nintci; nc <= nintcf; nc++ ) { direc2[nc] = bp[nc] * direc1[nc] - bs[nc] * direc1[lcc[0][nc]] - bw[nc] * direc1[lcc[3][nc]] - bl[nc] * direc1[lcc[4][nc]] - bn[nc] * direc1[lcc[2][nc]] - be[nc] * direc1[lcc[1][nc]] - bh[nc] * direc1[lcc[5][nc]]; } /* end phase 1 */ /* start phase 2 */ // execute normalization steps double oc1, oc2, occ; if( nor1 == 1 ) { oc1 = 0; occ = 0; for( int nc = nintci; nc <= nintcf; nc++ ) { occ = occ + adxor1[nc] * direc2[nc]; } oc1 = occ / cnorm[1]; for( int nc = nintci; nc <= nintcf; nc++ ) { direc2[nc] = direc2[nc] - oc1 * adxor1[nc]; direc1[nc] = direc1[nc] - oc1 * dxor1[nc]; } if1++; } else if( nor1 == 2 ) { oc1 = 0; occ = 0; for( int nc = nintci; nc <= nintcf; nc++ ) { occ = occ + adxor1[nc] * direc2[nc]; } oc1 = occ / cnorm[1]; oc2 = 0; occ = 0; for( int nc = nintci; nc <= nintcf; nc++ ) { occ = occ + adxor2[nc] * direc2[nc]; } oc2 = occ / cnorm[2]; for( int nc = nintci; nc <= nintcf; nc++ ) { direc2[nc] = direc2[nc] - oc1 * adxor1[nc] - oc2 * adxor2[nc]; direc1[nc] = direc1[nc] - oc1 * dxor1[nc] - oc2 * dxor2[nc]; } if2++; } cnorm[nor] = 0; double omega = 0; // compute the new residual for( int nc = nintci; nc <= nintcf; nc++ ) { cnorm[nor] = cnorm[nor] + direc2[nc] * direc2[nc]; omega = omega + resvec[nc] * direc2[nc]; } omega = omega / cnorm[nor]; double resnew = 0.0; for( int nc = nintci; nc <= nintcf; nc++ ) { var[nc] = var[nc] + omega * direc1[nc]; resvec[nc] = resvec[nc] - omega * direc2[nc]; resnew = resnew + resvec[nc] * resvec[nc]; } resnew = sqrt( resnew ); ratio = resnew / resref; // exit on no improvements of residual if( ratio <= 1.0e-10 ) { break; } iter++; // prepare additional arrays for the next iteration step if( nor == nomax ) { nor = 1; } else { if( nor == 1 ) { for( int nc = nintci; nc <= nintcf; nc++ ) { dxor1[nc] = direc1[nc]; adxor1[nc] = direc2[nc]; } } else if( nor == 2 ) { for( int nc = nintci; nc <= nintcf; nc++ ) { dxor2[nc] = direc1[nc]; adxor2[nc] = direc2[nc]; } } nor++; } nor1 = nor - 1; }/* end phase 2 */ /* finished computation loop */ /* Print profile data for phase CALC */ log_counters( pstats, "CALC", &tic, values ); /* write output file */ int nodeCnt; int **points, **elems; if( vol2mesh( nintci, nintcf, lcc, &nodeCnt, &points, &elems ) != 0 ) { printf( "error during conversion from volume to mesh\n" ); } write_vtk( output_prefix, "VAR.vtk", nintci, nintcf, nodeCnt, points, elems, var ); write_vtk( output_prefix, "CGUP.vtk", nintci, nintcf, nodeCnt, points, elems, cgup ); write_vtk( output_prefix, "SU.vtk", nintci, nintcf, nodeCnt, points, elems, su ); /* Print profile data for phase OUTPUT */ log_counters( pstats, "OUTPUT", &tic, values ); /* Stop counting events */ if( PAPI_stop_counters( values, SIZE( values ) ) != PAPI_OK ) { handle_error( 1 ); } fclose( pstats ); #if 0 /* Free all the dynamically allocated memory */ free( direc2 ); free( direc1 ); free( dxor2 ); free( dxor1 ); free( adxor2 ); free( adxor1 ); free( cnorm ); free( oc ); free( var ); free( cgup ); free( resvec ); free( su ); free( bp ); free( bh ); free( bl ); free( bw ); free( bn ); free( be ); free( bs ); #endif printf( "Simulation completed successfully!\n" ); return EXIT_SUCCESS; }