Beispiel #1
0
objinst & objinst::operator=(const objinst & src)
{
    if (&src == this) return *this;
    positionable::operator=(src);
    position = src.position;
    rotation = src.rotation;
    scale = src.scale;
    thisobject = src.thisobject;
    bbox = src.bbox;

    clearops(params);
    this->params = NULL;
    copyparams(this, &src);

    /* If the parameters are the same, the bounding box should be, too. */
    delete schembbox;
    if (src.schembbox) {
       schembbox = new BBox(*src.schembbox);
    }
    else
       schembbox = NULL;

    return *this;
}
Beispiel #2
0
static ddaboolean
computeGravityForce(Gravity * grav, Analysisdata * adn, int n2, int numblocks)
{
   double ** F = adn->F;

   double ** cfs = grav->contactFS;
   double ** cfn = grav->contactFN;
   double ** pforces = grav->prevforces;
   double ntol = grav->nforcetolerance; 
   double stol = grav->sforcetolerance;  
   double diff, tol;

  /* residual_tol should probably be force tolerance, which is 
   * initialized elsewhere.
   */
   double residual_tol = grav->residual_tol;
   int i, j;

   static char *gconv[6] = {"u0", "v0", "r0", "ex", "ey", "exy"};


  /* Temporary write to log file to see what the contacts are doing.
   */
   fprintf(fp.gravfile,"\nContact forces for grav step %d:\n", 
                      grav->gravTimeStep);
   fprintf(fp.gravfile,"             "
                      "current    previous iter   previous step\n");

   for (j=1;j<=n2;j++) 
   {
         fprintf(fp.gravfile,"normal     %f       %f       %f  (contact %d)\n",
                         cfn[j][2], cfn[j][1], cfn[j][0], j); 
         fprintf(fp.gravfile,"shear      %f       %f       %f  (contact %d)\n",
                         cfs[j][2], cfs[j][1], cfs[j][0], j);
   }


   fprintf(fp.gravfile,"\nContact forces for grav step %d:\n", 
                      grav->gravTimeStep);
   fprintf(fp.gravfile,"             "
                      "current    previous iter   previous step\n");


   for (j=1;j<=n2;j++) 
   {
     /* Use named constants for the array indices */
      diff = fabs(cfn[j][2]-cfn[j][0]);
      tol = fabs(ntol*cfn[j][0]);

      if (diff > tol)
      {   
         fprintf(fp.gravfile,"normal     %f       %f       %f\n",
                         cfn[j][2], cfn[j][1], cfn[j][0]); 
         fprintf(fp.gravfile,"\nfailed normal contact force convergence\n"
                            "(tolerance = %f) at contact %d of %d, continuing gravity turn on\n",
                 ntol, j, n2);
         fprintf(fp.gravfile,"Difference: %f; Tolerance: %f\n", diff, tol);
         //j = n2 + 2;
         copyparams(grav,pforces,F,numblocks);
         return FALSE;
      }

      diff = fabs(cfs[j][2]-cfs[j][0]);
      tol = fabs(stol*cfs[j][0]);
      if (diff > tol)
      {
         fprintf(fp.gravfile,"shear      %f       %f       %f\n",
                         cfs[j][2], cfs[j][1], cfs[j][0]);
         fprintf(fp.gravfile,"\nfailed shear contact force convergence \n"
                            "(tolerance = %f) at contact %d of %d, continuing gravity turn on\n",
                 stol, j, n2);
         fprintf(fp.gravfile,"Difference: %f; Tolerance: %f\n", diff, tol);
         copyparams(grav,pforces,F,numblocks);
         return FALSE;
      }
   }  /* end for each contact j */

   fprintf(fp.gravfile,"Contact normal and shear forces converged.\n");


  /* Check for convergence of unknowns */
   for (j=1; j<=numblocks; j++)
   {
      for (i=1;i<=6;i++)
      {
         if ( (fabs(pforces[j][i]) > grav->residual_tol)  &&  
                (  
                  (F[j][i] - pforces[j][i]) > fabs(residual_tol*pforces[j][i])
                )
            )
         {
            fprintf(fp.gravfile,"\nFailed at %s: current = %.12f previous = %.12f\n",
                                gconv[i], F[j][i], pforces[j][i]);
        
            copyparams(grav,pforces,F,numblocks); 
            return FALSE; 
         }
      }  /* end for each stress, strain i */
   }  /* end for each block j */

   fprintf(fp.gravfile,"Deformation parameter set converged.\n");

   fprintf(fp.gravfile,"\nGravity phase complete (%d steps) with shear tolerance = %f\n", grav->gravTimeStep, stol);
  /* This can be controlled as an option in the future.
   */
   //computeMaxDisplacement(gd);
   return TRUE;

} /* Close computeGravityforce() */