Example #1
1
XC::MidDistanceBeamIntegration::MidDistanceBeamIntegration(int nIP,const Vector &pt)
  : ParameterIDBeamIntegration(BEAM_INTEGRATION_TAG_MidDistance,pt)
  {

    for(int i = 0; i < nIP; i++)
      {
        int key = i;
        for(int j = i+1; j < nIP; j++)
          {
            if(pts(j) < pts(key))
              {
	        key = j;
	        std::cerr << "MidDistanceBeamIntegration::MidDistanceBeamIntegration -- point are not sorted; sort before calling constructor" << std::endl;
              }
          }
        //double temp = pts(i);
        //pts(i) = pts(key);
        //pts(key) = temp;
      }

    Vector mids(nIP-1);

    for(int i = 0; i < nIP-1; i++)
      {
        mids(i) = 0.5*(pts(i)+pts(i+1));
      }

    wts(0) = mids(0);
    wts(nIP-1) = 1.0-mids(nIP-2);
    for(int i = 1; i < nIP-1; i++)
      { wts(i) = mids(i)-mids(i-1); }
  }
MidDistanceBeamIntegration::MidDistanceBeamIntegration(int nIP,
						       const Vector &pt):
  BeamIntegration(BEAM_INTEGRATION_TAG_MidDistance),
  pts(nIP), wts(nIP)
{
  for (int i = 0; i < nIP; i++) {
    if (pt(i) < 0.0 || pt(i) > 1.0)
      opserr << "MidDistanceBeamIntegration::MidDistanceBeamIntegration -- point lies outside [0,1]" << endln;

    pts(i) = pt(i);
  }

  for (int i = 0; i < nIP; i++) {
    int key = i;
    for (int j = i+1; j < nIP; j++) {
      if (pts(j) < pts(key)) {
	key = j;
	opserr << "MidDistanceBeamIntegration::MidDistanceBeamIntegration -- point are not sorted; sort before calling constructor" << endln;
      }
    }
    //double temp = pts(i);
    //pts(i) = pts(key);
    //pts(key) = temp;
  }

  Vector mids(nIP-1);

  for (int i = 0; i < nIP-1; i++) {
    mids(i) = 0.5*(pts(i)+pts(i+1));
  }

  wts(0) = mids(0);
  wts(nIP-1) = 1.0-mids(nIP-2);
  for (int i = 1; i < nIP-1; i++) {
    wts(i) = mids(i)-mids(i-1);
  }
}