/* * Box.cpp * * Created on: Jun 30, 2010 * Author: crueger */ //#include "Helpers/MemDebug.hpp" #include "Box.hpp" #include #include "Matrix.hpp" #include "vector.hpp" #include "Helpers/Assert.hpp" Box::Box() { M= new Matrix(); M->one(); Minv = new Matrix(); Minv->one(); } Box::Box(const Box& src){ M=new Matrix(*src.M); Minv = new Matrix(*src.Minv); } Box::~Box() { delete M; delete Minv; } const Matrix &Box::getM() const{ return *M; } const Matrix &Box::getMinv() const{ return *Minv; } void Box::setM(Matrix _M){ ASSERT(_M.determinant()!=0,"Matrix in Box construction was not invertible"); *M =_M; *Minv = M->invert(); } Vector Box::translateIn(const Vector &point) const{ return (*M) * point; } Vector Box::translateOut(const Vector &point) const{ return (*Minv) * point; } Vector Box::WrapPeriodically(const Vector &point) const{ Vector helper = translateOut(point); for(int i=NDIM;i--;){ double intpart,fracpart; fracpart = modf(helper.at(i),&intpart); if(fracpart<0.) fracpart+=1.; helper.at(i)=fracpart; } return translateIn(helper); } VECTORSET(std::list) Box::explode(const Vector &point,int n) const{ VECTORSET(std::list) res; // translate the Vector into each of the 27 neighbourhoods // first create all translation Vectors // there are (n*2+1)^3 such vectors int max_dim = (n*2+1); int max_dim2 = max_dim*max_dim; int max = max_dim2*max_dim; // only one loop to avoid unneccessary jumps for(int i = 0;i