yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #01179
[svn] r1739 - in trunk: extra extra/clump gui/py pkg/common/Engine/DeusExMachina pkg/dem/Engine/StandAloneEngine
Author: eudoxos
Date: 2009-03-31 18:42:01 +0200 (Tue, 31 Mar 2009)
New Revision: 1739
Modified:
trunk/extra/Brefcom.hpp
trunk/extra/clump/Shop.cpp
trunk/extra/clump/Shop.hpp
trunk/gui/py/_utils.cpp
trunk/pkg/common/Engine/DeusExMachina/ForceEngine.cpp
trunk/pkg/common/Engine/DeusExMachina/ForceEngine.hpp
trunk/pkg/common/Engine/DeusExMachina/RotationEngine.cpp
trunk/pkg/common/Engine/DeusExMachina/RotationEngine.hpp
trunk/pkg/dem/Engine/StandAloneEngine/ElasticContactLaw.cpp
Log:
1. Remove Shop::Bex (no longer necessary)
2. Add InterpolatingDirectedForceEngine for Roger (not yet tested!)
Modified: trunk/extra/Brefcom.hpp
===================================================================
--- trunk/extra/Brefcom.hpp 2009-03-30 17:10:27 UTC (rev 1738)
+++ trunk/extra/Brefcom.hpp 2009-03-31 16:42:01 UTC (rev 1739)
@@ -200,7 +200,7 @@
public:
bool logStrain;
- BrefcomLaw(): logStrain(false) { Shop::Bex::initCache(); };
+ BrefcomLaw(): logStrain(false) { };
void action(MetaBody*);
protected:
REGISTER_CLASS_AND_BASE(BrefcomLaw,InteractionSolver);
Modified: trunk/extra/clump/Shop.cpp
===================================================================
--- trunk/extra/clump/Shop.cpp 2009-03-30 17:10:27 UTC (rev 1738)
+++ trunk/extra/clump/Shop.cpp 2009-03-31 16:42:01 UTC (rev 1739)
@@ -79,14 +79,8 @@
map<string,boost::any> Shop::defaults;
-void Shop::Bex::initCache(){}
-
-const Vector3r& Shop::Bex::force(body_id_t id,MetaBody* rb){ rb->bex.sync(); return rb->bex.getForce(id);}
-const Vector3r& Shop::Bex::momentum(body_id_t id,MetaBody* rb){ rb->bex.sync(); return rb->bex.getTorque(id);}
-
/* Apply force on contact point to 2 bodies; the force is oriented as it applies on the first body and is reversed on the second.
- *
- * Shop::Bex::initCache must have been called at some point. */
+ */
void Shop::applyForceAtContactPoint(const Vector3r& force, const Vector3r& contPt, body_id_t id1, const Vector3r& pos1, body_id_t id2, const Vector3r& pos2, MetaBody* rootBody){
rootBody->bex.addForce(id1,force);
rootBody->bex.addForce(id2,-force);
Modified: trunk/extra/clump/Shop.hpp
===================================================================
--- trunk/extra/clump/Shop.hpp 2009-03-30 17:10:27 UTC (rev 1738)
+++ trunk/extra/clump/Shop.hpp 2009-03-31 16:42:01 UTC (rev 1739)
@@ -79,17 +79,6 @@
//! Save spheres in the current simulation into a text file
static void saveSpheresToFile(string fileName);
- /*! Cache for class indices for physical actions (body external variables, Bex)
- *
- * It is necessary to populate the cache by calling initCache(); then supported
- * actions can be used like Shop::Bex::force(bodyId)+=someForce and so on.
- */
- class Bex{
- public:
- static void initCache();
- static const Vector3r& force(body_id_t, MetaBody* mb=NULL);
- static const Vector3r& momentum(body_id_t, MetaBody* mb=NULL);
- };
//! Estimate timestep based on P-wave propagation speed
static Real PWaveTimeStep(shared_ptr<MetaBody> rb=shared_ptr<MetaBody>());
Modified: trunk/gui/py/_utils.cpp
===================================================================
--- trunk/gui/py/_utils.cpp 2009-03-30 17:10:27 UTC (rev 1738)
+++ trunk/gui/py/_utils.cpp 2009-03-31 16:42:01 UTC (rev 1739)
@@ -189,7 +189,7 @@
*/
Real sumBexTorques(int mask, python::tuple _axis, python::tuple _axisPt){
shared_ptr<MetaBody> rb=Omega::instance().getRootBody();
- Shop::Bex::initCache();
+ rb->bex.sync();
Real ret=0;
Vector3r axis=tuple2vec(_axis), axisPt=tuple2vec(_axisPt);
FOREACH(const shared_ptr<Body> b, *rb->bodies){
@@ -208,9 +208,9 @@
*
*/
Real sumBexForces(int mask, python::tuple _direction){
- Shop::Bex::initCache();
shared_ptr<MetaBody> rb=Omega::instance().getRootBody();
- Real ret;
+ rb->bex.sync();
+ Real ret=0;
Vector3r direction=tuple2vec(_direction);
FOREACH(const shared_ptr<Body> b, *rb->bodies){
if(!b->maskOk(mask)) continue;
Modified: trunk/pkg/common/Engine/DeusExMachina/ForceEngine.cpp
===================================================================
--- trunk/pkg/common/Engine/DeusExMachina/ForceEngine.cpp 2009-03-30 17:10:27 UTC (rev 1738)
+++ trunk/pkg/common/Engine/DeusExMachina/ForceEngine.cpp 2009-03-31 16:42:01 UTC (rev 1739)
@@ -1,34 +1,15 @@
-/*************************************************************************
-* Copyright (C) 2004 by Janek Kozicki *
-* cosurgi@xxxxxxxxxx *
-* *
-* This program is free software; it is licensed under the terms of the *
-* GNU General Public License v2 or later. See file LICENSE for details. *
-*************************************************************************/
+// 2004 © Janek Kozicki <cosurgi@xxxxxxxxxx>
+// 2009 © Václav Šmilauer <eudoxos@xxxxxxxx>
+
#include"ForceEngine.hpp"
#include<yade/pkg-common/ParticleParameters.hpp>
#include<yade/core/MetaBody.hpp>
+#include<yade/pkg-common/LinearInterpolate.hpp>
+#include<yade/extra/Shop.hpp>
-#include<boost/foreach.hpp>
+YADE_PLUGIN("ForceEngine","InterpolatingDirectedForceEngine");
-
-ForceEngine::ForceEngine() : force(Vector3r::ZERO)
-{
-}
-
-ForceEngine::~ForceEngine()
-{
-}
-
-
-void ForceEngine::registerAttributes()
-{
- DeusExMachina::registerAttributes();
- REGISTER_ATTRIBUTE(force);
-}
-
-
void ForceEngine::applyCondition(MetaBody* ncb){
FOREACH(body_id_t id, subscribedBodies){
assert(ncb->bodies->exists(id));
@@ -36,4 +17,10 @@
}
}
-YADE_PLUGIN();
+void InterpolatingDirectedForceEngine::applyCondition(MetaBody* rb){
+ Real virtTime=wrap ? Shop::periodicWrap(rb->simulationTime,*times.begin(),*times.rbegin()) : rb->simulationTime;
+ direction.Normalize();
+ force=linearInterpolate<Real>(virtTime,times,magnitudes,_pos)*direction;
+ ForceEngine::applyCondition(rb);
+}
+
Modified: trunk/pkg/common/Engine/DeusExMachina/ForceEngine.hpp
===================================================================
--- trunk/pkg/common/Engine/DeusExMachina/ForceEngine.hpp 2009-03-30 17:10:27 UTC (rev 1738)
+++ trunk/pkg/common/Engine/DeusExMachina/ForceEngine.hpp 2009-03-31 16:42:01 UTC (rev 1739)
@@ -1,31 +1,46 @@
-/*************************************************************************
-* Copyright (C) 2004 by Janek Kozicki *
-* cosurgi@xxxxxxxxxx *
-* *
-* This program is free software; it is licensed under the terms of the *
-* GNU General Public License v2 or later. See file LICENSE for details. *
-*************************************************************************/
+// 2004 © Janek Kozicki <cosurgi@xxxxxxxxxx>
+// 2009 © Václav Šmilauer <eudoxos@xxxxxxxx>
#pragma once
#include<yade/core/DeusExMachina.hpp>
-class ForceEngine : public DeusExMachina
-{
+class ForceEngine : public DeusExMachina{
public :
- Vector3r force;
+ Vector3r force;
+ ForceEngine(): force(Vector3r::ZERO){};
+ virtual ~ForceEngine(){};
+ virtual void applyCondition(MetaBody*);
+ REGISTER_CLASS_AND_BASE(ForceEngine,DeusExMachina);
+ REGISTER_ATTRIBUTES(DeusExMachina,(force));
+};
+REGISTER_SERIALIZABLE(ForceEngine);
- ForceEngine();
- virtual ~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.
+ *
+ * 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.
+ */
+class InterpolatingDirectedForceEngine: public ForceEngine{
+ size_t _pos;
+ public:
+ //! Time readings
+ vector<Real> times;
+ //! Force magnitude readings
+ vector<Real> magnitudes;
+ //! Constant force direction (normalized automatically)
+ Vector3r direction;
+ //! wrap to the beginning of the sequence if beyond the last time point
+ bool wrap;
+ InterpolatingDirectedForceEngine(): _pos(0),direction(Vector3r::UNIT_X),wrap(false){};
+ virtual ~InterpolatingDirectedForceEngine(){};
virtual void applyCondition(MetaBody*);
-
- protected :
- virtual void registerAttributes();
- REGISTER_CLASS_NAME(ForceEngine);
- REGISTER_BASE_CLASS_NAME(DeusExMachina);
+ REGISTER_CLASS_AND_BASE(InterpolatingDirectedForceEngine,ForceEngine);
+ REGISTER_ATTRIBUTES(ForceEngine,(times)(magnitudes)(direction)(wrap));
};
+REGISTER_SERIALIZABLE(InterpolatingDirectedForceEngine);
-REGISTER_SERIALIZABLE(ForceEngine);
-
Modified: trunk/pkg/common/Engine/DeusExMachina/RotationEngine.cpp
===================================================================
--- trunk/pkg/common/Engine/DeusExMachina/RotationEngine.cpp 2009-03-30 17:10:27 UTC (rev 1738)
+++ trunk/pkg/common/Engine/DeusExMachina/RotationEngine.cpp 2009-03-31 16:42:01 UTC (rev 1739)
@@ -1,14 +1,7 @@
-/*************************************************************************
-* Copyright (C) 2004 by Olivier Galizzi *
-* olivier.galizzi@xxxxxxx *
-* Copyright (C) 2004 by Janek Kozicki *
-* cosurgi@xxxxxxxxxx *
-* *
-* This program is free software; it is licensed under the terms of the *
-* GNU General Public License v2 or later. See file LICENSE for details. *
-*************************************************************************/
+// © 2004 Olivier Galizzi <olivier.galizzi@xxxxxxx>
+// © 2004 Janek Kozicki <cosurgi@xxxxxxxxxx>
+// © 2008 Václav Šmilauer <eudoxos@xxxxxxxx>
-
#include"RotationEngine.hpp"
#include<yade/pkg-common/RigidBodyParameters.hpp>
#include<yade/core/MetaBody.hpp>
@@ -22,7 +15,7 @@
void InterpolatingSpiralEngine::applyCondition(MetaBody* rb){
Real virtTime=wrap ? Shop::periodicWrap(rb->simulationTime,*times.begin(),*times.rbegin()) : rb->simulationTime;
- angularVelocity=linearInterpolate<Real>(virtTime,times,angularVelocities,pos);
+ angularVelocity=linearInterpolate<Real>(virtTime,times,angularVelocities,_pos);
linearVelocity=angularVelocity*slope;
SpiralEngine::applyCondition(rb);
}
Modified: trunk/pkg/common/Engine/DeusExMachina/RotationEngine.hpp
===================================================================
--- trunk/pkg/common/Engine/DeusExMachina/RotationEngine.hpp 2009-03-30 17:10:27 UTC (rev 1738)
+++ trunk/pkg/common/Engine/DeusExMachina/RotationEngine.hpp 2009-03-31 16:42:01 UTC (rev 1739)
@@ -56,6 +56,8 @@
* between last and first values is done).
* */
class InterpolatingSpiralEngine: public SpiralEngine{
+ //! holder of interpolation state, should not be touched by the user.
+ size_t _pos;
public:
//! list of times at which velocities are given; must be increasing
vector<Real> times;
@@ -65,12 +67,10 @@
bool wrap;
//! axial translation per radian turn (can be negative)
Real slope;
- //! holder of interpolation state, should not be touched by the user.
- size_t pos;
- InterpolatingSpiralEngine(): wrap(false), slope(0), pos(0){}
+ InterpolatingSpiralEngine(): _pos(0), wrap(false), slope(0){}
virtual void applyCondition(MetaBody* rb);
REGISTER_CLASS_AND_BASE(InterpolatingSpiralEngine,SpiralEngine);
- REGISTER_ATTRIBUTES(SpiralEngine,(times)(angularVelocities)(wrap)(slope)(pos));
+ REGISTER_ATTRIBUTES(SpiralEngine,(times)(angularVelocities)(wrap)(slope));
};
REGISTER_SERIALIZABLE(InterpolatingSpiralEngine);
Modified: trunk/pkg/dem/Engine/StandAloneEngine/ElasticContactLaw.cpp
===================================================================
--- trunk/pkg/dem/Engine/StandAloneEngine/ElasticContactLaw.cpp 2009-03-30 17:10:27 UTC (rev 1738)
+++ trunk/pkg/dem/Engine/StandAloneEngine/ElasticContactLaw.cpp 2009-03-31 16:42:01 UTC (rev 1739)
@@ -19,7 +19,6 @@
YADE_PLUGIN("ElasticContactLaw2","ef2_Spheres_Elastic_ElasticLaw","ElasticContactLaw");
ElasticContactLaw2::ElasticContactLaw2(){
- Shop::Bex::initCache();
isCohesive=true;
}