Changeset c8c9f0


Ignore:
Timestamp:
Apr 19, 2013, 8:41:55 PM (13 years ago)
Author:
Julian Iseringhausen <isering@…>
Children:
8b2e07
Parents:
6f7f90
Message:

Added error output to sine testing interface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/interfaces/interface_sinus.cpp

    r6f7f90 rc8c9f0  
    5959void InterfaceSinus::ExportSolution(Grid& grid)
    6060{
     61  Index i;
     62  vmg_float err_1 = 0.0;
     63  vmg_float err_2 = 0.0;
     64  vmg_float err_inf = 0.0;
     65
     66  const Index begin_local = grid.Global().LocalBegin() - grid.Local().HaloSize1();
     67
     68  for (i.X()=grid.Local().Begin().X(); i.X()<grid.Local().End().X(); ++i.X())
     69    for (i.Y()=grid.Local().Begin().Y(); i.Y()<grid.Local().End().Y(); ++i.Y())
     70      for (i.Z()=grid.Local().Begin().Z(); i.Z()<grid.Local().End().Z(); ++i.Z()) {
     71        const Vector pos = grid.Extent().MeshWidth() * static_cast<Vector>(begin_local + i);
     72        const vmg_float err = std::abs(grid.GetVal(i) - std::sin(sine_factor * pos.X()) * std::sin(sine_factor * pos.Y()) * std::sin(sine_factor * pos.Z()));
     73        err_1 += err;
     74        err_2 += err * err;
     75        err_inf = std::max(err_inf, err);
     76      }
     77
     78  err_1 = grid.Extent().MeshWidth().Product() * err_1;
     79  err_2 = std::sqrt(grid.Extent().MeshWidth().Product() * err_2);
     80  err_inf = grid.Extent().MeshWidth().Product() * err_inf;
     81
     82  std::cout << std::scientific << "Error L1-Norm:   " << err_1 << std::endl
     83            << "Error L2-Norm:   " << err_2 << std::endl
     84            << "Error Inf-Norm: " << err_inf << std::endl;
    6185}
Note: See TracChangeset for help on using the changeset viewer.