Help for delete beam between two SetOfs.

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Help for delete beam between two SetOfs.

LE Ba Danh
Hello,

I have a small function in PlugIn of Granoo 0.0, it run well. But, it does not work with Granoo 2.0.
Can you help me make an update this function with Granoo2.0?

void
CreateDomains::DeleteBeamsBetweenFiberAndMatrix()
{    
  SetOfDE & demFiber        =  SetOfDE::Get("Fiber");
  SetOfDE & demMatrix       =  SetOfDE::Get("Matrix");
  SetOfBO * beamToBeDeleted =  new SetOfBO("BeamToBeDeleted");
 
  for (unsigned int i=0; i < demFiber.GetTotItemNumber(); ++i)
    {
      DEM::SetOfBase<DEM::Bond<_3D> > & bondSet = demFiber[i]->GetBondSet();
      for (unsigned int j=0; j < bondSet.GetTotItemNumber(); ++j)
        {
          DE & de1 = bondSet[j]->GetDiscreteElement1();
          DE & de2 = bondSet[j]->GetDiscreteElement2();
          // choose the discrete element at the other end of the beam:
          DE * de = &de1;
          if (&de1 == demFiber[i] )
            {
              de = & de2;
            }
          // look if de is in fiber or matrix... iy yes, append the beam to BeamToBeDeleted:
          if (demMatrix.Contain(de))
            {
              beamToBeDeleted->AddItem(bondSet[j]);
            }
        }
    }
    // destroy all the beams in beamToBeDeleted:
    beamToBeDeleted->ClearAndDelete();
}


Thank for your help.

Danh
Reply | Threaded
Open this post in threaded view
|

Re: Help for delete beam between two SetOfs.

Damien André
Administrator
Hello,
Your code sounds good, where is your problem ?
During compilation, execution ?


Could you give us some details on your problem ?
Reply | Threaded
Open this post in threaded view
|

Re: Help for delete beam between two SetOfs.

LE Ba Danh
Hi Damien,
1. The error appear during compilation:


You find attached my PlugIn. Can you help me correct in my PlugIn?

2. For the create a new setOf from 2 SetOfs, i did as you say:
    Core::SetOf<DEM::DiscreteElement> inter("LoadFiber"); // Create a new setOf
    inter.Intersection(xMinSet, yMaxSet); // Now, this setOf is the intersection
But the new setOf "LoadFiber" does not appear in gdd file.

Thank for your help my friend.

Danh
DCBtest.gz
Reply | Threaded
Open this post in threaded view
|

Re: Help for delete beam between two SetOfs.

Damien André
Administrator
Hello, try this
void
CreateDomains::DeleteBeamsBetweenFiberAndMatrix()
{    
  SetOfDE & demFiber        =  SetOfDE::Get("Fiber");
  SetOfDE & demMatrix       =  SetOfDE::Get("Matrix");
  SetOfBO * beamToBeDeleted =  new SetOfBO("BeamToBeDeleted");
 
  for (unsigned int i=0; i < demFiber.GetTotItemNumber(); ++i)
    {
      Core::SetOfBase<DEM::Bond > & bondSet = demFiber[i]->GetBondSet();
      for (unsigned int j=0; j < bondSet.GetTotItemNumber(); ++j)
        {
          DEM::Element & de1 = bondSet[j]->GetElement1();
          DEM::Element & de2 = bondSet[j]->GetElement2();
          // choose the discrete element at the other end of the beam:
          DEM::Element * de = &de1;
          if (&de1 == demFiber[i] )
            {
              de = & de2;
            }
          // look if de is in fiber or matrix... iy yes, append the beam to BeamToBeDeleted:
          if (demMatrix.Contain(de))
            {
              beamToBeDeleted->AddItem(bondSet[j]);
            }
        }
    }
    // destroy all the beams in beamToBeDeleted:
    beamToBeDeleted->ClearAndDelete();
} 


Be aware, the "SetOfDE" must be "Core::SetOf<DEM::Element>"... Good luck !
Reply | Threaded
Open this post in threaded view
|

Re: Help for delete beam between two SetOfs.

LE Ba Danh
Thank Damien,
It not yet working:



Thank for your help,

Danh
Reply | Threaded
Open this post in threaded view
|

Re: Help for delete beam between two SetOfs.

Damien André
Administrator
And this ?
void
CreateDomains::DeleteBeamsBetweenFiberAndMatrix()
{    
  SetOfDE & demFiber        =  SetOfDE::Get("Fiber");
  SetOfDE & demMatrix       =  SetOfDE::Get("Matrix");
  SetOfBO * beamToBeDeleted =  new SetOfBO("BeamToBeDeleted");
 
  for (unsigned int i=0; i < demFiber.GetTotItemNumber(); ++i)
    {
      Core::SetOfBase<DEM::Bond > & bondSet = demFiber[i]->GetBondSet();
      for (unsigned int j=0; j < bondSet.GetTotItemNumber(); ++j)
        {
          const DEM::Element & de1 = bondSet[j]->GetElement1();
          const DEM::Element & de2 = bondSet[j]->GetElement2();
          // choose the discrete element at the other end of the beam:
          const DEM::Element * de = &de1;
          if (&de1 == demFiber[i] )
            {
              de = & de2;
            }
          // look if de is in fiber or matrix... iy yes, append the beam to BeamToBeDeleted:
          if (demMatrix.Contain(dynamic_cast<const DEM::DiscreteElement *>(de)))
            {
              beamToBeDeleted->AddItem(bondSet[j]);
            }
        }
    }
    // destroy all the beams in beamToBeDeleted:
    beamToBeDeleted->ClearAndDelete();
} 


Reply | Threaded
Open this post in threaded view
|

Re: Help for delete beam between two SetOfs.

LE Ba Danh
Yes, It works.
Many thank my friend.

Danh