root/src/checkinclength.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. checkinclength

   1 /*     CalculiX - A 3-dimensional finite element program                 */
   2 /*              Copyright (C) 1998-2015 Guido Dhondt                          */
   3 
   4 /*     This program is free software; you can redistribute it and/or     */
   5 /*     modify it under the terms of the GNU General Public License as    */
   6 /*     published by the Free Software Foundation(version 2);    */
   7 /*                    */
   8 
   9 /*     This program is distributed in the hope that it will be useful,   */
  10 /*     but WITHOUT ANY WARRANTY; without even the implied warranty of    */ 
  11 /*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      */
  12 /*     GNU General Public License for more details.                      */
  13 
  14 /*     You should have received a copy of the GNU General Public License */
  15 /*     along with this program; if not, write to the Free Software       */
  16 /*     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         */
  17 
  18 #include <stdio.h>
  19 #include <math.h>
  20 #include <stdlib.h>
  21 #include "CalculiX.h"
  22 #ifdef SPOOLES
  23    #include "spooles.h"
  24 #endif
  25 #ifdef SGI
  26    #include "sgi.h"
  27 #endif
  28 #ifdef TAUCS
  29    #include "tau.h"
  30 #endif
  31 
  32 void checkinclength(double *time,double *ttime,double *theta, double *dtheta,
  33           ITG *idrct, double *tper,double *tmax, double *tmin, double *ctrl, 
  34           double *amta,ITG *namta, ITG *itpamp, ITG *inext, double *dthetaref, 
  35           ITG *itp,ITG *jprint, ITG *jout){
  36 
  37     ITG id,istart,iend,inew,ireduceincrement;
  38     double reftime;
  39 
  40     ITG i0,ir,ip,ic,il,ig,ia;
  41     double df,dc,db,dd,ran,can,rap,ea,cae,ral,da;
  42     i0=ctrl[0];ir=ctrl[1];ip=ctrl[2];ic=ctrl[3];il=ctrl[4];ig=ctrl[5];ia=ctrl[7];
  43     df=ctrl[10];dc=ctrl[11];db=ctrl[12];da=ctrl[13];dd=ctrl[16];
  44     ran=ctrl[18];can=ctrl[19];rap=ctrl[22];
  45     ea=ctrl[23];cae=ctrl[24];ral=ctrl[25];
  46 
  47     /* check whether the new increment size is not too big */
  48     
  49     if(*dtheta>*tmax){
  50         *dtheta=*tmax;
  51 //      printf(" the increment size exceeds thetamax and is decreased to %e\n\n",*dtheta**tper);
  52     } 
  53     
  54     /* if itp=1 the increment just finished ends at a time point */
  55     
  56     if((*itpamp>0)&&(*idrct==0)){
  57         if(namta[3**itpamp-1]<0){
  58             reftime=*ttime+*time+(*dtheta)**tper;
  59         }else{
  60             reftime=*time+(*dtheta)**tper;
  61         }
  62         istart=namta[3**itpamp-3];
  63         iend=namta[3**itpamp-2];
  64         FORTRAN(identamta,(amta,&reftime,&istart,&iend,&id));
  65         if(id<istart){
  66             inew=istart;
  67         }else{
  68             inew=id+1;
  69         }
  70 //      printf("istart=%" ITGFORMAT ",iend=%" ITGFORMAT ",inext=%" ITGFORMAT ",inew=%" ITGFORMAT "\n",istart,iend,*inext,inew);
  71 
  72             /* inew: smallest time point exceeding time+dtheta*tper
  73                inext: smallest time point exceeding time */
  74 
  75         /* the check with *tmin
  76            was introduced to circumvent the following problem: if the new data point is
  77            smaller than the next data point, but the distance is very small, the next *dheta
  78            calculated a few lines below may be zero due to the subtraction of two nearly equal
  79            numbers; a zero *dtheta leads to a fatal error */
  80 
  81         ireduceincrement=0;
  82         if(*inext<iend){
  83             if(fabs((amta[2**inext-2]-reftime)/(*tper))<*tmin){
  84                 ireduceincrement=1;
  85             }
  86         }
  87 
  88         if((*inext<inew)||(ireduceincrement==1)){
  89 //      if((*inext<inew)||(fabs((amta[2**inext-2]-reftime)/(*tper))<*tmin)){
  90           //    if((*inext<inew)||(fabs((amta[2**inext-2]-reftime))<1.e-10)){
  91           
  92             if(namta[3**itpamp-1]<0){
  93                 *dtheta=(amta[2**inext-2]-*ttime-*time)/(*tper);
  94             }else{
  95                 *dtheta=(amta[2**inext-2]-*time)/(*tper);
  96             }
  97             (*inext)++;
  98             *itp=1;
  99 //          printf(" the increment size exceeds a time point and is decreased to %e\n\n",*dtheta**tper);
 100         }else{*itp=0;}
 101     }
 102 
 103     /* check whether the step length is not exceeded */
 104 
 105     if(*dtheta>1.-*theta){
 106         *dtheta=1.-*theta;
 107         *dthetaref=*dtheta;
 108         printf(" the increment size exceeds the remainder of the step and is decreased to %e\n\n",*dtheta**tper);
 109 //      if(*dtheta<=1.e-6){(*ttime)+=(*dtheta**tper);}
 110     }
 111     
 112     return;
 113 }

/* [<][>][^][v][top][bottom][index][help] */