← Back to team overview

yade-users team mailing list archive

how to erase a discrete element during a simulation ?

 

Hi Janeck,

I'm still on my worry about how to erase an element during a simulation :o)

When I use the following code, I can check that elements under the deletion condition ( pos[1]< -0.1 here ) disappear from BodyContainer (initially 3 elements, after deletion 2 elements), but after this I have the traditionnal message after breaking Yade : "segmentation fault".
Apparently the problem comes from "PhysicalActionContainer.hpp" where the element deleted from BodyContainer is not effectively deleted. So I tried to do a "ncb->actionParameters->erase(*itv)", but there is not any erase() among "PhysicalActionContainer.hpp" instances.

--------------------------------------------------------------------------
 
*void ElementDestroyer::action(Body * body)
{
	futureDeletes.clear();

	Vector3r pos;
	bool testX;

	MetaBody * ncb = dynamic_cast<MetaBody*>(body);

	BodyContainer::iterator bi    = ncb->bodies->begin();
	BodyContainer::iterator biEnd = ncb->bodies->end();
	for(  ; bi!=biEnd ; ++bi )
	{
		shared_ptr<Body> body = *bi;

		if( body->isDynamic )
		{
			pos = body->physicalParameters->se3.position;

			testX = ( pos[1]< -0.1 );

			if (testX)
			{
				futureDeletes.push_back(body->getId());
			}
		}
	}
	vector<unsigned int>::iterator itv;

	for(itv=futureDeletes.begin();itv!=futureDeletes.end();++itv)
		ncb->bodies->erase(*itv);
}

*--------------------------------------------------------------------------


Could you help me, because I don't know how to solve that ...

thanks


lionel

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



Follow ups