/*
 *    vmg - a versatile multigrid solver
 *    Copyright (C) 2012 Institute for Numerical Simulation, University of Bonn
 *
 *  vmg is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  vmg is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see .
 */
/*
 * interface_gaussian.cpp
 *
 *  Created on: 19.04.2013
 *      Author: Julian Iseringhausen
 */
#ifdef HAVE_CONFIG_H
#include 
#endif
#include 
#include 
#include 
#include 
#include 
#include "base/math.hpp"
#include "grid/grid.hpp"
#include "grid/multigrid.hpp"
#include "interface_gaussian.hpp"
using namespace VMG;
using VMGInterfaces::InterfaceGaussian;
void InterfaceGaussian::ImportRightHandSide(Multigrid& multigrid)
{
  Index i;
  Vector pos;
  Grid& grid = multigrid(multigrid.MaxLevel());
  grid.Clear();
  const Vector pos_center = 0.5 * (grid.Extent().Begin() + grid.Extent().End());
  const Index begin = grid.Local().Begin() + grid.Local().Size() / 4;
  const Index end = grid.Local().End() - grid.Local().Size() / 4;
  for (i.X()=begin.X(); i.X() std::numeric_limits::epsilon()) {
	  const vmg_float err = std::abs(grid.GetVal(i) - 1.0 / (4.0 * VMG::Math::pi * dist) *
                                boost::math::erf(dist / (VMG::Math::sqrt2 * sigma)));
	  err_1 += err;
	  err_2 += err * err;
	  err_inf = std::max(err_inf, err);
	}
      }
  err_1 = grid.Extent().MeshWidth().Product() * err_1;
  err_2 = std::sqrt(grid.Extent().MeshWidth().Product() * err_2);
  err_inf = grid.Extent().MeshWidth().Product() * err_inf;
  std::cout << std::scientific << "Error L1-Norm:   " << err_1 << std::endl
	    << "Error L2-Norm:   " << err_2 << std::endl
	    << "Error Inf-Norm: " << err_inf << std::endl;
}