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