← Back to team overview

yade-dev team mailing list archive

Re: (moved to yade-dev) Interaction of FrictMat and a new class of material

 

Hi Jan,
Do you think that goReverse cannot solve the problem? I would expect that your typechecking is already done by dispatcher. Is goReverse called in one of the cases?
I'm asking that because I'm not really sure if goReverse works as expected. If not we better remove it.
Cheers.
Bruno

On Saturday, February 21, 2015 00:21 CET, Jan Stránský <question261724@xxxxxxxxxxxxxxxxxxxxx> wrote:

> Question #261724 on Yade changed:
> https://answers.launchpad.net/yade/+question/261724
>
> Jan Stránský proposed the following answer:
> >
> >
> > Look, I don't get what you're doing by:
> >
> >
> > if 0: # works for both 0 and 1
> > s1=utils.sphere([0.0,0.0,0.0],0.01,fixed=True,material=Mat2)

> > s2=utils.sphere([0.0,0.0,2.0e-2],0.01,fixed=False,material=Mat1)
> > else:
> > s1=utils.sphere([0.0,0.0,0.0],0.01,fixed=True,material=Mat1)

> > s2=utils.sphere([0.0,0.0,2.0e-2],0.01,fixed=False,material=Mat2)
> >
> >
> > But if you run the file with
> >
> > s1=utils.sphere([0.0,0.0,0.0],0.01,fixed=True,material=Mat2)

> > s2=utils.sphere([0.0,0.0,2.0e-2],0.01,fixed=False,material=Mat1)
> >
> >
> > it works!
> > And if you change it to:
> >
> > s1=utils.sphere([0.0,0.0,0.0],0.01,fixed=True,material=Mat1)

> > s2=utils.sphere([0.0,0.0,2.0e-2],0.01,fixed=False,material=Mat2)
> >
> > It does not!
> >
>
> my if else is just putting your two version of s1= s2= to one file for easy
> change of them
>
> sorry, it does not work for your original files, I tried some modifications
> and it was the effect of undo/redo that I had the impression.
>
> I you modify your .cpp file, specifically
>
>   FrictMat* mat1 = YADE_CAST<FrictMat*>(b1.get());
>   CohBurgersMat* mat2 = YADE_CAST<CohBurgersMat*>(b2.get());
>
> to
>
>   int i1 = b1->getClassIndex(); // get actual material index of b1

>   int i2 = b2->getClassIndex(); // get actual material index of b2

>   int cbmi = CohBurgersMat::getClassIndexStatic();  // get index of
> CohBurgersMat
>   FrictMat* mat1;
>   CohBurgersMat* mat2;
>   if (i2 == cbmi) { // b2 is CohburgersMat and b1 is FrictMat
>   mat1 = dynamic_cast<FrictMat*>(b1.get());
>   mat2 = dynamic_cast<CohBurgersMat*>(b2.get());
>   } else if (i1 == cbmi) { // b1 is CohburgersMat and b2 is FrictMat
>   mat1 = dynamic_cast<FrictMat*>(b2.get());
>   mat2 = dynamic_cast<CohBurgersMat*>(b1.get());
>   } else { // should not happen, but to be sure..
>   LOG_FATAL("TODO");
>   }
>
> it should work. If not, let me know.
> Basically you check the types of material instances and switch materials if
> needed
> Cheers
> Jan
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to     : yade-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users
> More help   : https://help.launchpad.net/ListHelp









Follow ups