1 /* CalculiX - A 3-dimensional finite element program */
2 /* Copyright (C) 1998-2021 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 <time.h>
22 #include "CalculiX.h"
23
precontact(ITG * ncont,ITG * ntie,char * tieset,ITG * nset,char * set,ITG * istartset,ITG * iendset,ITG * ialset,ITG * itietri,char * lakon,ITG * ipkon,ITG * kon,ITG * koncont,ITG * ne,double * cg,double * straight,double * co,double * vold,ITG * istep,ITG * iinc,ITG * iit,ITG * itiefac,ITG * islavsurf,ITG * islavnode,ITG * imastnode,ITG * nslavnode,ITG * nmastnode,ITG * imastop,ITG * mi,ITG * ipe,ITG * ime,double * tietol,ITG * iflagact,ITG * nintpoint,double ** pslavsurfp,double * xmastnor,double * cs,ITG * mcs,ITG * ics,double * clearini,ITG * nslavs)24 void precontact(ITG *ncont, ITG *ntie, char *tieset, ITG *nset, char *set,
25 ITG *istartset, ITG *iendset, ITG *ialset, ITG *itietri,
26 char *lakon, ITG *ipkon, ITG *kon, ITG *koncont, ITG *ne,
27 double *cg, double *straight, double *co,double *vold,
28 ITG *istep,ITG *iinc,ITG *iit,ITG *itiefac,
29 ITG *islavsurf, ITG *islavnode, ITG *imastnode,
30 ITG *nslavnode, ITG *nmastnode,ITG *imastop,ITG *mi,
31 ITG *ipe, ITG *ime,double *tietol,ITG *iflagact,
32 ITG *nintpoint,double **pslavsurfp,double *xmastnor,double *cs,
33 ITG *mcs,ITG *ics,double *clearini,ITG *nslavs){
34
35 /* authors: S. Rakotonanahary, S. Sitzmann and J. Hokkanen */
36
37 ITG i,j,ntrimax,*nx=NULL,*ny=NULL,*nz=NULL,im,
38 l,nstart,kflag,ntri,ii;
39
40 double *xo=NULL,*yo=NULL,*zo=NULL,*x=NULL,*y=NULL,*z=NULL,
41 *pslavsurf=NULL,*clearslavnode=NULL;
42
43 pslavsurf=*pslavsurfp;
44
45 /* update the location of the center of gravity of
46 the master triangles and the coefficients of their
47 bounding planes */
48
49 DMEMSET(xmastnor,0,3*nmastnode[*ntie],0.);
50
51 FORTRAN(updatecontpen,(koncont,ncont,co,vold,
52 cg,straight,mi,imastnode,nmastnode,xmastnor,
53 ntie,tieset,nset,set,istartset,
54 iendset,ialset,ipkon,lakon,kon,cs,mcs,ics));
55
56 /* determining the size of the auxiliary fields
57 (needed for the master triangle search for any
58 given location on the slave faces */
59
60 ntrimax=0;
61 for(i=0;i<*ntie;i++){
62 if(itietri[2*i+1]-itietri[2*i]+1>ntrimax)
63 ntrimax=itietri[2*i+1]-itietri[2*i]+1;
64 }
65
66 /* only at the start of a new step */
67
68 if ((*istep==1)&&(*iinc==1)&&(*iit<=0)){
69 NNEW(xo,double,ntrimax);
70 NNEW(yo,double,ntrimax);
71 NNEW(zo,double,ntrimax);
72 NNEW(x,double,ntrimax);
73 NNEW(y,double,ntrimax);
74 NNEW(z,double,ntrimax);
75 NNEW(nx,ITG,ntrimax);
76 NNEW(ny,ITG,ntrimax);
77 NNEW(nz,ITG,ntrimax);
78
79 NNEW(clearslavnode,double,3**nslavs);
80
81 FORTRAN(adjustcontactnodes,(tieset,ntie,itietri,cg,straight,
82 co,vold,xo,yo,zo,x,y,z,nx,ny,nz,istep,iinc,iit,
83 mi,imastop,nslavnode,islavnode,set,nset,istartset,
84 iendset,ialset,tietol,clearini,clearslavnode,itiefac,
85 ipkon,kon,lakon,islavsurf));
86
87 SFREE(clearslavnode);
88 SFREE(xo);SFREE(yo);SFREE(zo);SFREE(x);SFREE(y);SFREE(z);SFREE(nx);
89 SFREE(ny);SFREE(nz);
90 }
91
92 NNEW(xo,double,ntrimax);
93 NNEW(yo,double,ntrimax);
94 NNEW(zo,double,ntrimax);
95 NNEW(x,double,ntrimax);
96 NNEW(y,double,ntrimax);
97 NNEW(z,double,ntrimax);
98 NNEW(nx,ITG,ntrimax);
99 NNEW(ny,ITG,ntrimax);
100 NNEW(nz,ITG,ntrimax);
101
102 /* Calculating the location of the matched slave/master
103 integration points */
104
105 RENEW(pslavsurf,double,198);
106
107 /* pointer of islavsurf into field pslavsurf and
108 pmastsurf */
109
110 islavsurf[1]=0;
111
112 /* loop over all ties */
113
114 for(i=0;i<*ntie;i++){
115 ii=i+1;
116
117 /* only active contact ties are treated */
118
119 if(tieset[i*(81*3)+80]=='C'){
120 nstart=itietri[2*i]-1;
121 ntri=itietri[2*i+1]-nstart;
122 for(j=0;j<ntri;j++){
123 xo[j]=cg[(nstart+j)*3];
124 x[j]=xo[j];
125 nx[j]=j+1;
126 yo[j]=cg[(nstart+j)*3+1];
127 y[j]=yo[j];
128 ny[j]=j+1;
129 zo[j]=cg[(nstart+j)*3+2];
130 z[j]=zo[j];
131 nz[j]=j+1;
132 }
133 kflag=2;
134 FORTRAN(dsort,(x,nx,&ntri,&kflag));
135 FORTRAN(dsort,(y,ny,&ntri,&kflag));
136 FORTRAN(dsort,(z,nz,&ntri,&kflag));
137
138 /* loop over all slave faces belonging to the tie */
139
140 for(l=itiefac[2*i];l<=itiefac[2*i+1];l++){
141 RENEW(pslavsurf,double,3*(*nintpoint+ntri*66));
142 FORTRAN(slavintpoints,(ntie,itietri,ipkon,kon,
143 lakon,straight,nintpoint,koncont,co,vold,
144 xo,yo,zo,x,y,z,nx,ny,nz,islavsurf,
145 islavnode,nslavnode,imastop,
146 mi,ncont,ipe,ime,pslavsurf,&ii,&l,&ntri));
147 }
148 }
149 }
150 SFREE(xo);SFREE(yo);SFREE(zo);SFREE(x);SFREE(y);SFREE(z);SFREE(nx);
151 SFREE(ny);SFREE(nz);
152
153 *pslavsurfp=pslavsurf;
154
155 return;
156 }
157