← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2825: Add LinearDragEngine

 

------------------------------------------------------------
revno: 2825
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Wed 2011-04-20 17:52:11 +0200
message:
  Add LinearDragEngine
modified:
  pkg/common/ForceEngine.cpp
  pkg/common/ForceEngine.hpp


--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'pkg/common/ForceEngine.cpp'
--- pkg/common/ForceEngine.cpp	2011-04-20 13:10:23 +0000
+++ pkg/common/ForceEngine.cpp	2011-04-20 15:52:11 +0000
@@ -11,7 +11,7 @@
 #include<yade/core/IGeom.hpp>
 #include<yade/core/IPhys.hpp>
 
-YADE_PLUGIN((ForceEngine)(InterpolatingDirectedForceEngine)(RadialForceEngine)(DragEngine));
+YADE_PLUGIN((ForceEngine)(InterpolatingDirectedForceEngine)(RadialForceEngine)(DragEngine)(LinearDragEngine));
 
 void ForceEngine::action(){
 	FOREACH(Body::id_t id, ids){
@@ -57,3 +57,23 @@
 		}
 	}
 }
+
+void LinearDragEngine::action(){
+	FOREACH(Body::id_t id, ids){
+		Body* b=Body::byId(id,scene).get();
+		if (!b) continue;
+		if (!(scene->bodies->exists(id))) continue;
+		const Sphere* sphere = dynamic_cast<Sphere*>(b->shape.get());
+		if (sphere){
+			Vector3r velSphTemp = b->state->vel;
+			Vector3r dragForce = Vector3r::Zero();
+			
+			Real b = 6*Mathr::PI*nu*sphere->radius;
+			
+			if (velSphTemp != Vector3r::Zero()) {
+				dragForce = -b*velSphTemp;
+			}
+			scene->forces.addForce(id,dragForce);
+		}
+	}
+}

=== modified file 'pkg/common/ForceEngine.hpp'
--- pkg/common/ForceEngine.hpp	2011-04-20 13:10:23 +0000
+++ pkg/common/ForceEngine.hpp	2011-04-20 15:52:11 +0000
@@ -58,3 +58,12 @@
 	);
 };
 REGISTER_SERIALIZABLE(DragEngine);
+
+class LinearDragEngine: public PartialEngine{
+	public:
+		virtual void action();
+	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.",
+		((Real,nu,0.001,,"Viscosity of the medium."))
+	);
+};
+REGISTER_SERIALIZABLE(LinearDragEngine);