~yade-dev/yade/0.80

« back to all changes in this revision

Viewing changes to pkg/common/ForceEngine.hpp

  • Committer: Anton Gladky
  • Date: 2012-05-02 21:50:42 UTC
  • Revision ID: gladky.anton@gmail.com-20120502215042-v1fa9r65usqe7kfk
0.80.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 2004 © Janek Kozicki <cosurgi@berlios.de> 
 
2
// 2009 © Václav Šmilauer <eudoxos@arcig.cz> 
 
3
 
 
4
#pragma once
 
5
 
 
6
#include<yade/core/PartialEngine.hpp>
 
7
 
 
8
class ForceEngine: public PartialEngine{
 
9
        public:
 
10
                virtual void action();
 
11
        YADE_CLASS_BASE_DOC_ATTRS(ForceEngine,PartialEngine,"Apply contact force on some particles at each step.",
 
12
                ((Vector3r,force,Vector3r::Zero(),,"Force to apply."))
 
13
        );
 
14
};
 
15
REGISTER_SERIALIZABLE(ForceEngine);
 
16
 
 
17
/* Engine for applying force of varying magnitude but constant direction
 
18
 * on subscribed bodies. times and magnitudes must have the same length,
 
19
 * direction (normalized automatically) gives the orientation.
 
20
 *
 
21
 * As usual with interpolating engines: the first magnitude is used before the first
 
22
 * time point, last magnitude is used after the last time point. Wrap specifies whether
 
23
 * time wraps around the last time point to the first time point.
 
24
 */
 
25
class InterpolatingDirectedForceEngine: public ForceEngine{
 
26
        size_t _pos;
 
27
        public:
 
28
                virtual void action();
 
29
        YADE_CLASS_BASE_DOC_ATTRS_CTOR(InterpolatingDirectedForceEngine,ForceEngine,"Engine for applying force of varying magnitude but constant direction on subscribed bodies. times and magnitudes must have the same length, direction (normalized automatically) gives the orientation. \n\n\
 
30
        \
 
31
        As usual with interpolating engines: the first magnitude is used before the first time point, last magnitude is used after the last time point. Wrap specifies whether time wraps around the last time point to the first time point.",
 
32
                ((vector<Real>,times,,,"Time readings [s]"))
 
33
                ((vector<Real>,magnitudes,,,"Force magnitudes readings [N]"))
 
34
                ((Vector3r,direction,Vector3r::UnitX(),,"Contact force direction (normalized automatically)"))
 
35
                ((bool,wrap,false,,"wrap to the beginning of the sequence if beyond the last time point")),
 
36
                /*ctor*/ _pos=0
 
37
        );
 
38
};
 
39
REGISTER_SERIALIZABLE(InterpolatingDirectedForceEngine);
 
40
 
 
41
struct RadialForceEngine: public PartialEngine{
 
42
        virtual void action();
 
43
        virtual void postLoad(RadialForceEngine&);
 
44
        YADE_CLASS_BASE_DOC_ATTRS(RadialForceEngine,PartialEngine,"Apply force of given magnitude directed away from spatial axis.",
 
45
                ((Vector3r,axisPt,Vector3r::Zero(),,"Point on axis"))
 
46
                ((Vector3r,axisDir,Vector3r::UnitX(),Attr::triggerPostLoad,"Axis direction (normalized automatically)"))
 
47
                ((Real,fNorm,0,,"Applied force magnitude"))
 
48
        );
 
49
};
 
50
REGISTER_SERIALIZABLE(RadialForceEngine);
 
51
 
 
52
class DragEngine: public PartialEngine{
 
53
        public:
 
54
                virtual void action();
 
55
        YADE_CLASS_BASE_DOC_ATTRS(DragEngine,PartialEngine,"Apply `drag force <http://en.wikipedia.org/wiki/Drag_equation>`__ on some particles at each step, decelerating them proportionally to their linear velocities. The applied force reads\n\n.. math:: F_{d}=-\\frac{\\vec{v}}{|\\vec{v}|}\\frac{1}{2}\\rho|\\vec{v}|^2 C_d A\n\nwhere $\\rho$ is the medium density (:yref:`density<DragEngine.Rho>`), $v$ is particle's velocity,  $A$ is particle projected area (disc), $C_d$ is the drag coefficient (0.47 for :yref:`Sphere`), \n\n.. note:: Drag force is only applied to spherical particles, listed in ids.",
 
56
                ((Real,Rho,1.225,,"Density of the medium (fluid or air), by default - the density of the air."))
 
57
                ((Real,Cd,0.47,,"Drag coefficient <http://en.wikipedia.org/wiki/Drag_coefficient>`_."))
 
58
        );
 
59
};
 
60
REGISTER_SERIALIZABLE(DragEngine);
 
61
 
 
62
class LinearDragEngine: public PartialEngine{
 
63
        public:
 
64
                virtual void action();
 
65
        YADE_CLASS_BASE_DOC_ATTRS(LinearDragEngine,PartialEngine,"Apply `viscous resistance or linear drag <http://en.wikipedia.org/wiki/Drag_%28physics%29#Very_low_Reynolds_numbers_.E2.80.94_Stokes.27_drag>`__ on some particles at each step, decelerating them proportionally to their linear velocities. The applied force reads\n\n.. math:: F_{d}=-b{\\vec{v}} \n\nwhere $b$ is the linear drag, $\\vec{v}$ is particle's velocity. \n\n.. math:: b=6\\pi\\nu r \n\nwhere $\\nu$ is the medium viscosity, $r$ is the `Stokes radius <http://en.wikipedia.org/wiki/Stokes_radius>`__ of the particle (but in this case we accept it equal to sphere radius for simplification), \n\n.. note:: linear drag is only applied to spherical particles, listed in ids.",
 
66
                ((Real,nu,0.001,,"Viscosity of the medium."))
 
67
        );
 
68
};
 
69
REGISTER_SERIALIZABLE(LinearDragEngine);