void write_metrics_as_csv(fixedgrid_t* G, char* platform) { uint32_t i, steps; metrics_t avg; FILE* fptr; char fname[255]; steps = (G->tend - G->tstart) / G->dt; // Build file name sprintf(fname, "%s/METRICS_%03d_%02d.csv", OUTPUT_DIR, RUN_ID, G->nprocs); // Write to new file if((fptr = (FILE*)fopen(fname, "w")) != NULL) { // Write header fprintf(fptr, "Platform:,%s,\n", platform); fprintf(fptr, "NPROCS:,%d,\n", G->nprocs); fprintf(fptr, "NX:,%d,\n", NX); fprintf(fptr, "NY:,%d,\n", NY); fprintf(fptr, "NZ:,%d,\n", NZ); fprintf(fptr, "NSPEC:,%d,\n", NSPEC); fprintf(fptr, "Steps:,%d,\n", steps); fprintf(fptr, ",\n"); // Write metrics write_metrics_to_csv_file(&G->ppe_metrics, fptr); avg = average_metrics(G); write_metrics_to_csv_file(&avg, fptr); for(i=0; i<G->nprocs; i++) { write_metrics_to_csv_file(&G->threads[i].metrics, fptr); } fclose(fptr); } else { fprintf(stderr, "Couldn't open file \"%s\" for writing.", fname); exit(1); } printf("Metrics stored to file: %s\n", fname); }
bool IdealWeightInverseMeanRatio::evaluate( PatchData& pd, size_t handle, double& m, MsqError& err ) { const MsqMeshEntity* e = &pd.element_by_index(handle); EntityTopology topo = e->get_element_type(); const MsqVertex *vertices = pd.get_vertex_array(err); MSQ_ERRZERO(err); const size_t *v_i = e->get_vertex_index_array(); Vector3D n; // Surface normal for 2D objects // Prism and Hex element descriptions static const int locs_pri[6][4] = {{0, 1, 2, 3}, {1, 2, 0, 4}, {2, 0, 1, 5}, {3, 5, 4, 0}, {4, 3, 5, 1}, {5, 4, 3, 2}}; static const int locs_hex[8][4] = {{0, 1, 3, 4}, {1, 2, 0, 5}, {2, 3, 1, 6}, {3, 0, 2, 7}, {4, 7, 5, 0}, {5, 4, 6, 1}, {6, 5, 7, 2}, {7, 6, 4, 3}}; const Vector3D d_con(1.0, 1.0, 1.0); int i; m = 0.0; bool metric_valid = false; switch(topo) { case TRIANGLE: pd.get_domain_normal_at_element(e, n, err); MSQ_ERRZERO(err); n = n / n.length(); // Need unit normal mCoords[0] = vertices[v_i[0]]; mCoords[1] = vertices[v_i[1]]; mCoords[2] = vertices[v_i[2]]; metric_valid = m_fcn_2e(m, mCoords, n, a2Con, b2Con, c2Con); if (!metric_valid) return false; break; case QUADRILATERAL: pd.get_domain_normal_at_element(e, n, err); MSQ_ERRZERO(err); n = n / n.length(); // Need unit normal for (i = 0; i < 4; ++i) { mCoords[0] = vertices[v_i[locs_hex[i][0]]]; mCoords[1] = vertices[v_i[locs_hex[i][1]]]; mCoords[2] = vertices[v_i[locs_hex[i][2]]]; metric_valid = m_fcn_2i(mMetrics[i], mCoords, n, a2Con, b2Con, c2Con, d_con); if (!metric_valid) return false; } m = average_metrics(mMetrics, 4, err); break; case TETRAHEDRON: mCoords[0] = vertices[v_i[0]]; mCoords[1] = vertices[v_i[1]]; mCoords[2] = vertices[v_i[2]]; mCoords[3] = vertices[v_i[3]]; metric_valid = m_fcn_3e(m, mCoords, a3Con, b3Con, c3Con); if (!metric_valid) return false; break; case PYRAMID: for (i = 0; i < 4; ++i) { mCoords[0] = vertices[v_i[ i ]]; mCoords[1] = vertices[v_i[(i+1)%4]]; mCoords[2] = vertices[v_i[(i+3)%4]]; mCoords[3] = vertices[v_i[ 4 ]]; metric_valid = m_fcn_3p(mMetrics[i], mCoords, a3Con, b3Con, c3Con); if (!metric_valid) return false; } m = average_metrics(mMetrics, 4, err); MSQ_ERRZERO(err); break; case PRISM: for (i = 0; i < 6; ++i) { mCoords[0] = vertices[v_i[locs_pri[i][0]]]; mCoords[1] = vertices[v_i[locs_pri[i][1]]]; mCoords[2] = vertices[v_i[locs_pri[i][2]]]; mCoords[3] = vertices[v_i[locs_pri[i][3]]]; metric_valid = m_fcn_3w(mMetrics[i], mCoords, a3Con, b3Con, c3Con); if (!metric_valid) return false; } m = average_metrics(mMetrics, 6, err); MSQ_ERRZERO(err); break; case HEXAHEDRON: for (i = 0; i < 8; ++i) { mCoords[0] = vertices[v_i[locs_hex[i][0]]]; mCoords[1] = vertices[v_i[locs_hex[i][1]]]; mCoords[2] = vertices[v_i[locs_hex[i][2]]]; mCoords[3] = vertices[v_i[locs_hex[i][3]]]; metric_valid = m_fcn_3i(mMetrics[i], mCoords, a3Con, b3Con, c3Con, d_con); if (!metric_valid) return false; } m = average_metrics(mMetrics, 8, err); MSQ_ERRZERO(err); break; default: MSQ_SETERR(err)(MsqError::UNSUPPORTED_ELEMENT, "Element type (%d) not supported in IdealWeightInverseMeanRatio", (int)topo); return false; } // end switch over element type return true; }