root/src/tiedcontact.c

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

DEFINITIONS

This source file includes following definitions.
  1. tiedcontact

   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 
  23 void tiedcontact(ITG *ntie, char *tieset, ITG *nset, char *set,
  24                ITG *istartset, ITG *iendset, ITG *ialset,
  25                char *lakon, ITG *ipkon, ITG *kon,
  26                double *tietol,
  27                ITG *nmpc, ITG *mpcfree, ITG *memmpc_,
  28                ITG **ipompcp, char **labmpcp, ITG **ikmpcp, ITG **ilmpcp,
  29                double **fmpcp, ITG **nodempcp, double **coefmpcp,
  30                ITG *ithermal, double *co, double *vold, ITG *cfd,
  31                ITG *nmpc_, ITG *mi, ITG *nk,ITG *istep,ITG *ikboun,
  32                ITG *nboun,char *kind1,char *kind2){
  33 
  34   char *labmpc=NULL;
  35 
  36   ITG *itietri=NULL,*koncont=NULL,nconf,i,k,*nx=NULL,im,
  37       *ny=NULL,*nz=NULL,*ifaceslave=NULL,*istartfield=NULL,
  38       *iendfield=NULL,*ifield=NULL,ntrimax,index,
  39       ncont,ncone,*ipompc=NULL,*ikmpc=NULL,
  40       *ilmpc=NULL,*nodempc=NULL,ismallsliding=0,neq,neqterms,
  41       nmpctied,mortar=0,*ipe=NULL,*ime=NULL,*imastop=NULL,ifreeme;
  42 
  43   double *xo=NULL,*yo=NULL,*zo=NULL,*x=NULL,*y=NULL,*z=NULL,
  44     *cg=NULL,*straight=NULL,*fmpc=NULL,*coefmpc=NULL;
  45 
  46   ipompc=*ipompcp;labmpc=*labmpcp;ikmpc=*ikmpcp;ilmpc=*ilmpcp;
  47   fmpc=*fmpcp;nodempc=*nodempcp;coefmpc=*coefmpcp;
  48 
  49   /* identifying the slave surfaces as nodal or facial surfaces */
  50 
  51   NNEW(ifaceslave,ITG,*ntie);
  52 
  53   FORTRAN(identifytiedface,(tieset,ntie,set,nset,ifaceslave,kind1));
  54 
  55   /* determining the number of triangles of the triangulation
  56      of the master surface and the number of entities on the
  57      slave side */
  58 
  59   FORTRAN(allocont,(&ncont,ntie,tieset,nset,set,istartset,iendset,
  60           ialset,lakon,&ncone,tietol,&ismallsliding,kind1,
  61           kind2,&mortar,istep));
  62 
  63   if(ncont==0){
  64       SFREE(ifaceslave);return;
  65   }
  66 
  67   /* allocation of space for the triangulation; 
  68      koncont(1..3,i): nodes belonging to triangle i
  69      koncont(4,i): face label to which the triangle belongs =
  70      10*element+side number */
  71 
  72   NNEW(itietri,ITG,2**ntie);
  73   NNEW(koncont,ITG,4*ncont);
  74 
  75   /* triangulation of the master surface */
  76 
  77   FORTRAN(triangucont,(&ncont,ntie,tieset,nset,set,istartset,iendset,
  78           ialset,itietri,lakon,ipkon,kon,koncont,kind1,kind2,co,nk));
  79   
  80   /* catalogueing the neighbors of the master triangles */
  81   
  82   RENEW(ipe,ITG,*nk);
  83   RENEW(ime,ITG,12*ncont);
  84   DMEMSET(ipe,0,*nk,0.);
  85   DMEMSET(ime,0,12*ncont,0.);
  86   NNEW(imastop,ITG,3*ncont);
  87 
  88   FORTRAN(trianeighbor,(ipe,ime,imastop,&ncont,koncont,
  89                         &ifreeme));
  90 
  91   SFREE(ipe);SFREE(ime);
  92 
  93   /* allocation of space for the center of gravity of the triangles
  94      and the 4 describing planes */
  95 
  96   NNEW(cg,double,3*ncont);
  97   NNEW(straight,double,16*ncont);
  98   
  99   FORTRAN(updatecont,(koncont,&ncont,co,vold,cg,straight,mi));
 100   
 101   /* determining the nodes belonging to the slave face surfaces */
 102 
 103   NNEW(istartfield,ITG,*ntie);
 104   NNEW(iendfield,ITG,*ntie);
 105   NNEW(ifield,ITG,8*ncone);
 106 
 107   FORTRAN(nodestiedface,(tieset,ntie,ipkon,kon,lakon,set,istartset,
 108        iendset,ialset,nset,ifaceslave,istartfield,iendfield,ifield,
 109        &nconf,&ncone,kind1));
 110 
 111   /* determining the maximum number of equations neq */
 112 
 113   if(*cfd==1){
 114     if(ithermal[1]<=1){
 115       neq=4;
 116     }else{
 117       neq=5;
 118     }
 119   }else{
 120     if(ithermal[1]<=1){
 121       neq=3;
 122     }else if(ithermal[1]==2){
 123       neq=1;
 124     }else{
 125       neq=4;
 126     }
 127   }
 128   neq*=(ncone+nconf);
 129 
 130   /* reallocating the MPC fields for the new MPC's
 131      ncone: number of MPC'S due to nodal slave surfaces
 132      nconf: number of MPC's due to facal slave surfaces */  
 133 
 134   RENEW(ipompc,ITG,*nmpc_+neq);
 135   RENEW(labmpc,char,20*(*nmpc_+neq)+1);
 136   RENEW(ikmpc,ITG,*nmpc_+neq);
 137   RENEW(ilmpc,ITG,*nmpc_+neq);
 138   RENEW(fmpc,double,*nmpc_+neq);
 139 
 140   /* determining the maximum number of terms;
 141      expanding nodempc and coefmpc to accommodate
 142      those terms */
 143   
 144   neqterms=9*neq;
 145   index=*memmpc_;
 146   (*memmpc_)+=neqterms;
 147   RENEW(nodempc,ITG,3**memmpc_);
 148   RENEW(coefmpc,double,*memmpc_);
 149   for(k=index;k<*memmpc_;k++){
 150       nodempc[3*k-1]=k+1;
 151   }
 152   nodempc[3**memmpc_-1]=0;
 153 
 154   /* determining the size of the auxiliary fields */
 155   
 156   ntrimax=0;
 157   for(i=0;i<*ntie;i++){
 158     if(itietri[2*i+1]-itietri[2*i]+1>ntrimax)
 159       ntrimax=itietri[2*i+1]-itietri[2*i]+1;
 160   }
 161   NNEW(xo,double,ntrimax);
 162   NNEW(yo,double,ntrimax);
 163   NNEW(zo,double,ntrimax);
 164   NNEW(x,double,ntrimax);
 165   NNEW(y,double,ntrimax);
 166   NNEW(z,double,ntrimax);
 167   NNEW(nx,ITG,ntrimax);
 168   NNEW(ny,ITG,ntrimax);
 169   NNEW(nz,ITG,ntrimax);
 170   
 171   /* generating the tie MPC's */
 172 
 173   FORTRAN(gentiedmpc,(tieset,ntie,itietri,ipkon,kon,
 174           lakon,set,istartset,iendset,ialset,cg,straight,
 175           koncont,co,xo,yo,zo,x,y,z,nx,ny,nz,nset,
 176           ifaceslave,istartfield,iendfield,ifield,
 177           ipompc,nodempc,coefmpc,nmpc,&nmpctied,mpcfree,ikmpc,ilmpc,
 178           labmpc,ithermal,tietol,cfd,&ncont,imastop,ikboun,nboun,kind1));
 179 
 180   (*nmpc_)+=nmpctied;
 181   
 182   SFREE(xo);SFREE(yo);SFREE(zo);SFREE(x);SFREE(y);SFREE(z);SFREE(nx);
 183   SFREE(ny);SFREE(nz);SFREE(imastop);
 184 
 185   SFREE(ifaceslave);SFREE(istartfield);SFREE(iendfield);SFREE(ifield);
 186   SFREE(itietri);SFREE(koncont);SFREE(cg);SFREE(straight);
 187 
 188   /* reallocating the MPC fields */
 189 
 190   /*  RENEW(ipompc,ITG,nmpc_);
 191   RENEW(labmpc,char,20*nmpc_+1);
 192   RENEW(ikmpc,ITG,nmpc_);
 193   RENEW(ilmpc,ITG,nmpc_);
 194   RENEW(fmpc,double,nmpc_);*/
 195 
 196   *ipompcp=ipompc;*labmpcp=labmpc;*ikmpcp=ikmpc;*ilmpcp=ilmpc;
 197   *fmpcp=fmpc;*nodempcp=nodempc;*coefmpcp=coefmpc;
 198 
 199   /*  for(i=0;i<*nmpc;i++){
 200     j=i+1;
 201     FORTRAN(writempc,(ipompc,nodempc,coefmpc,labmpc,&j));
 202     }*/
 203 
 204   return;
 205 }

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