← Back to team overview

yade-users team mailing list archive

Re: [Question #261724]: Interaction of FrictMat and a new class of material

 

>
>
> 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

Follow ups

References