File: BodyForceGroup.h

package info (click to toggle)
esys-particle 2.3.4%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 13,036 kB
  • ctags: 10,805
  • sloc: cpp: 80,009; python: 5,872; makefile: 1,243; sh: 313; perl: 225
file content (191 lines) | stat: -rw-r--r-- 5,102 bytes parent folder | download
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/////////////////////////////////////////////////////////////
//                                                         //
// 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.apache.org/licenses/LICENSE-2.0          //
//                                                         //
/////////////////////////////////////////////////////////////


#ifndef ESYS_LSMBODYFORCEGROUP_H
#define ESYS_LSMBODYFORCEGROUP_H

#include "Model/InteractionGroup.h"
#include "Foundation/vec3.h"

template <class TmplParticle> class ParallelParticleArray;

namespace esys
{
  namespace lsm
  {
    class BodyForceIGP : public AIGParam
    {
    public:

      BodyForceIGP();

      BodyForceIGP(const std::string &name, const Vec3 &acceleration);

      virtual ~BodyForceIGP();

      const Vec3 &getAcceleration() const;

      const std::string &getName() const;

      virtual void packInto(CVarMPIBuffer *pBuffer) const;

      static BodyForceIGP extract(CVarMPIBuffer *pBuffer);
      
      virtual std::string getTypeString() const {return "BodyForce";}

    protected:
      Vec3 m_acceleration;
    };

    class GravityIGP : public BodyForceIGP
    {
    public:

      GravityIGP() : BodyForceIGP()
      {
      }

      GravityIGP(const std::string &name, const Vec3 &acceleration) : BodyForceIGP(name, acceleration)
      {
      }

      virtual std::string getTypeString() const {return "Gravity";}

    private:
    };

    class BuoyancyIGP : public AIGParam
    {
    public:

      BuoyancyIGP()
      {
      }

      BuoyancyIGP(const std::string &name, const Vec3 &acceleration, const double &fluidDensity, const double &fluidHeight);

      virtual std::string getTypeString() const {return "Buoyancy";}

      virtual void packInto(CVarMPIBuffer *pBuffer) const;

      static BuoyancyIGP extract(CVarMPIBuffer *pBuffer);

      const double &getFluidDensity () const;

      const double &getFluidHeight () const;

      const Vec3 &getAcceleration() const;

    private:
      Vec3 m_acceleration;
      double m_fluidDensity, m_fluidHeight;
    };

    /**
     * Objects of this class apply a gravitational body-acceleration
     * to individual particles.
     */
    template <class TmplParticle>
    class BodyForceGroup : public AInteractionGroup<TmplParticle>
    {
    public:
      typedef ParallelParticleArray<TmplParticle> ParticleArray;
      typedef typename ParticleArray::ParticleListIterator ParticleIterator;

      BodyForceGroup(const BodyForceIGP &prms, ParticleArray &particleArray);

      ~BodyForceGroup();

      /**
       * Returns the force which would be applied to a
       * particle of the specified mass.
       *
       * @param mass A mass ("units" assumed to be same as
       *             the acceleration units).
       */
      Vec3 getForce(double mass) const;

      /**
       * Applies body force to the specified particle.
       *
       * @param particle Force applied to this particle using
       *                 a call to particle.applyForce(...).
       */
      void applyForce(TmplParticle &particle) const;

      virtual void Update(ParallelParticleArray<TmplParticle> *particleArray);

      /**
       * Null op, time step size not required.
       */
      virtual void setTimeStepSize(double dt)
      {
      }
      
      virtual void calcForces();

    private:
      Vec3          m_acceleration;
      ParticleArray *m_pParticleArray;
    };

    template <class TmplParticle>
    class BuoyancyForceGroup : public AInteractionGroup<TmplParticle>
    {
    public:
      typedef ParallelParticleArray<TmplParticle> ParticleArray;
      typedef typename ParticleArray::ParticleListIterator ParticleIterator;

      BuoyancyForceGroup(const BuoyancyIGP &prms, ParticleArray &particleArray);

      ~BuoyancyForceGroup();

      /**
       * Returns the force which would be applied to a
       * particle of the specified mass.
       *
       * @param mass A mass ("units" assumed to be same as
       *             the acceleration units).
       */
      Vec3 getForce(double volume) const;

      /**
       * Applies body force to the specified particle.
       *
       * @param particle Force applied to this particle using
       *                 a call to particle.applyForce(...).
       */
      void applyForce(TmplParticle &particle) const;

      virtual void Update(ParallelParticleArray<TmplParticle> *particleArray);

      /**
       * Null op, time step size not required.
       */
      virtual void setTimeStepSize(double dt)
      {
      }

      virtual void calcForces();

    private:
      Vec3          m_acceleration;
      ParticleArray *m_pParticleArray;
      double m_fluidDensity, m_fluidHeight;
    };
  }
}

#include "Model/BodyForceGroup.hpp"

#endif