MercuryDPM  0.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InsertionBoundary Class Reference

#include <InsertionBoundary.h>

+ Inheritance diagram for InsertionBoundary:

Public Member Functions

virtual InsertionBoundarycopy () const
 BaseBoundary copy method. More...
 
void set (Vec3D posMin, Vec3D posMax, Vec3D velMin, Vec3D velMax, Mdouble radMin, Mdouble radMax, int maxFailed)
 
virtual void checkBoundaryActionsBeforeTimeStep (ParticleHandler &pH, WallHandler &wH, RNG &random)
 
void read (std::istream &is)
 reads wall More...
 
void print (std::ostream &os) const
 outputs wall More...
 
- Public Member Functions inherited from BaseBoundary
virtual ~BaseBoundary ()
 
virtual int createPeriodicParticles (BaseParticle *P UNUSED, ParticleHandler &pH UNUSED)
 
virtual bool checkBoundaryAfterParticleMoved (BaseParticle *P UNUSED, ParticleHandler &pH UNUSED)
 
virtual void checkBoundaryActionsBeforeTimeStep (ParticleHandler &pH UNUSED, WallHandler &wH UNUSED, RNG &random UNUSED)
 
void set_Index (int index)
 
void set_Id (int id)
 
void setHandler (BoundaryHandler *handler)
 
virtual void read (std::istream &is UNUSED)=0
 reads boundary More...
 
virtual void print (std::ostream &os UNUSED) const =0
 outputs boundary More...
 
virtual void moveInHandler (int newPos)
 

Public Attributes

Vec3D posMin_
 
Vec3D posMax_
 
Vec3D velMin_
 
Vec3D velMax_
 
Mdouble radMin_
 
Mdouble radMax_
 
int maxFailed_
 

Detailed Description

Definition at line 31 of file InsertionBoundary.h.

Member Function Documentation

virtual void InsertionBoundary::checkBoundaryActionsBeforeTimeStep ( ParticleHandler pH,
WallHandler wH,
RNG random 
)
inlinevirtual

Definition at line 53 of file InsertionBoundary.h.

References WallHandler::begin(), BaseHandler< T >::begin(), BaseHandler< T >::copyAndAddObject(), WallHandler::end(), BaseHandler< T >::end(), BaseParticle::get_Position(), BaseParticle::get_Radius(), RNG::get_RN(), maxFailed_, posMax_, posMin_, radMax_, radMin_, BaseParticle::set_inertia(), BaseParticle::set_Mass(), BaseParticle::set_Position(), BaseParticle::set_Radius(), BaseParticle::set_Velocity(), sqr, velMax_, velMin_, Vec3D::X, Vec3D::Y, and Vec3D::Z.

54  {
55  int failed = 0;
56  BaseParticle p0;
57  bool isInsertable;
58  Mdouble distance;
59  Vec3D normal;
60  //try max_failed times to find new insertable particle
61  while (failed<=maxFailed_)
62  {
63  std::cout << "I" << std::endl;
64  //Set random radius, position and velocity
65  p0.set_Radius(random.get_RN(radMin_,radMax_));
66  p0.set_Mass(1.0);
67  p0.set_inertia(1.0);
68  Vec3D position;
69  position.X = random.get_RN(posMin_.X,posMax_.X);
70  position.Y = random.get_RN(posMin_.Y,posMax_.Y);
71  position.Z = random.get_RN(posMin_.Z,posMax_.Z);
72  Vec3D velocity;
73  velocity.X = random.get_RN(velMin_.X,velMax_.X);
74  velocity.Y = random.get_RN(velMin_.Y,velMax_.Y);
75  velocity.Z = random.get_RN(velMin_.Z,velMax_.Z);
76  p0.set_Position(position);
77  p0.set_Velocity(velocity);
78  // p0.set_Position(Vec3D(random.get_RN(posMin_.X,posMax_.X),random.get_RN(posMin_.Y,posMax_.Y),random.get_RN(posMin_.Z,posMax_.Z)));
79  // p0.set_Velocity(Vec3D(random.get_RN(velMin_.X,velMax_.X),random.get_RN(velMin_.Y,velMax_.Y),random.get_RN(velMin_.Z,velMax_.Z)));
80 
81  isInsertable=true;
82 
83 // cout<<"Particle to insert "<<p0<<endl;
84  //Check if it has no collision with walls
85  for(std::vector<BaseWall*>::iterator it=wH.begin();isInsertable&&it!=wH.end();it++)
86  {
87  (*it)->get_distance_and_normal(p0,distance,normal);
88  if(distance<p0.get_Radius())
89  {
90  // cout<<"Collision with wall "<<**it<<endl;
91  isInsertable=false;
92  }
93  else
94  {
95 // cout<<"No collision with wall "<<**it<<endl;
96  }
97  }
98  //Check if it has no collision with other particles
99  for(std::vector<BaseParticle*>::iterator it=pH.begin();isInsertable&&it!=pH.end();it++)
100  {
101  if(GetDistance2(p0.get_Position(),(*it)->get_Position())<sqr(p0.get_Radius()+(*it)->get_Radius()))
102  {
103  // cout<<"Collision with particle "<<**it<<endl;
104  isInsertable=false;
105  }
106  else
107  {
108 // cout<<"No collision with particle "<<**it<<endl;
109  }
110  }
111 
112  if (isInsertable)
113  {
114  //Still needs to set a lot of things like mass and HGRID stuff
115  // cout<<"Inserting particle"<<endl;
116  pH.copyAndAddObject(p0);
117  failed = 0;
118  }
119  else
120  {
121 // cout<<"Not inserting particle"<<endl;
122  failed++;
123  }
124  }
125  };
void set_inertia(const Mdouble _new)
Mdouble X
Definition: Vector.h:44
void copyAndAddObject(const T &O)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:93
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:220
Mdouble get_RN(Mdouble min, Mdouble max)
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:32
#define sqr(a)
Definition: ExtendedMath.h:36
Mdouble get_Radius() const
const std::vector< BaseWall * >::const_iterator begin() const
Gets the begin of the const_iterator over all BaseWall in this WallHandler.
Definition: WallHandler.cc:242
const std::vector< BaseWall * >::const_iterator end() const
Gets the end of the const_iterator over all BaseWall in this WallHandler.
Definition: WallHandler.cc:254
double Mdouble
Definition: ExtendedMath.h:33
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
Definition: BaseHandler.h:233
const Vec3D & get_Position() const
Mdouble Y
Definition: Vector.h:44
void set_Radius(const Mdouble _new)
void set_Velocity(const Vec3D &_new)
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:40
void set_Position(const Vec3D &_new)
Mdouble Z
Definition: Vector.h:44
void set_Mass(const Mdouble _new)
virtual InsertionBoundary* InsertionBoundary::copy ( ) const
inlinevirtual

BaseBoundary copy method.

It calls the copy constructor of this BaseBoundary, useful for polymorphism todo{Does this work correctly?}

Implements BaseBoundary.

Definition at line 34 of file InsertionBoundary.h.

35  {
36  #ifdef CONSTUCTOR_OUTPUT
37  cerr << "virtual InsertionBoundary* copy() const finished" << endl;
38  #endif
39  return new InsertionBoundary(*this);
40  }
void InsertionBoundary::print ( std::ostream &  os) const
inline

outputs wall

Definition at line 134 of file InsertionBoundary.h.

References maxFailed_, posMax_, posMin_, radMax_, radMin_, velMax_, and velMin_.

134  {
135  os << "InsertionBoundary posMin " << posMin_
136  << " posMax " << posMax_
137  << " velMin " << velMin_
138  << " velMax " << velMax_
139  << " radMin " << radMin_
140  << " radMax " << radMax_
141  << " maxFailed " << maxFailed_;
142  }
void InsertionBoundary::read ( std::istream &  is)
inline

reads wall

Definition at line 128 of file InsertionBoundary.h.

References maxFailed_, posMax_, posMin_, radMax_, radMin_, velMax_, and velMin_.

128  {
129  std::string dummy;
130  is >> dummy >> posMin_ >> dummy >> posMax_ >> dummy >> velMin_ >> dummy >> velMax_ >> dummy >> radMin_ >> dummy >> radMax_ >> dummy >> maxFailed_;
131  }
void InsertionBoundary::set ( Vec3D  posMin,
Vec3D  posMax,
Vec3D  velMin,
Vec3D  velMax,
Mdouble  radMin,
Mdouble  radMax,
int  maxFailed 
)
inline

Definition at line 42 of file InsertionBoundary.h.

References maxFailed_, posMax_, posMin_, radMax_, radMin_, velMax_, and velMin_.

43  {
44  posMin_=posMin;
45  posMax_=posMax;
46  velMin_=velMin;
47  velMax_=velMax;
48  radMin_=radMin;
49  radMax_=radMax;
50  maxFailed_=maxFailed;
51  }

Member Data Documentation

int InsertionBoundary::maxFailed_

Definition at line 148 of file InsertionBoundary.h.

Referenced by checkBoundaryActionsBeforeTimeStep(), print(), read(), and set().

Vec3D InsertionBoundary::posMax_

Definition at line 145 of file InsertionBoundary.h.

Referenced by checkBoundaryActionsBeforeTimeStep(), print(), read(), and set().

Vec3D InsertionBoundary::posMin_

Definition at line 145 of file InsertionBoundary.h.

Referenced by checkBoundaryActionsBeforeTimeStep(), print(), read(), and set().

Mdouble InsertionBoundary::radMax_

Definition at line 147 of file InsertionBoundary.h.

Referenced by checkBoundaryActionsBeforeTimeStep(), print(), read(), and set().

Mdouble InsertionBoundary::radMin_

Definition at line 147 of file InsertionBoundary.h.

Referenced by checkBoundaryActionsBeforeTimeStep(), print(), read(), and set().

Vec3D InsertionBoundary::velMax_

Definition at line 146 of file InsertionBoundary.h.

Referenced by checkBoundaryActionsBeforeTimeStep(), print(), read(), and set().

Vec3D InsertionBoundary::velMin_

Definition at line 146 of file InsertionBoundary.h.

Referenced by checkBoundaryActionsBeforeTimeStep(), print(), read(), and set().


The documentation for this class was generated from the following file: