/*===========================*/ /* gccSCAsearch.c */ /*===========================*/ #include #include #include #include #include #define pi M_PI #define NN 21 #define MM 1000 struct DATA{ double SF; double sumR; double sumS; double aa; double bb; double rr; int nd; double xsta; double ylsta; double yusta; double xend; double ylend; double yuend; }; int main_part(char fnameR[50],char fnameW[50]); void CALC_ONE(double gamma,double cc,double phi,double aa,double bb,double rr, double dx,double ylmin,struct DATA *cur,int np,double xp[NN],double yp[NN]); double COYL(double x,double aa,double bb,double rr); double COYU(double x,int np,double xp[NN],double yp[NN]); void CALC_RS(double x1,double x2,double yl1,double yl2,double yu1,double yu2, double gamma,double cc,double phi,double *R,double *S); void GPL(double gamma,double cc,double phi,double dx, struct DATA W[MM],int kk,double xmin,double xmax,double ymin,double ymax, int np,double xp[NN],double yp[NN]); /*------------------------------------------------------------------------------*/ int main(int argc, char* argv[]) { char fnameR[50]; /* Input file */ char fnameW[50]; /* Output file */ strcpy(fnameR,argv[1]); strcpy(fnameW,argv[2]); main_part(fnameR,fnameW); return 0; } /*------------------------------------------------------------------------------*/ int main_part(char fnameR[50],char fnameW[50]) { /*Circle Slip Analysis*/ FILE *fin,*fout; char dat[256]=""; struct DATA cur,W[MM]; int np,i,ii,jj,kk; double gamma,cc,phi; double xp[NN],yp[NN]; double dx,drr,rrmax,ylmin; double gxmin,gymin,dgg; int ngx,ngy; double aaa,bbb,rrr; double xmin,xmax,ymin,ymax; fin=fopen(fnameR,"r"); fgets(dat,sizeof dat,fin); gamma=atof(strtok(dat,",")); /* Unit weight of soil */ cc =atof(strtok(NULL,",")); /* Cohesion */ phi =atof(strtok(NULL,",")); /* Friction angle */ fgets(dat,sizeof dat,fin); dx =atof(strtok(dat,",")); /* Pitch of strip */ drr =atof(strtok(NULL,",")); /* Pitch of radius change */ rrmax=atof(strtok(NULL,",")); /* Maximum radius */ ylmin=atof(strtok(NULL,",")); /* Minimum elevation of slip circle */ fgets(dat,sizeof dat,fin); gxmin=atof(strtok(dat,",")); /* Minimum x-coordinate of Grid */ ngx =atoi(strtok(NULL,",")); /* Number of device of Grid in x-direction */ gymin=atof(strtok(NULL,",")); /* Minimum y-coordinate of Grid */ ngy =atoi(strtok(NULL,",")); /* Number of device ofGrid in y-direction */ dgg =atof(strtok(NULL,",")); /* */ fgets(dat,sizeof dat,fin); np=atoi(strtok(dat,",")); /* Number of slope point */ for(i=1;i<=np;i++){ fgets(dat,sizeof dat,fin); xp[i]=atof(strtok(dat,",")); /* x-coordinate of slope */ yp[i]=atof(strtok(NULL,","));/* y-coordinate of slope */ } fclose(fin); /* Loop for Grid */ kk=0; for(ii=0;ii<=ngy;ii++){ for(jj=0;jj<=ngx;jj++){ /* Initializing of min.safety circle data for each center */ kk=kk+1; W[kk].SF =1e6; W[kk].sumR =0.0; W[kk].sumS =0.0; W[kk].aa =0.0; W[kk].bb =0.0; W[kk].rr =0.0; W[kk].nd =0; W[kk].xsta =0.0; W[kk].ylsta=0.0; W[kk].yusta=0.0; W[kk].xend =0.0; W[kk].ylend=0.0; W[kk].yuend=0.0; /* Characteristics of circle */ aaa=gxmin+dgg*(double)jj; bbb=gymin+dgg*(double)ii; rrr=0.0; do{ rrr=rrr+drr; CALC_ONE(gamma,cc,phi,aaa,bbb,rrr,dx,ylmin,&cur,np,xp,yp); /* Min.safety circle in each center */ if(cur.SFSF =SF; cur->sumR =sumR; cur->sumS =sumS; cur->aa =aa; cur->bb =bb; cur->rr =rr; cur->nd =nd; cur->xsta =xsta; cur->ylsta=ylsta; cur->yusta=yusta; cur->xend =xend; cur->ylend=ylend; cur->yuend=yuend; } /*---------------------------------------------------------------------------*/ double COYL(double x,double aa,double bb,double rr) { double y,d; y=-1.0; d=rr*rr-(x-aa)*(x-aa); if(0.0