File: RotParticlePy.cpp

package info (click to toggle)
esys-particle 2.3.5%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,132 kB
  • sloc: cpp: 81,480; python: 5,872; makefile: 1,259; sh: 313; perl: 225
file content (192 lines) | stat: -rw-r--r-- 7,633 bytes parent folder | download | duplicates (4)
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
192
/////////////////////////////////////////////////////////////
//                                                         //
// Copyright (c) 2003-2017 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              //
//                                                         //
/////////////////////////////////////////////////////////////

#include <mpi.h>
#include <boost/version.hpp>
#include <stdexcept>
#include <boost/python.hpp>
#include "Python/esys/lsm/RotParticlePy.h"

namespace esys
{
  namespace lsm
  {
    RotParticlePy::RotParticlePy() : CRotParticle()
    {
    }

    RotParticlePy::RotParticlePy(const RotParticlePy &p) : CRotParticle(p)
    {
    }

    RotParticlePy::RotParticlePy(const CRotParticle &p) : CRotParticle(p)
    {
    }

    // dynamic & rotational default to true
    RotParticlePy::RotParticlePy(int id, const Vec3Py &posn, double radius, double mass)
      : CRotParticle(radius, mass, posn, Vec3(), Vec3(), id,true,true)
    {
    }

    Vec3Py RotParticlePy::getInitialPosn() const
    {
      return Vec3Py(getInitPos());
    }

    Vec3Py RotParticlePy::getPosn() const
    {
      return Vec3Py(getPos());
    }

    void RotParticlePy::setPosn(const Vec3Py& posn)
    {
      setPos(posn);
    }

    QuaternionPy RotParticlePy::getOrientation() const
    {
      return QuaternionPy(getQuat());
    }

    void RotParticlePy::setOrientation(const QuaternionPy& quat)
    {
      setQuat(quat);
    }

    Vec3Py RotParticlePy::getVelocity() const
    {
      return Vec3Py(getVel());
    }

    Vec3Py RotParticlePy::getLinearVelocity() const
    {
      return Vec3Py(getVel());
    }

    void RotParticlePy::setLinearVelocity(const Vec3Py& vel)
    {
      return setVel(vel);
    }

    Vec3Py RotParticlePy::getAngularVelocity() const
    {
      return Vec3Py(getAngVel());
    }

    void RotParticlePy::setAngularVelocity(const Vec3Py& vel)
    {
      setAngVel(vel);
    }

    Vec3Py RotParticlePy::getAcceleration() const
    {
      return Vec3Py(getForce()*getInvMass());
    }

    Vec3Py RotParticlePy::getLinearAcceleration() const
    {
      return Vec3Py(getForce()*getInvMass());
    }

    void RotParticlePy::setLinearAcceleration(const Vec3Py& accel)
    {
      setForce(accel*getMass());
    }

    Vec3Py RotParticlePy::getAngularAcceleration() const
    {
      return getMoment()*getInvInertRot();
    }

    void RotParticlePy::setAngularAcceleration(const Vec3Py& accel)
    {
      setMoment(accel*getInertRot());
    }

    Vec3Py RotParticlePy::getLinearForce() const
    {
      return Vec3Py(m_force);
    }

    void RotParticlePy::setLinearForce(const Vec3Py& force)
    {
      setForce(force);
    }

    Vec3Py RotParticlePy::getAngularForce() const
    {
      return Vec3Py(m_moment);
    }

    void RotParticlePy::setAngularForce(const Vec3Py& moment)
    {
      setMoment(moment);
    }

    using boost::python::arg;
    void exportRotParticle()
    {
      // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher)
      // for Epydoc which stumbles over indentation in the automatically generated strings.
      boost::python::docstring_options no_autogen(true,false);

      boost::python::class_<RotParticlePy>("RotSphere","Class defining the properties of spheres with translational and rotational degrees of freedom.\n")
        .def(boost::python::init<>())
        .def(boost::python::init<const RotParticlePy &>())
        .def(boost::python::init<int,const Vec3Py &, double, double>(
          (
            arg("id"),
            arg("posn"),
            arg("radius"),
            arg("mass")
          ),
          "Construct a rotational spherical particle.\n"
          "@type id: int\n"
          "@kwarg id: Unique identifier for particle.\n"
          "@type posn: L{Vec3<esys.lsm.util.FoundationPy.Vec3>}\n"
          "@kwarg posn: Initial position of particle, centre-point of sphere.\n"
          "@type radius: float\n"
          "@kwarg radius: The radius of the sphere.\n"
          "@type mass: float\n"
          "@kwarg mass: Mass of particle.\n"
        ))
        .def("getId",                   &RotParticlePy::getID, "Returns the unique ID of the particle\n")
        .def("getTag",                  &RotParticlePy::getTag, "Returns the non-unique tag of the particle\n")
        .def("setTag",                  &RotParticlePy::setTag, "Specifies the tag of the particle\n")
        .def("getInitialPosn",          &RotParticlePy::getInitialPosn, "Returns the initial position of the particle\n")
        .def("getInitialPosition",      &RotParticlePy::getInitialPosn, "Returns the initial position of the particle\n")
        .def("getPosn",                 &RotParticlePy::getPosn, "Returns the current position of the particle\n")
        .def("getPosition",             &RotParticlePy::getPosn, "Returns the current position of the particle\n")
        .def("setPosn",                 &RotParticlePy::setPosn, "Specifies the position of the particle\n")
        .def("setPosition",             &RotParticlePy::setPosn, "Specifies the position of the particle\n")
        .def("getOrientation",          &RotParticlePy::getOrientation, "Returns the current orientation of the particle\n")
        .def("setOrientation",          &RotParticlePy::setOrientation, "Specifies the orientation of the particle\n")
        .def("getVelocity",             &RotParticlePy::getVelocity, "Returns the current translational velocity of the particle\n")
        .def("getLinearVelocity",       &RotParticlePy::getLinearVelocity, "Returns the current translational velocity of the particle\n")
        .def("setLinearVelocity",       &RotParticlePy::setLinearVelocity, "Specifies the current translational velocity of the particle\n")
        .def("getAngularVelocity",      &RotParticlePy::getAngularVelocity, "Returns the current angular velocity of the particle\n")
        .def("setAngularVelocity",      &RotParticlePy::setAngularVelocity, "Specifies the angular velocity of the particle\n")
        .def("getAcceleration",         &RotParticlePy::getAcceleration, "Returns the current translational acceleration of the particle\n")
        .def("getLinearAcceleration",   &RotParticlePy::getLinearAcceleration, "Returns the current translational acceleration of the particle\n")
        .def("setLinearAcceleration",   &RotParticlePy::setLinearAcceleration, "Specifies the translational acceleration of the particle\n")
        .def("getAngularAcceleration",  &RotParticlePy::getAngularAcceleration, "Returns the current angular acceleration of the particle\n")
        .def("setAngularAcceleration",  &RotParticlePy::setAngularAcceleration, "Specifies the angular acceleration of the particle\n")
        .def("getRad",                  &RotParticlePy::getRad, "Returns the radius of the particle\n")
        .def("getRadius",               &RotParticlePy::getRad, "Returns the radius of the particle\n")
        .def("getCentre",               &RotParticlePy::getPosn, "Returns the current position of the particle\n")
        .def("getCenter",               &RotParticlePy::getPosn, "Returns the current position of the particle\n")
        .def("getMass",                 &RotParticlePy::getMass, "Returns the mass of the particle\n")
      ;
    }
  }
}