Skip to content
Snippets Groups Projects
BallProject.h 2.34 KiB
Newer Older
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  TU Dresden                                                            ==
// ==  Institut fr Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
// ==                                                                        ==
// ============================================================================

/** \file BallProject.h */

#ifndef AMDIS_BALLPROJECT_H
#define AMDIS_BALLPROJECT_H

namespace AMDiS {

  /** \brief
   * Projects world coordinates to the surface of a ball with given center and 
   * radius. Can be used as boundary or volume projection.
   */
  class BallProject : public Projection
  {
  public:
    BallProject(int id, 
		ProjectionType type,
		WorldVector<double> &center,
		double radius) 
      : Projection(id, type),
	center_(center),
	radius_(radius)
    /// Destructor.
    virtual ~BallProject() {}
    /// Implementation of Projection::project();
Thomas Witkowski's avatar
Thomas Witkowski committed
    void project(WorldVector<double> &x) 
    {
      x -= center_;
      double norm = sqrt(x*x);
      TEST_EXIT(norm != 0.0)("can't project vector x\n");
    WorldVector<double> center_;