ESyS-Particle  2.2.2
SoftBWallInteractionGroup.hpp
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2003-2013 by The University of Queensland //
4 // Earth Systems Science Computational Centre (ESSCC) //
5 // http://www.uq.edu.au/esscc //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.opensource.org/licenses/osl-3.0.php //
10 // //
12 
13 //----------------------------------------------
14 // CSoftBWallInteractionGroup functions
15 //----------------------------------------------
16 
17 #include "Foundation/console.h"
18 
19 template<class T>
21 {}
22 
30 template<class T>
32  : AWallInteractionGroup<T>(comm)
33 {
34  console.XDebug() << "making CSoftBWallInteractionGroup \n";
35 
36  m_normalK=I->getNormalK();
37  m_shearK=I->getShearK();
38  this->m_wall=wallp;
39  m_tag=I->getTag();
40  m_scaling=I->getScaling();
41 // console.XDebug() << "kx, ky, kz: " << m_kx << ","<< m_ky << ","<< m_kz << "\n";
42 }
43 
44 template<class T>
46 {
47 
48  console.XDebug() << "calculating " << m_interactions.size() << " soft bonded wall forces\n" ;
49 
50  for(
51  typename vector<CSoftBondedWallInteraction<T> >::iterator it=m_interactions.begin();
52  it != m_interactions.end();
53  it++
54  ){
55  it->calcForces();
56  }
57 }
58 
65 template<class T>
67 {
68  console.XDebug() << "CSoftBWallInteractionGroup<T>::applyForce: F = " << F << "\n";
69  // calculate local K
70 
71  double K=0.0;
72  for (
73  typename vector<CSoftBondedWallInteraction<T> >::iterator it=m_interactions.begin();
74  it!=m_interactions.end();
75  it++){
76  if(it->isInner()){
77  K+=it->getStiffness();
78  console.XDebug() << "CSoftBWallInteractionGroup<T>::applyForce: K = " << K << "\n";
79  }
80  }
81  // get global K
82  double K_global=this->m_comm->sum_all(K);
83  console.XDebug() << "CSoftBWallInteractionGroup<T>::applyForce: K_global = " << K_global << "\n";
84 
85  int it=0;
86  double d;
87  Vec3 O_f=F.unit(); // direction of the applied force
88  console.XDebug() << "CSoftBWallInteractionGroup<T>::applyForce: unitF = " << O_f << "\n";
89  do{
90  // calculate local F
91  Vec3 F_local=Vec3(0.0,0.0,0.0);
92  // bonded itneractions
93  for(
94  typename vector<CSoftBondedWallInteraction<T> >::iterator iter=m_interactions.begin();
95  iter!=m_interactions.end();
96  iter++
97  ){
98  if(iter->isInner()){
99  Vec3 f_i=iter->getForce();
100  F_local+=(f_i*O_f)*O_f; // add component of f_i in O_f direction
101  }
102  }
103 
104  // get global F
105  // by component (hack - fix later,i.e. sum_all for Vec3)
106  double fgx=this->m_comm->sum_all(F_local.X());
107  double fgy=this->m_comm->sum_all(F_local.Y());
108  double fgz=this->m_comm->sum_all(F_local.Z());
109  Vec3 F_global=Vec3(fgx,fgy,fgz);
110 
111  // calc necessary wall movement
112  d=((F+F_global)*O_f)/K_global;
113  console.XDebug()
114  << "CBWallInteractionGroup<T>::applyForce: iteration " << it << ", d = " << fabs(d) << "\n";
115 
116  // move the wall
117  console.XDebug()
118  << "CBWallInteractionGroup<T>::applyForce: moving wall by " << d*O_f << "\n";
119  this->m_wall->moveBy(d*O_f);
120  it++;
121  } while((it<10)&&(fabs(d)>10e-6)); // check for convergence
122  console.XDebug()
123  << "CBWallInteractionGroup<T>::applyForce: d = " << fabs(d)
124  << ", num iterations = " << it << "\n";
125 }
126 
127 
128 template<class T>
130 {
131 
132  console.XDebug() << "CSoftBWallInteractionGroup::Update()\n" ;
133 
134  // empty particle list first
135  m_interactions.erase(m_interactions.begin(),m_interactions.end());
136  // build new particle list
138  PPA->getParticlesAtPlane(this->m_wall->getOrigin(),this->m_wall->getNormal());
139  for(typename ParallelParticleArray<T>::ParticleListIterator iter=plh->begin();
140  iter!=plh->end();
141  iter++){
142  if((*iter)->getTag()==m_tag){
143  bool iflag=PPA->isInInner((*iter)->getPos());
144  m_interactions.push_back(CSoftBondedWallInteraction<T>(*iter,this->m_wall,m_normalK,m_shearK,m_scaling,iflag));
145  }
146  }
147  console.XDebug() << "end CSoftBWallInteractionGroup::Update()\n";
148 }
149 
150 template<class T>
151 ostream& operator<<(ostream& ost,const CSoftBWallInteractionGroup<T>& IG)
152 {
153  ost << "CBWallInteractionGroup" << endl << flush;
154  ost << *(IG.m_wall) << endl << flush;
155 
156  return ost;
157 }
CWall * m_wall
the wall
Definition: WallIG.h:33
NeighborTable< T >::particlelist::iterator ParticleListIterator
Definition: pp_array.h:80
virtual bool isInInner(const Vec3 &)
Definition: pp_array.hpp:208
Definition: vec3.h:46
VEC3_INLINE double & Z()
Definition: vec3.h:121
virtual void Update(ParallelParticleArray< T > *)
Definition: SoftBWallInteractionGroup.hpp:129
VEC3_INLINE double & Y()
Definition: vec3.h:120
bool getScaling() const
Definition: SoftBWallInteractionGroup.h:41
boost::python::object iter(const boost::python::object &pyOb)
Definition: Util.h:25
virtual void calcForces()
Definition: SoftBWallInteractionGroup.hpp:45
ParticleListHandle getParticlesAtPlane(Vec3 o, Vec3 n)
Get list of particles along a plane. Forwards to NTable::getParticlesAtPlane.
Definition: pp_array.h:191
base class for all walls
Definition: Wall.h:39
CSoftBWallInteractionGroup(TML_Comm *)
Definition: SoftBWallInteractionGroup.hpp:20
parrallel particle storage array with neighborsearch and variable exchange
Definition: SubLattice.h:61
Abstract Base class for a group of interactions between particles and a wall.
Definition: WallIG.h:30
double getShearK() const
Definition: SoftBWallInteractionGroup.h:40
int getTag() const
Definition: BWallInteractionGroup.h:47
virtual void applyForce(const Vec3 &)
Definition: SoftBWallInteractionGroup.hpp:66
abstract base class for communicator
Definition: comm.h:46
BasicCon & XDebug(bool h=true)
set verbose level of next message to &quot;xdg&quot;
Definition: console.cpp:316
bool m_scaling
Definition: SoftBWallInteractionGroup.h:64
int m_tag
Definition: SoftBWallInteractionGroup.h:63
Con console
double m_normalK
Definition: SoftBWallInteractionGroup.h:62
Interaction group parameters for CSoftBWallInteractionGroups.
Definition: SoftBWallInteractionGroup.h:31
VEC3_INLINE double & X()
Definition: vec3.h:119
Template class for a handle/ref. counted pointer.
Definition: handle.h:26
bonded elastic interaction between a particle and a wall with different spring constants in the norma...
Definition: SoftBWallInteraction.h:29
double getNormalK() const
Definition: SoftBWallInteractionGroup.h:39
double m_shearK
spring constants for each direction
Definition: SoftBWallInteractionGroup.h:62
VEC3_INLINE Vec3 unit() const
Definition: vec3.hpp:225