コード例 #1
0
ファイル: Monitor.cpp プロジェクト: bkkrueger/toy_hydro
   void write_to_monitor() {

      // ----------------------------------------------------------------------
      // Compute quantities to be monitored

      mout << "  " << std::setw(13) << std::scientific << Driver::time;

#ifdef MONITOR_CONVERGENCE
      double L1 = 0;
      double L2 = 0;
      double Linf = 0;
      double resid;
      for (int i = Grid::Ng; i < Grid::Ng+Grid::Nx; i++) {
         try{
         resid = std::abs(Grid::data[i] - analytic_solution(Grid::x[i]));
         } catch (std::out_of_range &e) {
            std::cerr << "error in analytic_solution" << std::endl;
            throw;
         }
         L1 += resid;
         L2 += std::pow(resid, 2);
         if (resid > Linf) {
            Linf = resid;
         }
      }
      L2 = std::sqrt(L2);
      mout << "   " << std::setw(13) << std::scientific << L1;
      mout << "   " << std::setw(13) << std::scientific << L2;
      mout << "   " << std::setw(13) << std::scientific << Linf;
#endif // end ifdef MONITOR_CONVERGENCE

      mout << std::endl;

   }
コード例 #2
0
ファイル: main.c プロジェクト: robertdfrench/ode-to-joy
void populate_analytic_solution(OTJ_Grid g, Stepsize h, int tau) {
	int i,j;
	for (i = 0; i < g.len_x; i++) {
		for (j = 0; j < g.len_y; j++) {
			OTJ_Grid_Element(g,i,j) = analytic_solution(h.x * i, h.y * j, h.t * tau);
		}
	}
}