ESyS-Particle  2.3.4
EWallInteractionGroup.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 // CEWallInteractionGroup functions
15 //----------------------------------------------
16 
17 #include "Foundation/console.h"
18 #include <iostream>
19 
20 template<class T>
22 {}
23 
31 template<class T>
33  :AWallInteractionGroup<T>(comm)
34 {
35  console.XDebug() << "making CEWallInteractionGroup \n";
36 
37  m_k=I->getSpringConst();
38  this->m_wall=wallp;
39 }
40 
41 template<class T>
43 {
44 
45  console.XDebug() << "calculating " << m_interactions.size() << " elastic wall forces\n" ;
46 
47  for(
48  typename vector<CElasticWallInteraction<T> >::iterator it=m_interactions.begin();
49  it != m_interactions.end();
50  it++
51  ){
52  it->calcForces();
53  }
54 }
55 
56 template<class T>
58 {
59 
60  console.XDebug() << "CEWallInteractionGroup::Update()\n" ;
61 
62  console.XDebug()
63  << "CEWallInteractionGroup::Update: wall origin = " << this->m_wall->getOrigin()
64  << ", wall normal = " << this->m_wall->getNormal() << "\n" ;
65 
66  k_local=0.0;
67  // empty particle list first
68  m_interactions.erase(m_interactions.begin(),m_interactions.end());
69  this->m_inner_count=0;
70  // build new particle list
72  PPA->getParticlesAtPlane(this->m_wall->getOrigin(),this->m_wall->getNormal());
73  for(typename ParallelParticleArray<T>::ParticleListIterator iter=plh->begin();
74  iter!=plh->end();
75  iter++){
76  bool iflag=PPA->isInInner((*iter)->getPos());
77  m_interactions.push_back(CElasticWallInteraction<T>(*iter,this->m_wall,m_k,iflag));
78  this->m_inner_count+=(iflag ? 1 : 0);
79  }
80 
81  console.XDebug() << "end CEWallInteractionGroup::Update()\n";
82 }
83 
84 
92 template<class T>
94 {
95  // warn if trying to apply non-perpendicular force
96  double par=F.unit()*this->m_wall->getNormal().unit(); // should be 1 if parallel
97  if(par<1.0){
98  console.Warning() << "Force not parallel to wall normal in CEWallInteractionGroup::applyForce : " << F << " vs. " << this->m_wall->getNormal() << "\n";
99  }
100  // warn if initial value of force is zero, which prevents convergence
101  if(F.norm()==0.0){
102  console.Warning() << "No force applied to wall in CEWallInteractionGroup::applyForce, which will not converge. If ramping the force, start with a nonzero value.\n";
103  }
104 
105  int it=0;
106  double d; // distance to move
107  double df; // force difference
108  double ef; // relative force error (df/|F|)
109  Vec3 O_f=F.unit(); // direction of the applied force
110  do{
111  //std::cerr << "iteration: " << it << std::endl;
112  // calculate local stiffness
113  k_local=0.0;
114  for(typename vector<CElasticWallInteraction<T> >::iterator iter=m_interactions.begin();
115  iter!=m_interactions.end();
116  iter++){
117  k_local+=iter->getStiffness();
118  }
119  //std::cerr << "local stiffness: " << k_local << std::endl;
120  // get global K
121  m_k_global=this->m_comm->sum_all(k_local);
122  //std::cerr << "global stiffness: " << m_k_global << std::endl;
123  if(m_k_global>0){
124  // calculate local F
125  Vec3 F_local=Vec3(0.0,0.0,0.0);
126  for (
127  typename vector<CElasticWallInteraction<T> >::iterator iter=m_interactions.begin();
128  iter!=m_interactions.end();
129  iter++
130  ){
131  if(iter->isInner()){
132  Vec3 f_i=iter->getForce();
133  F_local+=(f_i*O_f)*O_f; // add component of f_i in O_f direction
134  }
135  }
136  //std::cerr << "local Force: " << F_local << std::endl;
137  // get global F
138  // by component (hack - fix later,i.e. sum_all for Vec3)
139  double fgx=this->m_comm->sum_all(F_local.X());
140  double fgy=this->m_comm->sum_all(F_local.Y());
141  double fgz=this->m_comm->sum_all(F_local.Z());
142  Vec3 F_global=Vec3(fgx,fgy,fgz);
143  //std::cerr << "global Force: " << F_global << std::endl;
144 
145  // calc necessary wall movement
146  df=(F+F_global)*O_f;
147  d=df/m_k_global;
148  ef=df/F.norm();
149  // move the wall
150  this->m_wall->moveBy(d*O_f);
151  it++;
152  } else {
153  d=1e-5;
154  ef=1;
155  // move the wall
156  this->m_wall->moveBy(d*O_f);
157  it++;
158  }
159  } while((it<50)&&(ef>1e-3)); // check for convergence
160  // warning message if no contact or high error after iteration
161  if(ef>1e-3){
162  console.Warning() << "applyForce doesn't converge, global stiffness: " << m_k_global << " applied force: " << F << " wall normal: " << this->m_wall->getNormal() << "\n";
163  }
164 }
165 
166 
167 template<class T>
168 ostream& operator<<(ostream& ost,const CEWallInteractionGroup<T>& IG)
169 {
170  ost << "CEWallInteractionGroup" << endl << flush;
171  ost << *(IG.m_wall) << endl << flush;
172 
173  return ost;
174 }
CWall
base class for all walls
Definition: Wall.h:40
CEWallInteractionGroup::applyForce
virtual void applyForce(const Vec3 &)
Definition: brokenEWallInteractionGroup.hpp:102
CEWallInteractionGroup::CEWallInteractionGroup
CEWallInteractionGroup(TML_Comm *)
Definition: brokenEWallInteractionGroup.hpp:21
CElasticWallInteraction
unbonded elastic interaction between a particle and a wall
Definition: EWallInteraction.h:31
operator<<
ostream & operator<<(ostream &ost, const CEWallInteractionGroup< T > &IG)
Definition: EWallInteractionGroup.hpp:168
CEWallInteractionGroup
Class for a group of unbonded,elastic interactions between particles and a wall.
Definition: EWallInteractionGroup.h:56
CElasticIGP::getSpringConst
double getSpringConst() const
Definition: ElasticInteraction.h:36
console.h
Vec3::unit
VEC3_INLINE Vec3 unit() const
Definition: vec3.hpp:225
CEWallInteractionGroup::Update
virtual void Update(ParallelParticleArray< T > *)
Definition: brokenEWallInteractionGroup.hpp:57
AWallInteractionGroup
Abstract Base class for a group of interactions between particles and a wall.
Definition: WallIG.h:31
CEWallIGP
Interaction group parameters for CEWallInteractionGroups.
Definition: brokenEWallInteractionGroup.h:33
CEWallInteractionGroup::m_k
double m_k
Elastic modulus.
Definition: brokenEWallInteractionGroup.h:59
Vec3::norm
VEC3_INLINE double norm() const
Definition: vec3.hpp:211
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
Console::XDebug
Console & XDebug()
set verbose level of next message to "xdg"
Vec3::Z
VEC3_INLINE double & Z()
Definition: vec3.h:121
Console::Warning
Console & Warning()
set verbose level of next message to "wrn"
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
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
CEWallInteractionGroup::calcForces
virtual void calcForces()
Definition: brokenEWallInteractionGroup.hpp:42
console
Console console
Definition: console.cpp:25