bool make_statistic::generic_run()
  {
    typedef viennagrid::segmented_mesh<MeshT, SegmentationT> SegmentedMeshType;
    typename viennamesh::result_of::const_parameter_handle<SegmentedMeshType>::type imp = input_mesh.get<SegmentedMeshType>();
    if (imp)
    {
      typedef viennamesh::statistic<double> StatisticType;
      typedef typename viennagrid::result_of::cell<MeshT>::type CellType;
      output_parameter_proxy<StatisticType> osp(output_statistic);

      if (histogram_bins.valid())
      {
        osp().set_histogram( StatisticType::histogram_type::make(histogram_bins().begin(), histogram_bins().end()) );
      }
      else if (histogram_min.valid() && histogram_max.valid() && histogram_bin_count.valid())
      {
        osp().set_histogram( StatisticType::histogram_type::make_uniform(histogram_min(), histogram_max(), histogram_bin_count()) );
      }
      else
      {
        error(1) << "No histogram configuration provided" << std::endl;
        return false;
      }

      try
      {
        if (metric_type() == "aspect_ratio")
          osp()( imp().mesh, viennamesh::aspect_ratio<CellType> );
        else if (metric_type() == "condition_number")
          osp()( imp().mesh, viennamesh::condition_number<CellType> );
        else if (metric_type() == "min_angle")
          osp()( imp().mesh, viennamesh::min_angle<CellType> );
        else if (metric_type() == "max_angle")
          osp()( imp().mesh, viennamesh::max_angle<CellType> );
        else if (metric_type() == "min_dihedral_angle")
          osp()( imp().mesh, viennamesh::min_dihedral_angle<CellType> );
        else if (metric_type() == "radius_edge_ratio")
          osp()( imp().mesh, viennamesh::radius_edge_ratio<CellType> );
        else
        {
          error(1) << "Metric type \"" << metric_type() << "\" is not supported" << std::endl;
          return false;
        }
      }
      catch ( metric_not_implemented_or_supported_exception const & ex )
      {
        error(1) << "Metric type \"" << metric_type() << "\" is not supported" << std::endl;
        error(1) << ex.what() << std::endl;
      }

      info(5) << osp() << std::endl;

      return true;
    }

    return false;
  }
Exemplo n.º 2
0
std::ostream& operator<<(std::ostream& out, const ExceptionInfo& info) {
  out << "Exception type: ";
  if (info.type) {
    out << folly::demangle(*info.type);
  } else {
    out << "(unknown type)";
  }
  out << " (" << info.frames.size()
      << (info.frames.size() == 1 ? " frame" : " frames")
      << ")\n";
  try {
    size_t frameCount = info.frames.size();

    // Skip our own internal frames
    static constexpr size_t kInternalFramesNumber = 3;
    if (frameCount > kInternalFramesNumber) {
      auto addresses = info.frames.data() + kInternalFramesNumber;
      frameCount -= kInternalFramesNumber;

      std::vector<SymbolizedFrame> frames;
      frames.resize(frameCount);

      Symbolizer symbolizer;
      symbolizer.symbolize(addresses, frames.data(), frameCount);

      OStreamSymbolizePrinter osp(out, SymbolizePrinter::COLOR_IF_TTY);
      osp.println(addresses, frames.data(), frameCount);
    }
  } catch (const std::exception& e) {
    out << "\n !! caught " << folly::exceptionStr(e) << "\n";
  } catch (...) {
    out << "\n !!! caught unexpected exception\n";
  }
  return out;
}
Exemplo n.º 3
0
void printExceptionInfo(
    std::ostream& out,
    const ExceptionInfo& info,
    int options) {
  out << "Exception type: ";
  if (info.type) {
    out << folly::demangle(*info.type);
  } else {
    out << "(unknown type)";
  }
  out << " (" << info.frames.size()
      << (info.frames.size() == 1 ? " frame" : " frames")
      << ")\n";
  try {
    size_t frameCount = info.frames.size();

    // Skip our own internal frames
    static constexpr size_t kInternalFramesNumber = 3;
    if (frameCount > kInternalFramesNumber) {
      auto addresses = info.frames.data() + kInternalFramesNumber;
      frameCount -= kInternalFramesNumber;

      std::vector<SymbolizedFrame> frames;
      frames.resize(frameCount);

      Symbolizer symbolizer(
          (options & SymbolizePrinter::NO_FILE_AND_LINE)
              ? Dwarf::LocationInfoMode::DISABLED
              : Symbolizer::kDefaultLocationInfoMode);
      symbolizer.symbolize(addresses, frames.data(), frameCount);

      OStreamSymbolizePrinter osp(out, options);
      osp.println(addresses, frames.data(), frameCount);
    }
  } catch (const std::exception& e) {
    out << "\n !! caught " << folly::exceptionStr(e) << "\n";
  } catch (...) {
    out << "\n !!! caught unexpected exception\n";
  }
}