root/src/checkconvnet.c

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

DEFINITIONS

This source file includes following definitions.
  1. checkconvnet

   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 checkconvnet(ITG *icutb, ITG *iin,
  33                   double *uamt, double *uamf, double *uamp, 
  34                   double *cam1t, double *cam1f, double *cam1p,
  35                   double *cam2t, double *cam2f, double *cam2p,
  36                   double *camt, double *camf, double *camp,
  37                   ITG *icntrl, double *dtheta, double *ctrl,
  38                   double *uama,double *cam1a,double *cam2a,double *cama,
  39                   double *vamt, double *vamf, double *vamp, double *vama){
  40   
  41   ITG i0,ir,ip,ic,il,ig,ia,idivergence;
  42   
  43   double c1t,c1f,c1p,c1a;
  44   double df,dc,db,dd,ran,can,rap,ea,cae,ral;
  45 
  46   i0=ctrl[0];ir=ctrl[1];ip=ctrl[2];ic=ctrl[3];il=ctrl[4];ig=ctrl[5];ia=ctrl[7];
  47   df=ctrl[10];dc=ctrl[11];db=ctrl[12];dd=ctrl[16];
  48   ran=ctrl[18];can=ctrl[19];rap=ctrl[22];
  49   ea=ctrl[23];cae=ctrl[24];ral=ctrl[25];
  50   
  51   /* temperature */
  52   
  53   if(*iin<=ip){c1t=0.0001*ran;}
  54   else{c1t=0.0001*rap;}
  55   
  56   /* mass flow */
  57   
  58   if(*iin<=ip){c1f=0.0001*ran;}
  59   else{c1f=0.0001*rap;}
  60   
  61   /* pressure */
  62   
  63   if(*iin<=ip){c1p=0.0001*ran;}
  64   else{c1p=0.0001*rap;}
  65   
  66   /* geometry */
  67   
  68   if(*iin<=ip){c1a=0.0001*ran;}
  69   else{c1a=0.0001*rap;}
  70   
  71   if(*cam1t<*cam2t) {*cam2t=*cam1t;}
  72   if(*cam1f<*cam2f) {*cam2f=*cam1f;}
  73   if(*cam1p<*cam2p) {*cam2p=*cam1p;}
  74   if(*cam1a<*cam2a) {*cam2a=*cam1a;}
  75   
  76   /* check for convergence or divergence; 
  77      each call of radflowload.c corresponds to a thermomechanical
  78      iteration, let's call the iterations within radflowload.c
  79      subiterations;
  80      the convergence check consists of a comparison of the change in
  81      the latest subiteration with
  82         - the largest change in the present thermomechanical iteration
  83         - the largest value in the present thermomechanical iteration */
  84 
  85 /*  if(((*camt<=c1t**uamt)||(*camt<1.e-8**vamt))&&
  86      ((*camf<=c1f**uamf)||(*camf<1.e-8**vamf))&&
  87      ((*camp<=c1p**uamp)||(*camp<1.e-8**vamp))&&
  88      ((*cama<=c1a**uama)||(*cama<1.e-8**vama))&&*/
  89   if(((*camt<=c1t**uamt)||(*camt<c1t**vamt))&&
  90      ((*camf<=c1f**uamf)||(*camf<c1f**vamf))&&
  91      ((*camp<=c1p**uamp)||(*camp<c1p**vamp))&&
  92      ((*cama<=c1a**uama)||(*cama<c1a**vama))&&
  93      (*iin>3)){
  94       
  95       /* increment convergence reached */
  96       
  97       printf("      flow network: convergence in gas iteration %" ITGFORMAT " \n\n",*iin);
  98       *icntrl=1;
  99       *icutb=0;
 100   }
 101   
 102   else {
 103 
 104       idivergence=0;
 105 
 106       /* divergence based on temperatures */
 107       
 108       if((*iin>=20*i0)||(fabs(*camt)>1.e20)){
 109           if((*cam1t>=*cam2t)&&(*camt>=*cam2t)&&(*camt>c1t**uamt)){
 110               idivergence=1;
 111           }
 112       }
 113 
 114       /* divergence based on the mass flux */
 115       
 116       if((*iin>=20*i0)||(fabs(*camf)>1.e20)){
 117           if((*cam1f>=*cam2f)&&(*camf>=*cam2f)&&(*camf>c1f**uamf)){
 118               idivergence=1;
 119           }
 120       }
 121 
 122       /* divergence based on pressures */
 123       
 124       if((*iin>=20*i0)||(fabs(*camp)>1.e20)){
 125           if((*cam1p>=*cam2p)&&(*camp>=*cam2p)&&(*camp>c1p**uamp)){
 126               idivergence=1;
 127           }
 128       }
 129 
 130       /* divergence based on geometry */
 131       
 132       if((*iin>=20*i0)||(fabs(*cama)>1.e20)){
 133           if((*cam1a>=*cam2a)&&(*cama>=*cam2a)&&(*cama>c1a**uama)){
 134               idivergence=1;
 135           }
 136       }
 137 
 138       /* divergence based on the number of iterations */
 139 
 140       if(*iin>20*ic) idivergence=1;
 141 
 142       /* divergence based on singular matrix or negative pressures */
 143 
 144       if(*iin==0) idivergence=1;
 145       
 146       if(idivergence==1){
 147           *dtheta=*dtheta*df;
 148           printf("\n divergence; the increment size is decreased to %e\n",*dtheta);
 149           printf(" the increment is reattempted\n\n");
 150           *iin=0;
 151           (*icutb)++;
 152           if(*icutb>ia){
 153             printf("\n *ERROR: too many cutbacks\n");
 154             FORTRAN(stop,());
 155           }
 156       }else{
 157                   printf("      no convergence\n\n"); 
 158       }
 159   }
 160   return;
 161 }

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