/* -------------------------------------------------------------------- */ /* CALCULIX */ /* - GRAPHICAL INTERFACE - */ /* */ /* A 3-dimensional pre- and post-processor for finite elements */ /* Copyright (C) 1996 Klaus Wittig */ /* */ /* This program is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU General Public License as */ /* published by the Free Software Foundation; version 2 of */ /* the License. */ /* */ /* This program is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* -------------------------------------------------------------------- */ #include #define TEST 0 #define N_CLOSEST_NODES 10 extern SpecialSet specialset[1]; extern unsigned char printFlag; /* printf 1:on 0:off */ extern Sets *set; /* must! else pre_seta will change the address */ int mergeCluster(Cluster *cluster, int c1, int c2) { int i,n; int sum_n=0, *cnode=NULL, mergFlag=0; /* add both node-lists */ if((cnode =(int *)malloc((cluster[c1].nn + cluster[c2].nn+1) *sizeof(int)))==NULL) { errMsg("\n\n ERROR: malloc failed for cluster\n" ); return(-1); } for(i=0; i0) { for (c2=c1+1; c20) { i=mergeCluster(cluster, c1, c2 ); if(i>0) mergFlag=1; } } } while (mergFlag==1); /* stop if no cluster found another cluster with a common node */ /* define a set per remaining cluster */ e=sum_c; sum_c=0; for (c1=0; c10) { sum_c++; sprintf( setname, "%s%d", specialset->cf,sum_c); for (n=0; nnmax, set, e_enqire, &ctri3, &tri3_index, &ntri_nodes); delSet("-eset"); if(printFlag) printf (" %d ctri3 created from elements\n\n", sum_tri3 ); if(!sum_tri3) { errMsg ("ERROR: found no valid element\n\n" ); return(-1); } /* get the dimensions of a cubus in which the set2-nodes are located */ xmin=ymin=zmin=MAX_FLOAT; xmax=ymax=zmax=-MAX_FLOAT; for (j=0; j node[set[set2].node[j]].nx) xmin = node[set[set2].node[j]].nx; if(xmax < node[set[set2].node[j]].nx) xmax = node[set[set2].node[j]].nx; if(ymin > node[set[set2].node[j]].ny) ymin = node[set[set2].node[j]].ny; if(ymax < node[set[set2].node[j]].ny) ymax = node[set[set2].node[j]].ny; if(zmin > node[set[set2].node[j]].nz) zmin = node[set[set2].node[j]].nz; if(zmax < node[set[set2].node[j]].nz) zmax = node[set[set2].node[j]].nz; } xmax+=tol; xmin-=tol; ymax+=tol; ymin-=tol; zmax+=tol; zmin-=tol; if ( (rsort = (Rsort *)malloc( (set[set2].anz_n+1) * sizeof(Rsort))) == NULL ) { printf("ERROR: realloc failed: Rsort\n\n" ); return(-1); } if((int)N_CLOSEST_NODES xmax) goto next_node; if(node[set[set1].node[i]].nx < xmin) goto next_node; if(node[set[set1].node[i]].ny > ymax) goto next_node; if(node[set[set1].node[i]].ny < ymin) goto next_node; if(node[set[set1].node[i]].nz > zmax) goto next_node; if(node[set[set1].node[i]].nz < zmin) goto next_node; /* suche die naechst-liegenden indep-nodes */ for (j=0; j offset*offset ) { min_offset=offset*offset; elbuf=e; offsetbuf=offset;} } } } if(printFlag) printf("min_offset!=(double)MAXVALUE:%d tol*tol>=offsetbuf*offsetbuf:%d\n", min_offset!=(double)MAXVALUE,tol*tol>=offsetbuf*offsetbuf); if((min_offset!=(double)MAXVALUE)&&(tol*tol>=offsetbuf*offsetbuf)) { if(printFlag) printf("closest tri3:%d (%d %d %d)for node:%d, offset:%lf\n", elbuf+1, ctri3[elbuf].nod[0],ctri3[elbuf].nod[1],ctri3[elbuf].nod[2], set[set1].node[i], offsetbuf); if((dep =(int *)realloc((int *)dep, (sum_dep+2) *sizeof(int)))==NULL) { errMsg("\n\n ERROR: realloc failed\n" ); return(-1); } dep[sum_dep]=set[set1].node[i]; sum_dep++; if((ind =(int *)realloc((int *)ind, (sum_ind+4) *sizeof(int)))==NULL) { errMsg("\n\n ERROR: realloc failed\n" ); return(-1); } ind[sum_ind]=ctri3[elbuf].nod[0]; sum_ind++; ind[sum_ind]=ctri3[elbuf].nod[1]; sum_ind++; ind[sum_ind]=ctri3[elbuf].nod[2]; sum_ind++; } next_node:; } depset=-1; if (sum_dep) { /* check if all nodes of a face connected to this node are dep-nodes */ for(f=0; f-1) for (n=0; n-1) return(depset); else return(-1); } /* search face-pairs of unconnected sets of faces */ /* deside which side is the dep side */ /* remove all dep-nodes which are not inside the ind-faces */ int getFacePair( Summen *anz, int set1, int set2, Elements *e_enqire, Faces *face, Nodes *node, double tol, int *mpcset) { int i,j=0,f; printf ("getFacePair of %s %s\n", set[set1].name, set[set2].name); mpcset[0]=getDepNodes( anz, set1, set2, e_enqire, face, node, tol); if(mpcset[0]>-1) mpcset[1]=getDepNodes( anz, set2, set1, e_enqire, face, node, tol); else return(0); if(mpcset[1]<0) { printf(" ERROR: could not detect dependent nodes from set:%s, connection not done\n", set[set2].name); return(0); } if(set[mpcset[0]].anz_n < set[mpcset[1]].anz_n) { /* switch dep and ind */ i=mpcset[0]; mpcset[0]=mpcset[1]; mpcset[1]=i; } /* add all face-nodes of the ind-set */ for(f=0; f