← Back to team overview

yade-users team mailing list archive

element insertion during a simulation

 

Hello,

I currently try to insert spherical elements during a simulation.
For this purpose I put a class named "Sphere_Insertion" (joined here) in the following folder : /yade-all-0.10.0/yade-packages/yade-package-dem/src/Engine/StandAloneEngine

After its creation, my new element doesn't move. After further investigation I saw that it has no mass. Moreover when occuring a contact between my new element and another element, my new element still desn't move. Another thing I noted is that if I give an initial velocity not equal to zero to my new element, it moves at this velocity.

Maybe these informations would have seemed fuzzy, but if you have an idea ...

Thank you

Lionel Favier
/*************************************************************************
*  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. *
*************************************************************************/

#include "Sphere_Insertion.hpp"

#include "BodyMacroParameters.hpp"

#include <yade/yade-package-common/AABB.hpp>
#include <yade/yade-package-common/Sphere.hpp>
#include <yade/yade-package-common/InteractingSphere.hpp>

#include <yade/yade-package-common/ParticleParameters.hpp>
#include <yade/yade-package-common/BodyRedirectionVector.hpp>
#include <yade/yade-package-common/InteractionVecSet.hpp>
#include <yade/yade-package-common/PhysicalActionVectorVector.hpp>

#include <yade/yade-package-common/MetaInteractingGeometry.hpp>

#include <yade/yade-core/Body.hpp>

#include <yade/yade-core/Omega.hpp>
#include <yade/yade-core/MetaBody.hpp>

Sphere_Insertion::Sphere_Insertion () : StandAloneEngine()
{
	interval = 5;
	position = Vector3r(0,9,0);
}

void Sphere_Insertion::registerAttributes()
{
	StandAloneEngine::registerAttributes();
	REGISTER_ATTRIBUTE(interval);
	REGISTER_ATTRIBUTE(position);
}

bool Sphere_Insertion::isActivated()
{
	return (Omega::instance().getCurrentIteration() /*% interval*/ == 2);
}

void Sphere_Insertion::action(Body * body)
{
	MetaBody * ncb = dynamic_cast<MetaBody*>(body);

	shared_ptr<Body> b;
	createSphere(b,position);
	ncb->bodies->insert(b);

cerr << "élément inséré" << endl;

}

void Sphere_Insertion::createSphere(shared_ptr<Body>& body, Vector3r position)
{
	body = shared_ptr<Body>(new Body(0,1));
	shared_ptr<BodyMacroParameters> physics(new BodyMacroParameters);
	shared_ptr<AABB> aabb(new AABB);
	shared_ptr<Sphere> gSphere(new Sphere);
	shared_ptr<InteractingSphere> iSphere(new InteractingSphere);
	
	Quaternionr q;
	q.fromAxisAngle( Vector3r(0,0,1),0);

	Real radius 			= 5;

	body->isDynamic 		= true;

	physics->angularVelocity	= Vector3r(0,0,0);
	physics->velocity		= Vector3r(0,0,0);
	
	physics->mass			= 4.0/3.0*Mathr::PI*radius*radius*radius*2500;

cerr << "masse de l'élément à sa création " << physics->mass << endl;

	physics->inertia		= Vector3r(2.0/5.0*physics->mass*radius*radius,2.0/5.0*physics->mass*radius*radius,2.0/5.0*physics->mass*radius*radius);

	physics->se3			= Se3r(position,q);
	physics->young			= 15000000.0;//youngModulus;
	physics->poisson		= 0.21;//poissonRatio;
	physics->frictionAngle		= 28/*sphereFrictionDeg*/ * Mathr::PI/180.0;

	aabb->diffuseColor		= Vector3r(0,1,0);

	gSphere->radius			= radius;
	gSphere->diffuseColor		= Vector3f(Mathf::unitRandom(),Mathf::unitRandom(),Mathf::unitRandom());
	gSphere->wire			= false;
	gSphere->visible		= true;
	gSphere->shadowCaster		= true;
	
	iSphere->radius			= radius;
	iSphere->diffuseColor		= Vector3f(0.8,0.3,0.3);

	body->interactionGeometry	= iSphere;
	body->geometricalModel		= gSphere;
	body->boundingVolume		= aabb;
	body->physicalParameters	= physics;
}

/*************************************************************************
*  Copyright (C) 2004 by Olivier Galizzi                                 *
*  olivier.galizzi@xxxxxxx                                               *
*                                                                        *
*  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. *
*************************************************************************/

#ifndef SPHERE_INSERTION_HPP
#define SPHERE_INSERTION_HPP

#include <yade/yade-core/DataRecorder.hpp>
#include <string>
#include <fstream>

class Sphere_Insertion : public StandAloneEngine
{
	private :
		int		interval;

		Vector3r	position;	

	public :
		void createSphere(shared_ptr<Body>& body, Vector3r position);
// 		void positionRootBody(shared_ptr<MetaBody>& rootBody);

		Sphere_Insertion ();

		virtual void action(Body * body);
		virtual bool isActivated();
		virtual void registerAttributes();



	protected :
	REGISTER_CLASS_NAME(Sphere_Insertion);
	REGISTER_BASE_CLASS_NAME(StandAloneEngine);
};

REGISTER_SERIALIZABLE(Sphere_Insertion,false);

#endif // SPHERE_INSERTION_HPP

_______________________________________________
Yade-users mailing list
Yade-users@xxxxxxxxxxxxxxxx
https://lists.berlios.de/mailman/listinfo/yade-users

Follow ups