~esys-p-dev/esys-particle/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/////////////////////////////////////////////////////////////
//                                                         //
// Copyright (c) 2003-2014 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.opensource.org/licenses/osl-3.0.php          //
//                                                         //
/////////////////////////////////////////////////////////////

//----------------------------------------------
//       CEWallInteractionGroup functions
//----------------------------------------------

#include "Foundation/console.h"
#include <iostream>

template<class T>
CTaggedEWallInteractionGroup<T>::CTaggedEWallInteractionGroup(TML_Comm* comm):CEWallInteractionGroup<T>(comm)
{}

/*!
  Constructor for a tagged elastic wall interaction group

  \param comm the communicator
  \param wallp a pointer to the wall
  \param param the interaction parameters
  \param tag the tag of the particles 
  \param mask the mask for the particle tag	
*/
template<class T>
CTaggedEWallInteractionGroup<T>::CTaggedEWallInteractionGroup(TML_Comm* comm,CWall* wallp,const CEWallIGP* I, int tag, int mask)
  :CEWallInteractionGroup<T>(comm, wallp,I)
{
  console.XDebug() << "making CTaggedEWallInteractionGroup \n";

  this->m_tag=tag;
  this->m_mask=mask;		
}

/*!
  Update the interaction group. Checks which particles are close to the wall and have the right
  tag. Except for the tag issue this is copied from the base class (CEWallInteractionGroup)

  \param PPA the array containing the particles
*/
template<class T>
void CTaggedEWallInteractionGroup<T>::Update(ParallelParticleArray<T>* PPA)
{
  console.XDebug() << "CTaggedEWallInteractionGroup::Update()\n" ;

  console.XDebug()
    << "CTaggedEWallInteractionGroup::Update: wall origin = " << this->m_wall->getOrigin()
    << ", wall normal = " << this->m_wall->getNormal() << "\n" ;

  this->k_local=0.0;
  // empty particle list first
  this->m_interactions.erase(this->m_interactions.begin(),this->m_interactions.end());
  this->m_inner_count=0;
  // build new particle list
  typename ParallelParticleArray<T>::ParticleListHandle plh=
    PPA->getParticlesAtPlane(this->m_wall->getOrigin(),this->m_wall->getNormal());
  for(typename ParallelParticleArray<T>::ParticleListIterator iter=plh->begin();
      iter!=plh->end();
      iter++){
	int p_tag=(*iter)->getTag(); // get particle tag
	if ((p_tag & this->m_mask) == (this->m_tag & this->m_mask)){ // check if particles have the right tag
		bool iflag=PPA->isInInner((*iter)->getPos());
		this->m_interactions.push_back(CElasticWallInteraction<T>(*iter,this->m_wall,this->m_k,iflag));
		this->m_inner_count+=(iflag ? 1 : 0);
	}
  }
  console.XDebug() << "found " << this->m_inner_count << " interactions\n";
  
  console.XDebug() << "end CTaggedEWallInteractionGroup::Update()\n";
}