root/src/mastructrad.c

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

DEFINITIONS

This source file includes following definitions.
  1. mastructrad

   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 <stdlib.h>
  19 #include <math.h>
  20 #include <stdio.h>
  21 #include <string.h>
  22 #include "CalculiX.h"
  23 
  24 void mastructrad(ITG *ntr,ITG *nloadtr,char *sideload,ITG *ipointerrad,
  25               ITG **mast1radp,ITG **irowradp,ITG *nzsrad,
  26               ITG *jqrad,ITG *icolrad){
  27 
  28 /* determining the structure of the viewfactor and the radiation
  29    matrix (both have the same structure). Only the structure of the
  30    lower half of the matrix is determined, since the structure of
  31    the upper half is identical */
  32 
  33   char crcav[4]="   \0";
  34 
  35   ITG three=3,i,j,k,l,ii,jj,icav,jcav,*mast1rad=NULL,*irowrad=NULL,
  36       ifree,nzsrad_,nmast,isubtract,isize,kflag,istart,istartold;
  37 
  38   mast1rad=*mast1radp;
  39   irowrad=*irowradp;
  40 
  41   kflag=2;
  42   nzsrad_=*nzsrad;
  43 
  44     /* determining the position of each nonzero matrix element in
  45        the SUPERdiagonal matrix */
  46 
  47   ifree=0;
  48 
  49   for(ii=1;ii<=*ntr;ii++){
  50       i=nloadtr[ii-1]-1;
  51       strcpy1(crcav,&sideload[20*i+17],three);
  52       icav=atoi(crcav);
  53       for(jj=1;jj<=ii;jj++){
  54           j=nloadtr[jj-1]-1;
  55           strcpy1(crcav,&sideload[20*j+17],three);
  56           jcav=atoi(crcav);
  57           if(icav==jcav){
  58               insertrad(ipointerrad,&mast1rad,&irowrad,&ii,
  59                      &jj,&ifree,&nzsrad_);
  60           }
  61       }
  62   }
  63 
  64   /*   storing the nonzero nodes in the SUPERdiagonal columns:
  65        mast1rad contains the row numbers (already done),
  66        irowrad the column numbers (done in the next lines) */
  67     
  68   for(i=0;i<*ntr;++i){
  69       if(ipointerrad[i]==0){
  70           printf("*ERROR in mastructrad: zero column\n");
  71           printf("       DOF=%" ITGFORMAT "\n",i);
  72           FORTRAN(stop,());
  73       }
  74       istart=ipointerrad[i];
  75       while(1){
  76           istartold=istart;
  77           istart=irowrad[istart-1];
  78           irowrad[istartold-1]=i+1;
  79           if(istart==0) break;
  80       }
  81   }
  82   
  83   nmast=ifree;
  84   
  85   /* summary */
  86   
  87   printf(" number of radiation equations\n");
  88   printf(" %" ITGFORMAT "\n",*ntr);
  89   printf(" number of nonzero radiation matrix elements\n");
  90   printf(" %" ITGFORMAT "\n",2*nmast-*ntr);
  91   printf(" \n");
  92 
  93     /* switching from a SUPERdiagonal inventory to a SUBdiagonal one:
  94        since the nonzeros are located in symmetric positions mast1rad
  95        can be considered to contain the column numbers and irowrad the
  96        row numbers; after sorting mast1rad the following results:
  97 
  98        - irowrad contains the row numbers of the SUBdiagonal
  99          nonzero's, column per column
 100        - mast1rad contains the column numbers
 101 
 102        Furthermore, the following fields are determined:       
 103 
 104        - icolrad(i)=# SUBdiagonal nonzero's in column i
 105        - jqrad(i)= location in field irow of the first SUBdiagonal
 106          nonzero in column i  */
 107 
 108     /* ordering the column numbers in mast1rad */
 109   
 110   FORTRAN(isortii,(mast1rad,irowrad,&nmast,&kflag));
 111   
 112   /* filtering out the diagonal elements and generating icolrad and jqrad */
 113   
 114   isubtract=0;
 115   for(i=0;i<*ntr;++i){icolrad[i]=0;}
 116   k=0;
 117   for(i=0;i<nmast;++i){
 118       if(mast1rad[i]==irowrad[i]){++isubtract;}
 119       else{
 120           mast1rad[i-isubtract]=mast1rad[i];
 121           irowrad[i-isubtract]=irowrad[i];
 122           if(k!=mast1rad[i]){
 123               for(l=k;l<mast1rad[i];++l){jqrad[l]=i+1-isubtract;}
 124               k=mast1rad[i];
 125           }
 126           ++icolrad[k-1];
 127       }
 128   }
 129   nmast=nmast-isubtract;
 130   for(l=k;l<*ntr+1;++l){jqrad[l]=nmast+1;}
 131 
 132     /* sorting the row numbers within each column */
 133   
 134   for(i=0;i<*ntr;++i){
 135       if(jqrad[i+1]-jqrad[i]>0){
 136           isize=jqrad[i+1]-jqrad[i];
 137           FORTRAN(isortii,(&irowrad[jqrad[i]-1],&mast1rad[jqrad[i]-1],
 138                   &isize,&kflag));
 139       }
 140   }
 141   
 142   *nzsrad=jqrad[*ntr]-1;
 143   
 144   *mast1radp=mast1rad;
 145   *irowradp=irowrad;
 146   
 147   return;
 148 
 149 }
 150           

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