root/src/exovector.c

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

DEFINITIONS

This source file includes following definitions.
  1. exovector

   1 /*     CalculiX - A 3-dimensional finite element program                 */
   2 /*              Copyright (C) 1998-2011 Guido Dhondt                     */
   3 /*     This subroutine                                                   */
   4 /*              Copyright (C) 2013-2014 Peter A. Gustafson                    */
   5 /*                                                                       */
   6 /*     This program is free software; you can redistribute it and/or     */
   7 /*     modify it under the terms of the GNU General Public License as    */
   8 /*     published by the Free Software Foundation(version 2);    */
   9 /*                                                                       */
  10 
  11 /*     This program is distributed in the hope that it will be useful,   */
  12 /*     but WITHOUT ANY WARRANTY; without even the implied warranty of    */ 
  13 /*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      */
  14 /*     GNU General Public License for more details.                      */
  15 
  16 /*     You should have received a copy of the GNU General Public License */
  17 /*     along with this program; if not, write to the Free Software       */
  18 /*     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         */
  19 
  20 #include <stdlib.h>
  21 #include <math.h>
  22 #include <stdio.h>
  23 #include <string.h>
  24 #include "CalculiX.h"
  25 #include "exodusII.h"
  26 #include "exo.h"
  27 
  28 void exovector(double *v, ITG *iset, ITG *ntrans, char * filabl, 
  29                ITG *nkcoords, ITG *inum, ITG *inotr, double *trab,
  30                double *co, ITG *istartset, ITG *iendset, ITG *ialset, 
  31                ITG *mi, ITG *ngraph, int exoid, ITG time_step, 
  32                int countvar, ITG nout){
  33   
  34   ITG nksegment;
  35   ITG i,j,k,l,m,n,ii,jj,kk;
  36   
  37   double a[9];
  38   
  39   /* When initializing parameter values:
  40      "g" (or "G")
  41      For global variables.
  42      "n" (or "N")
  43      For nodal variables.
  44      "e" (or "E")
  45      For element variables.
  46      "m" (or "M")
  47      For nodeset variables.
  48      "s" (or "S")
  49      For sideset variables.
  50   */
  51   
  52   int errr;
  53 
  54   int num_nod_vars=3;
  55   
  56   float *nodal_var_vals;
  57   nodal_var_vals = (float *) calloc (nout, sizeof(float));
  58   
  59   for (j=1; j<=num_nod_vars; j++){ // For each direction
  60     if(*iset==0){
  61       if((*ntrans==0)||(strcmp1(&filabl[5],"G")==0)){
  62         m=0;
  63         for(i=0;i<*nkcoords;i++){
  64           if(inum[i]<=0) continue;
  65           nodal_var_vals[m++]=v[(mi[1]+1)*i+j];
  66         }
  67       }else{
  68         m=0;
  69         for(i=0;i<*nkcoords;i++){
  70           if(inum[i]<=0) continue;
  71           if(inotr[2*i]==0){
  72             nodal_var_vals[m++]=v[(mi[1]+1)*i+j];
  73           }else{
  74             ii=(mi[1]+1)*i+1;
  75             jj=(mi[1]+1)*i+2;
  76             kk=(mi[1]+1)*i+3;
  77             FORTRAN(transformatrix,(&trab[7*(inotr[2*i]-1)],&co[3*i],a));
  78             nodal_var_vals[m++]=v[ii]*a[0+(j-1)*3]+v[jj]*a[1+(j-1)*3]+v[kk]*a[2+(j-1)*3];
  79           }
  80         }
  81       }
  82     }else{
  83       nksegment=(*nkcoords)/(*ngraph);
  84       for(k=istartset[*iset-1]-1;k<iendset[*iset-1];k++){
  85         if(ialset[k]>0){
  86           m=0;
  87           for(l=0;l<*ngraph;l++){
  88             i=ialset[k]+l*nksegment-1;
  89             if(inum[i]<=0) continue;
  90             if((*ntrans==0)||(strcmp1(&filabl[5],"G")==0)||(inotr[2*i]==0)){
  91               nodal_var_vals[m++]=v[(mi[1]+1)*i+j];
  92             }else{
  93               FORTRAN(transformatrix,(&trab[7*(inotr[2*i]-1)],&co[3*i],a));
  94               ii=(mi[1]+1)*i+1;
  95               jj=(mi[1]+1)*i+2;
  96               kk=(mi[1]+1)*i+3;
  97               nodal_var_vals[m++]=v[ii]*a[0+(j-1)*3]+v[jj]*a[1+(j-1)*3]+v[kk]*a[2+(j-1)*3];
  98             }
  99           }
 100         }else{
 101           l=ialset[k-2];
 102           do{
 103             l-=ialset[k];
 104             if(l>=ialset[k-1]) break;
 105             n=0;
 106             for(m=0;m<*ngraph;m++){
 107               i=l+m*nksegment-1;      
 108               if(inum[i]<=0) continue;
 109               if((*ntrans==0)||(strcmp1(&filabl[5],"G")==0)||(inotr[2*i]==0)){
 110                 nodal_var_vals[n++]=v[(mi[1]+1)*i+j];
 111               }else{
 112                 FORTRAN(transformatrix,(&trab[7*(inotr[2*i]-1)],&co[3*i],a));
 113                 ii=(mi[1]+1)*i+1;
 114                 jj=(mi[1]+1)*i+2;
 115                 kk=(mi[1]+1)*i+3;
 116                 nodal_var_vals[n++]=v[ii]*a[0+(j-1)*3]+v[jj]*a[1+(j-1)*3]+v[kk]*a[2+(j-1)*3];
 117               }
 118             }
 119           }while(1);
 120         }
 121       }
 122     }
 123     
 124 
 125     errr = ex_put_nodal_var (exoid, time_step, j+countvar, nout, nodal_var_vals);
 126     if (errr) printf ("ERROR storing vector data into exo file.\n");
 127   }
 128 
 129   free(nodal_var_vals);
 130   return;
 131 
 132 }

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