///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2017 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.apache.org/licenses/LICENSE-2.0 // // // ///////////////////////////////////////////////////////////// #include "CircMNTable2D.h" // --- System includes --- #include // --- IO includes --- #include using std::endl; using std::floor; CircMNTable2D::CircMNTable2D() {} /*! Construct CircMNTable2D. \param MinPt minimum point (z component ignored) \param MaxPt maximum point (z component ignored) \param cd cell dimension \param ngroups initial number of particle groups */ CircMNTable2D::CircMNTable2D(const Vector3& MinPt,const Vector3& MaxPt,double cd,unsigned int ngroups): MNTable2D(MinPt, MaxPt, cd, ngroups) { set_x_circ(); // check if grid spacing fits size in circular direction: double nx=(MaxPt-MinPt).X()/m_celldim; // error message if not if(nx!=floor(nx)){ std::cout << "WARNING! grid spacing " << m_celldim << " doesn't fit periodic x-dimension " << (MaxPt-MinPt).X() << std::endl; } double shift_x=(m_nx-2)*m_celldim; m_shift_vec_x=Vector3(shift_x,0.0,0.0); } /*! Destruct CircMNTable2D. Just calls MNTable2D destructor. */ CircMNTable2D::~CircMNTable2D() {} /*! set circularity of x-dimension to 1 */ void CircMNTable2D::set_x_circ() { m_x_periodic=1; } int CircMNTable2D::getXIndex(const Vector3& Pos) const { return int(floor((Pos.x()-m_x0)/m_celldim)); } int CircMNTable2D::getYIndex(const Vector3& Pos) const { return int(floor((Pos.y()-m_y0)/m_celldim)); } int CircMNTable2D::getFullIndex(const Vector3& Pos) const { int ix=int(floor((Pos.x()-m_x0)/m_celldim)); int iy=int(floor((Pos.y()-m_y0)/m_celldim)); return idx(ix,iy); } /*! get the cell index for a given position \param Pos the position \return the cell index if Pos is inside the table, -1 otherwise */ int CircMNTable2D::getIndex(const Vector3& Pos) const { int ret; int ix=int(floor((Pos.x()-m_x0)/m_celldim)); int iy=int(floor((Pos.y()-m_y0)/m_celldim)); // check if pos is in table excl. padding if((ix>=0) && (ix<=m_nx-1) && (iy>0) && (iy > bonds; if((id2==id) && (i!=0)){ // intra-cell, not for boundary //std::cout << id << " - " << id << std::endl; bonds=m_data[id].getBonds(gid,tol); } else if(id2>id){ // inter-cell //std::cout << id << " - " << id2 << std::endl; bonds=m_data[id].getBonds(gid,tol,m_data[id2]); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ //std::cout << iter->first << " | " << iter->second << " "; m_bonds[btag].insert(*iter); } //std::cout << std::endl; } } //std::cout << std::endl; } } } /*! Generate bonds between particles of a group with identical particle tag. Takes cloned particles into account. \param gid the group ID \param tol max. difference between bond length and equilibrium dist. \param btag bond tag \param ptag the particle tag \param mask the mask for the particle tag */ void CircMNTable2D::generateBondsWithMask(int gid,double tol,int btag, int ptag, int mask) { std::cout << "CircMNTable2D::generateBondsWithMask( " << gid << " , " << tol << " , " << btag << " " << ptag <<" " << mask<<" )" << std::endl; // loop over all cells for(int i=0;i > bonds; if((id2==id) && (i!=0)){ // intra-cell, not for boundary //std::cout << id << " - " << id << std::endl; bonds=m_data[id].getBonds(gid,tol,ptag,mask); } else if(id2>id){ // inter-cell //std::cout << id << " - " << id2 << std::endl; bonds=m_data[id].getBonds(gid,tol,m_data[id2],ptag,mask); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ //std::cout << iter->first << " | " << iter->second << " "; m_bonds[btag].insert(*iter); } //std::cout << std::endl; } } //std::cout << std::endl; } } } /*! Output the content of a MNTable2D to an ostream. The output format depends on the value of MNTable2D::s_output_style (see MNTable2D::SetOutputStyle). If it is set to 0, output suitable for debugging is generated, if it is set to 1 output in the esys .geo format is generated. If MNTable2D::s_output_style is set to 2, the output format is VTK-XML. \param ost the output stream \param T the table */ ostream& operator << (ostream& ost,const CircMNTable2D& T) { if(CircMNTable2D::s_output_style==0){ // debug style // don't print padding MNTCell::SetOutputStyle(0); for(int i=0;i > >::const_iterator iter=T.m_bonds.begin(); iter!=T.m_bonds.end(); iter++){ nbonds+=iter->second.size(); } ost << nbonds << endl; for(map > >::const_iterator iter=T.m_bonds.begin(); iter!=T.m_bonds.end(); iter++){ for(set >::const_iterator v_iter=iter->second.begin(); v_iter!=iter->second.end(); v_iter++){ ost << v_iter->first << " " << v_iter->second << " " << iter->first << endl; } } ost << "EndConnect" << endl; } else if (CircMNTable2D::s_output_style==2){ // vtk-xml T.WriteAsVtkXml(ost); } return ost; }