yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #10630
[Branch ~yade-pkg/yade/git-trunk] Rev 3865: Move all force and torque calculation into separate function
------------------------------------------------------------
revno: 3865
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Tue 2014-04-01 16:45:46 +0200
message:
Move all force and torque calculation into separate function
Discussed and proposed by Bruno.
http://www.mail-archive.com/yade-dev@xxxxxxxxxxxxxxxxxxx/msg09742.html
added:
pkg/dem/ViscoelasticCapillarPM.hpp
modified:
pkg/dem/ViscoelasticCapillarPM.cpp
pkg/dem/ViscoelasticPM.cpp
pkg/dem/ViscoelasticPM.hpp
--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'pkg/dem/ViscoelasticCapillarPM.cpp'
--- pkg/dem/ViscoelasticCapillarPM.cpp 2014-01-30 08:09:44 +0000
+++ pkg/dem/ViscoelasticCapillarPM.cpp 2014-04-01 14:45:46 +0000
@@ -1,4 +1,4 @@
-#include"ViscoelasticPM.hpp"
+#include"ViscoelasticCapillarPM.hpp"
#include<yade/core/State.hpp>
#include<yade/pkg/dem/ScGeom.hpp>
#include<yade/core/Omega.hpp>
=== added file 'pkg/dem/ViscoelasticCapillarPM.hpp'
--- pkg/dem/ViscoelasticCapillarPM.hpp 1970-01-01 00:00:00 +0000
+++ pkg/dem/ViscoelasticCapillarPM.hpp 2014-04-01 14:45:46 +0000
@@ -0,0 +1,1 @@
+#include"ViscoelasticPM.hpp"
=== modified file 'pkg/dem/ViscoelasticPM.cpp'
--- pkg/dem/ViscoelasticPM.cpp 2014-02-07 18:20:02 +0000
+++ pkg/dem/ViscoelasticPM.cpp 2014-04-01 14:45:46 +0000
@@ -123,8 +123,23 @@
}
/* Law2_ScGeom_ViscElPhys_Basic */
-void Law2_ScGeom_ViscElPhys_Basic::go(shared_ptr<IGeom>& _geom, shared_ptr<IPhys>& _phys, Interaction* I){
+void Law2_ScGeom_ViscElPhys_Basic::go(shared_ptr<IGeom>& _geom, shared_ptr<IPhys>& _phys, Interaction* I) {
+ Vector3r force = Vector3r::Zero();
+ Vector3r torque1 = Vector3r::Zero();
+ Vector3r torque2 = Vector3r::Zero();
+ computeForceTorque(_geom, _phys, I, force, torque1, torque2);
+ if (I->isActive) {
+ const int id1 = I->getId1();
+ const int id2 = I->getId2();
+
+ addForce (id1,-force,scene);
+ addForce (id2, force,scene);
+ addTorque(id1, torque1,scene);
+ addTorque(id2, torque2,scene);
+ }
+}
+void Law2_ScGeom_ViscElPhys_Basic::computeForceTorque(shared_ptr<IGeom>& _geom, shared_ptr<IPhys>& _phys, Interaction* I, Vector3r & force, Vector3r & torque1, Vector3r & torque2) {
const ScGeom& geom=*static_cast<ScGeom*>(_geom.get());
ViscElPhys& phys=*static_cast<ViscElPhys*>(_phys.get());
@@ -179,7 +194,6 @@
if (I->isFresh(scene)) shearForce=Vector3r(0,0,0);
const Real& dt = scene->dt;
shearForce = geom.rotate(shearForce);
-
// Handle periodicity.
const Vector3r shift2 = scene->isPeriodic ? scene->cell->intrShiftPos(I->cellDist): Vector3r::Zero();
@@ -235,13 +249,7 @@
// Then no slip occurs we consider friction damping + viscous damping.
shearForceVisc = phys.cs*shearVelocity;
}
-
- if (I->isActive) {
- const Vector3r f = phys.normalForce + shearForce + shearForceVisc;
- addForce (id1,-f,scene);
- addForce (id2, f,scene);
- addTorque(id1,-c1x.cross(f)+momentResistance,scene);
- addTorque(id2, c2x.cross(f)-momentResistance,scene);
- }
+ force = phys.normalForce + shearForce + shearForceVisc;
+ torque1 = -c1x.cross(force)+momentResistance;
+ torque2 = c2x.cross(force)-momentResistance;
}
-
=== modified file 'pkg/dem/ViscoelasticPM.hpp'
--- pkg/dem/ViscoelasticPM.hpp 2014-01-30 08:09:44 +0000
+++ pkg/dem/ViscoelasticPM.hpp 2014-04-01 14:45:46 +0000
@@ -82,9 +82,11 @@
virtual void go(shared_ptr<IGeom>&, shared_ptr<IPhys>&, Interaction*);
private:
Real calculateCapillarForce(const ScGeom& geom, ViscElPhys& phys);
+ void computeForceTorque(shared_ptr<IGeom>& _geom, shared_ptr<IPhys>& _phys, Interaction* I, Vector3r & force, Vector3r & torque1, Vector3r & torque2);
public :
FUNCTOR2D(ScGeom,ViscElPhys);
YADE_CLASS_BASE_DOC(Law2_ScGeom_ViscElPhys_Basic,LawFunctor,"Linear viscoelastic model operating on :yref:`ScGeom` and :yref:`ViscElPhys`. The model is mostly based on the paper for For details see Pournin [Pournin2001]_ .");
DECLARE_LOGGER;
};
REGISTER_SERIALIZABLE(Law2_ScGeom_ViscElPhys_Basic);
+