yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #00991
Re: How to communicate between two independent Engines
Hi, I forgot to paste my final solution code:
Real DampingAdjustment::convergenceValue(Body* body)
{
if (!convergenceEstimater)
{
MetaBody * ncb = dynamic_cast<MetaBody*>(body);
std::vector<shared_ptr<Engine> >::iterator itFirst = ncb->engines.begin();
std::vector<shared_ptr<Engine> >::iterator itLast = ncb->engines.end();
for ( ;itFirst!=itLast; ++itFirst )
{
if ( ( *itFirst )->getClassName() == "ConvergenceEstimater" )
{
///FIXME here should be dynamic_cast or static_cast???
convergenceEstimater = static_pointer_cast<ConvergenceEstimater>(*itFirst);
//cerr << "CCValue to be:\n" << convergenceEstimater->getCCValue() << end;
break;
}
}
}
return convergenceEstimater->getCCValue();
}
-----Original Message-----
From: yade-users-bounces@xxxxxxxxxxxxxxxx on behalf of Bruno Chareyre
Sent: Fri 5/9/2008 1:11 PM
To: yade-users@xxxxxxxxxxxxxxxx
Subject: Re: [Yade-users] How to communicate between two independent Engines
One more solution can be to scan the list of engines form inside one engine.
You have an exemple in TriaxialStateRecorder, which record variables of
TriaxialCompressionEngine.
This first part will be executed only once :
TriaxialStateRecorder.cpp, Line 69 :
if ( !triaxialCompressionEngine )
//(triaxialCompressionEngine is a pointer to an object of this type)
{
vector<shared_ptr<Engine> >::iterator itFirst =
ncb->engines.begin();
vector<shared_ptr<Engine> >::iterator itLast = ncb->engines.end();
for ( ;itFirst!=itLast; ++itFirst )
{
if ( ( *itFirst )->getClassName() ==
"TriaxialCompressionEngine" ) //|| (*itFirst)->getBaseClassName() ==
"TriaxialCompressionEngine")
{
LOG_DEBUG ( "stress controller engine found" );
triaxialCompressionEngine =
YADE_PTR_CAST<TriaxialCompressionEngine> ( *itFirst );
//triaxialCompressionEngine =
shared_ptr<TriaxialCompressionEngine>
(static_cast<TriaxialCompressionEngine*> ( (*itFirst).get()));
}
}
}
Then the initialized pointer is used to get data from the engine, like
at line 91 :
Real V = ( triaxialCompressionEngine->height ) * (
triaxialCompressionEngine->width ) * ( triaxialCompressionEngine->depth );
Your "DampingAdjustment" could just do the same and scan engines to find
a "ConvergenceEstimator".
The solution proposed by Vaçlav should work too.
Bruno
Chen, Feng a écrit :
> Hi, all:
>
> I am recently having such kind of problem, I have two costomized
> engines, one is called "ConvergenceEstimator", which is used to
> evaluate some maximumUnBalanceForce over the contactForce ratio (this
> will return a CCValue to evaluate whether the whole particle system is
> close to equilibrium), then I have another engine
> "DampingAdjustment" designed to change the initial simulation
> parameter, in my case, the damping coefficient, for example, from 0.3
> to 0.4.
>
> I have one piece of code in the preprocessor (similar to
> SDECSpheresPlane) which looks like this:
>
> ///--------------------
> ...
> rootBody->engines.push_back(ConvergenceEstimator);
> rootBody->engines.push_back(DampingAdjustment);
> ///--------------------
>
> This means my DampingAdjustment Engine needs the return values of the
> previous engine, I need to have something in DampingAdjustment like(I
> think should be in DampingAdjustment::applyCondition(Body* body)):
>
> if (convergenceEstimator->getCCVaue() <=eps)
> dampingCoefficient = 0.3;
> else
> dampingCoefficient =0.5;
>
> I think this is purely a programming problem, how to access the
> ConvergenceEstimator which is the other engine?
>
> I hope I have made my problem clear. Thank you very much!
>
> Feng Chen
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Yade-users mailing list
> Yade-users@xxxxxxxxxxxxxxxx
> https://lists.berlios.de/mailman/listinfo/yade-users
>
--
_______________
Chareyre Bruno
Maitre de conference
Institut National Polytechnique de Grenoble
Laboratoire 3S (Soils Solids Structures) - bureau E145
BP 53 - 38041, Grenoble cedex 9 - France
Tél : 33 4 56 52 86 21
Fax : 33 4 76 82 70 43
________________
_______________________________________________
Yade-users mailing list
Yade-users@xxxxxxxxxxxxxxxx
https://lists.berlios.de/mailman/listinfo/yade-users
_______________________________________________
Yade-users mailing list
Yade-users@xxxxxxxxxxxxxxxx
https://lists.berlios.de/mailman/listinfo/yade-users
Follow ups
References