setTag in NRotSphere
I was trying use the following piece of python script to add particles to a domain
#add the first particle to the domain:
particle=
particle.
particle.setTag(10)
sim.createParti
but I then realize that there is not a setTag for NRotSphere.
I do not know if there is a reason for not having the possibility to set a tag for this particle type or if it just a missing line of code.
After looking into the code, I decide to add the following line in the ParticlePy.cpp in Python/esys/lsm/
After recompiliing, the setTag works. I suggest to include this modification in future versions, unless there is a reason to not do that.
The new ParticlePy.cpp looks like:
///////
// //
// Copyright (c) 2003-2009 by The University of Queensland //
// Earth Systems Science Computational Centre (ESSCC) //
// http://
// //
// Primary Business: Brisbane, Queensland, Australia //
// Licensed under the Open Software License version 3.0 //
// http://
// //
///////
#include <boost/version.hpp>
#include <boost/python.hpp>
#include "Python/
namespace esys
{
namespace lsm
{
ParticlePy:
{
}
ParticlePy:
: CParticle(radius, mass, posn, Vec3(), Vec3(), id, true)
{
}
ParticlePy:
{
}
ParticlePy:
{
}
Vec3Py ParticlePy:
{
return Vec3Py(getPos());
}
void ParticlePy:
{
setPos(posn);
}
Vec3Py ParticlePy:
{
return Vec3Py(getVel());
}
void ParticlePy:
{
setVel(vel);
}
Vec3Py ParticlePy:
{
return Vec3Py(
}
Vec3Py ParticlePy:
{
return Vec3Py(
}
void ParticlePy:
{
setForce(
}
Vec3Py ParticlePy:
{
return Vec3Py(getForce());
}
void ParticlePy:
{
setForce(
}
using boost::python::arg;
void exportParticle()
{
// Check that Boost 1.34.0 or higher is being used.
// If so, disable auto-generation of C++ signatures for Epydoc
// (which stumbles over indentation in the auto-generated strings).
#if ((BOOST_VERSION / 100000 >= 1) \
&& (BOOST_VERSION / 100 % 1000 >= 34)) \
|| (BOOST_VERSION / 100000 >= 2)
#endif
boost:
.def(
(
),
"@type id: int\n"
"@kwarg id: Unique identifier for particle.\n"
"@type posn: L{Vec3<
"@kwarg posn: Initial position of particle, centre-point of sphere."
"@type radius: float\n"
"@kwarg radius: The radius of the sphere.\n"
"@type mass: float\n"
"@kwarg mass: Mass of particle."
)
)
;
}
}
}
Question information
- Language:
- English Edit question
- Status:
- Answered
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Gonzalo Tancredi for more information if necessary.