Пример #1
0
void post_process(MESH& m) {
  // HW4B: Post-processing step
  // Translate the triangle-averaged values to node-averaged values
  // Implement Equation 9 from your pseudocode here
  for (auto nit = m.node_begin(); nit != m.node_end(); ++nit) {
      double total_area = 0;
      QVar Q_tot(0, 0, 0);
      int count = 0;
  
      for (auto tri_it = m.adjacent_triangle_begin(*nit); tri_it != m.adjacent_triangle_end(*nit); ++tri_it) {
        Q_tot = Q_tot + (*tri_it).value() * (*tri_it).area();
        total_area += (*tri_it).area();
        ++count;
      }
      (*nit).value() = Q_tot / total_area;
  }
}