TzSimple1Gen.cpp

Go to the documentation of this file.
00001 
00002 //  This file contains the constructor, destructor, and member          //  
00003 //  functions for the TzSimple1Gen class.  The purpose of the           //
00004 //  class is to create TzSimple1 materials associated with                      //
00005 //  pre-defined zeroLength elements, beam column elements, and          //
00006 //      nodes.                                                                                                                  //
00007 //                                                                                                                                      //
00008 //  Written by: Scott Brandenberg                                                                       //
00009 //              Graduate Student, UC Davis                                                      //
00010 //              December 2, 2003                                                                        //
00012 
00013 //$Revision: 1.4 $
00014 //$Date: 2004/06/30 00:27:40 $
00015 //$Source: /usr/local/cvs/OpenSees/SRC/material/uniaxial/PY/TzSimple1Gen.cpp,v $
00016 
00017 #include "TzSimple1Gen.h"
00018 
00019 using namespace std;
00020 
00022 // Default Constructor
00023 TzSimple1Gen::TzSimple1Gen()
00024 {
00025         NumNodes = 0;
00026         NumTzEle = 0;
00027         NumPileEle = 0;
00028         NPile = 0;
00029         NumLayer = 0;
00030         NumMtLoadSp = 0;
00031         NumLoad = 0;
00032         NumSp = 0;
00033         NumMt = 0;
00034         NumMat = 0;
00035         p = 0.0;
00036         zground = 0.0;
00037         TULT = 0.0;
00038         Z50 = 0.0;
00039         ru = 0.0;
00040         ca = 0.0;
00041         depth = 0.0;
00042         stress = 0.0;
00043         delta = 0.0;
00044         b = 0.0;
00045         Sa = 0.0;
00046 }
00047 
00049 // Destructor deletes dynamically allocated arrays
00050 TzSimple1Gen::~TzSimple1Gen()
00051 {
00052         delete[] Nodex;
00053         delete[] Nodey;
00054         delete[] NodeNum;
00055         delete[] TzEleNum;
00056         delete[] TzNode1;
00057         delete[] TzNode2;
00058         delete[] TzMat;
00059         delete[] TzDir;
00060         delete[] PileEleNum;
00061         delete[] PileNode1;
00062         delete[] PileNode2;
00063         delete[] gamma_t;
00064         delete[] gamma_b;
00065         delete[] z_t;
00066         delete[] z_b;
00067         delete[] p_t;
00068         delete[] p_b;
00069         delete[] c_t;
00070         delete[] c_b;
00071         delete[] ca_t;
00072         delete[] ca_b;
00073         delete[] delta_t;
00074         delete[] delta_b;
00075         delete[] zLoad_t;
00076         delete[] zLoad_b;
00077         delete[] load_val_t;
00078         delete[] load_val_b;
00079         delete[] zSp_t;
00080         delete[] zSp_b;
00081         delete[] sp_val_t;
00082         delete[] sp_val_b;
00083         delete[] zMt_t;
00084         delete[] zMt_b;
00085         delete[] mt_val_t;
00086         delete[] mt_val_b;
00087         delete[] Sa_b;
00088         delete[] Sa_t;
00089         delete[] ru_t;
00090         delete[] ru_b;
00091         delete[] z50_t;
00092         delete[] z50_b;
00093         delete[] tult_t;
00094         delete[] tult_b;
00095         for(int i=0;i<NumMat;i++)
00096                 delete[] MatType[i];
00097         delete[] MatType;
00098         delete[] tzType;
00099 }
00100 
00102 // Function to call appropriate subroutines given input from main
00103 void TzSimple1Gen::WriteTzSimple1(const char *file1, const char *file2, const char *file3, const char *file4, const char *file5)
00104 {
00105         GetTzSimple1(file1, file2, file3, file4, file5);
00106 }
00107 
00108 void TzSimple1Gen::WriteTzSimple1(const char *file1, const char *file2, const char *file3, const char *file4, const char *file5, const char *file6)
00109 {
00110         GetTzSimple1(file1, file2, file3, file4, file5);
00111         GetPattern(file6);
00112 }
00113 
00115 // Function to write an output file containing tz materials
00116 // given nodes, pile elements and tz elements
00117 void TzSimple1Gen::GetTzSimple1(const char *file1, const char *file2, const char *file3, const char *file4, const char *file5)
00118 {
00119 
00120         // Define local variables
00121         int i, j, k, tzelenum, TzIndex, tzmat, stype, NODENUM;
00122         double z, maxz, c, mt;
00123         double ztrib1, ztrib2, dzsub, zsub, depthsub, sublength, tult, z50, numtzshared;
00124         mt = 1.0;
00125         char *mattype;
00126 
00127         // Initialize output stream
00128         ofstream TzOut;
00129         TzOut.open(file5, ios::out);
00130 
00131         // Write headers for output file
00132         TzOut << "#######################################################################################" << endln;
00133         TzOut << "##" << endln;
00134         TzOut << "## This file contains TzSimple1 materials associated with pre-defined nodes, zeroLength" << endln;
00135         TzOut << "## elements and pile beam column elements.  The file was created using the program" << endln;
00136         TzOut << "## TzSimple1Gen.cpp written by Scott Brandenberg (sjbrandenberg@ucdavis.edu)" << endln;
00137         TzOut << "##" << endln;
00138         TzOut << "#######################################################################################" << endln << endln;
00139         TzOut << "########################################################################################" << endln;
00140         TzOut << "## Material Properties for tz Elements" << endln << endln;
00141 
00142         // Call functions to open input files
00143         
00144         GetSoilProperties(file1);
00145         GetNodes(file2);
00146         GetTzElements(file3);
00147         GetPileElements(file4);
00148         
00149         // Loop over nodes
00150         for(i=0;i<NumTzEle;i++)
00151         {
00152                 // Initialize variables to zero.  Note that elements and nodes must be assigned numbers larger than zero
00153                 tzelenum = 0;
00154                 z = 0;
00155                 TzIndex = -1;
00156 
00157                 // Find number of tz element that shares the node
00158                 for(j=0;j<NumNodes;j++)
00159                 {
00160                         if(NodeNum[j] == TzNode1[i]) // Only calculate values for TzNode that also attaches to pile node
00161                         {
00162                                 for(k=0;k<NumPileEle;k++)
00163                                 {
00164                                         if(PileNode1[k] == TzNode1[i] || PileNode2[k] == TzNode1[i])
00165                                         {
00166                         tzelenum = TzEleNum[i];
00167                                                 TzIndex = i;
00168                                                 tzmat = TzMat[i];
00169                                                 z = Nodey[j];
00170                                                 NODENUM = NodeNum[j];
00171                                         }
00172                                 }
00173                         }
00174                         else if(NodeNum[j] == TzNode2[i])
00175                         {
00176                                 for(k=0;k<NumPileEle;k++)
00177                                 {
00178                                         if(PileNode1[k] == TzNode2[i] || PileNode2[k] == TzNode2[i])
00179                                         {
00180                         tzelenum = TzEleNum[i];
00181                                                 TzIndex = i;
00182                                                 tzmat = TzMat[i];
00183                                                 z = Nodey[j];
00184                                                 NODENUM = NodeNum[j];
00185                                         }
00186                                 }
00187                         }
00188                         if(TzIndex == -1)
00189                                 continue;
00190                 }
00191 
00192                 // Find depth of node
00193                 maxz = z_t[0];
00194                 for (j=0;j<NumMat;j++)
00195                 {
00196                         if(z_t[j] > maxz)
00197                                 maxz = z_t[j];
00198                 }
00199 
00200                 depth = maxz - z;
00201 
00202                 GetTributaryCoordsTz(NODENUM);
00203                 ztrib1 = tribcoord[0];
00204                 ztrib2 = tribcoord[1];
00205 
00206                 // make sure coordinates of tributary length lie within soil layer for assigning tributary lengths
00207                 // for the tz elements
00208                 if(ztrib1 > maxz)
00209                         ztrib1 = maxz;
00210                 if(ztrib2 > maxz)
00211                         ztrib2 = maxz;
00212 
00213                 // Calculate tz material properties and write to file
00214                 if(TzIndex != -1)
00215                 {
00216                         // subdivide tributary length into 10 sublayers, and integrate pult over tributary length
00217                         dzsub = (ztrib2 - ztrib1)/10.0; // sublayer incremental depth change
00218                         sublength = fabs(dzsub);  // thickness of sublayer
00219                         tult = 0.0;
00220                         for(k=0;k<10;k++)
00221                         {                       
00222                                 zsub = ztrib1 + dzsub/2.0 + k*dzsub; // z-coordinate at sublayer center
00223                                 depthsub = maxz - zsub;
00224                         
00225                                 // Find properties at node location
00226                                 for(j=0;j<NumMat;j++)
00227                                 {
00228                                         if(zsub<=z_t[j] && zsub>=z_b[j])
00229                                         {
00230                                                 mattype = MatType[j];
00231                                                 // linearly interpolate parameters at z
00232                                                 p = linterp(z_t[j], z_b[j], p_t[j], p_b[j], zsub);
00233                                                 ca = linterp(z_t[j], z_b[j], ca_t[j], ca_b[j], zsub);
00234                                                 delta = linterp(z_t[j], z_b[j], delta_t[j], delta_b[j], zsub);
00235                                                 c = linterp(z_t[j], z_b[j], c_t[j], c_b[j], zsub);
00236                                                 TULT = linterp(z_t[j], z_b[j], tult_t[j], tult_b[j], zsub);
00237                                                 Z50 = linterp(z_t[j], z_b[j], z50_t[j], z50_b[j], zsub);
00238                                                 ru = linterp(z_t[j], z_b[j], ru_t[j], ru_b[j], zsub);
00239                                                 Sa = linterp(z_t[j], z_b[j], Sa_t[j], Sa_b[j], zsub);
00240                                                 if(strcmp(mattype,"tz1")==0)
00241                                                         stype = 1;
00242                                                 else if(strcmp(mattype,"tz2")==0 || strcmp(mattype,"tz3")==0)
00243                                                         stype = 2;
00244                                                 else if(strcmp(mattype,"tz4")==0)
00245                                                         stype = tzType[j];
00246                                                 else                                    
00247                                                 {
00248                                                         opserr << "MatType must be tz1, tz2, tz3 or tz4.  " << mattype << " is not supported." << endln;
00249                                                         exit(0);
00250                                                 }
00251                                                 break;
00252                                         }
00253                                 }
00254                                                                 
00255                                 for(j=0;j<NumMt;j++)
00256                                 {
00257                                         if(zsub<=zMt_t[j] && zsub>=zMt_b[j])
00258                                                 mt = linterp(zMt_t[j], zMt_b[j], mt_val_t[j], mt_val_b[j], zsub);
00259                                         else mt = 1.0;
00260                                 }
00261 
00262                                 // calculate vertical effective stress and integrate over tributary length
00263                                 stress = GetVStress(zsub);
00264                                 tult = GetTult(mattype)*sublength*mt + tult;
00265                         }
00266 
00267                         z50 = GetZ50(mattype);
00268 
00269                         // Calculate the number of t-z elements that share nodes with the current t-z element
00270                         numtzshared = 1.0;
00271                         for(j=0;j<NumTzEle;j++)
00272                         {
00273                                 if(j!=i)
00274                                 {
00275                                         if(TzNode1[j] == TzNode1[i] || TzNode1[j] == TzNode2[i])
00276                                                 numtzshared += 1.0;
00277                                 }
00278                         }
00279 
00280                         TzOut << "uniaxialMaterial TzSimple1 " << tzmat << " " << stype << " " << tult/numtzshared << " " << z50 << " " << c << endln;
00281                 }
00282         }
00283 
00284         // Write footer for output file
00285         TzOut << endln << "## End Material Properties for tz Elements" << endln;
00286         TzOut << "########################################################################################" << endln;
00287 
00288         TzOut.close();
00289 }
00290 
00292 // Function to get applied constraints
00293 void TzSimple1Gen::GetPattern(const char *file6)
00294 {
00295         double ztrib1, ztrib2, maxz, minz, dzsub, sublength, zsub, depthsub;
00296         int node, i, j, k;
00297         double patternvalue, z, load, sp;
00298         char patterntype[] = "trash";
00299         
00300         // Now open a stream to construct the constraints
00301         ofstream PatternOut;
00302         PatternOut.open(file6,ios::out);
00303 
00304         if(!PatternOut)
00305         {
00306                 opserr << "Error opening " << file6 << " in TzSimple1Gen.cpp.  Must Exit." << endln;
00307                 exit(-1);
00308         }
00309 
00310         patternvalue = 0.0;
00311         z = 0.0;
00312 
00313                 // Write header for constraint file
00314         PatternOut << "#######################################################################################" << endln;
00315         PatternOut << "##" << endln;
00316         PatternOut << "## This file contains load patterns applied to pile nodes, and/or displacement" << endln;
00317         PatternOut << "## patterns applied to the free ends of tz elements.  The file was created using" << endln;
00318         PatternOut << "## TzSimple1Gen.cpp written by Scott Brandenberg (sjbrandenberg@ucdavis.edu)" << endln;
00319         PatternOut << "##" << endln;
00320         PatternOut << "#######################################################################################" << endln << endln;
00321         PatternOut << "#######################################################################################" << endln;
00322         PatternOut << "## Begin Pattern File" << endln << endln;
00323         
00324         // If loads are applied (i.e. PatternType = "load"), then the appropriate loads must be assigned to
00325         // the pile nodes.  The free ends of the tz elements below the nodal loads (i.e. in the soil
00326         // that is not spreading) must already be fixed when the mesh is generated in GiD.      
00327         // Write constraints file for pushover analyses
00328         
00329         for(i=0;i<NumNodes;i++)
00330         {
00331                 z = Nodey[i];
00332                 GetTributaryCoordsPile(NodeNum[i]);
00333                 ztrib1 = tribcoord[0];
00334                 ztrib2 = tribcoord[1];
00335         
00336                 // Find depth of node
00337                 maxz = z_t[0];  // initialize maxz to some value in the domain
00338                 minz = z_b[0];
00339                 for (j=0;j<NumMat;j++)
00340                 {
00341                         if(z_t[j] > maxz)
00342                                 maxz = z_t[j];
00343                         if(z_b[j] < minz)
00344                                 minz = z_b[j];
00345                 }
00346 
00347                         // subdivide tributary length into 10 sublayers, and integrate distributed load over tributary length
00348                 dzsub = (ztrib2 - ztrib1)/10.0; // sublayer incremental depth change
00349                 sublength = fabs(dzsub);  // thickness of sublayer
00350                 load = 0.0;
00351                 for(k=0;k<10;k++)
00352                 {       
00353                         zsub = ztrib1 + dzsub/2.0 + k*dzsub; // z-coordinate at sublayer center
00354                         depthsub = maxz - zsub;
00355 
00356                         for(j=0;j<NumLoad;j++)
00357                         {                               
00358                                 if(zsub<=zLoad_t[j] && zsub>=zLoad_b[j])
00359                                 {
00360                                         load = linterp(zLoad_t[j], zLoad_b[j], load_val_t[j], load_val_b[j], zsub)*sublength + load;
00361                                         strcpy(patterntype,"load");
00362                                 }
00363                                 
00364                         }
00365                 }
00366                 node = -1;
00367                 if(strcmp(patterntype,"load")==0)
00368                 {
00369                         for(j=0;j<NumPileEle;j++)
00370                         {                                       
00371                                 if(NodeNum[i] == PileNode1[j] || NodeNum[i] == PileNode2[j])
00372                                 {
00373                                         node = NodeNum[i];
00374                                 }
00375                         }
00376                         if(node!=-1)
00377                         PatternOut << "load " << node << " 0.0 " << load << " 0.0" << endln;
00378                 }
00379         
00380                 for(j=0;j<NumSp;j++)
00381                 {
00382                         if(z<=zSp_t[j] && z>=zSp_b[j])
00383                         {
00384                                 sp = linterp(zSp_t[j], zSp_b[j], sp_val_t[j], sp_val_b[j], z);
00385                                 strcpy(patterntype,"sp");
00386                         }
00387                 }               
00388         
00389                 node = -1;
00390                 if(strcmp(patterntype,"sp")==0)
00391                 {
00392                         for(k=0;k<NumTzEle;k++)
00393                         {
00394                                 if(NodeNum[i] == TzNode1[k] || NodeNum[i] == TzNode2[k])
00395                                 {
00396                                         node = NodeNum[i];
00397                                         // Check if node is free or attached to pile
00398                                         for(j=0;j<NumPileEle;j++)
00399                                         {
00400                                                 if(PileNode1[j] == NodeNum[i] || PileNode2[j] == NodeNum[i])
00401                                                 {
00402                                                         node = -1;
00403                                                         break;
00404                                                 }
00405                                         }
00406                                 }
00407                         }
00408                                 
00409                 // write to file
00410                         if(node != -1)
00411                                 PatternOut << "sp " << node << " 2 " << sp << endln;
00412                 }
00413                 
00414         }
00415 
00416         PatternOut << endln << endln;
00417         PatternOut << "## End Tz Pattern File" << endln;
00418         PatternOut << "#######################################################################################" << endln;
00419 
00420         PatternOut.close();
00421 }
00422 
00424 // Function to get node numbers and coordinates
00425 void TzSimple1Gen::GetNodes(const char *file)
00426 {
00427         int i = 0;
00428         char *trash = new char[1000];
00429         char ch;
00430         
00431         ifstream in_file(file, ios::in);
00432         
00433         if(!in_file)
00434         {
00435                 opserr << "File " << file << "does not exist.  Must exit." << endln;
00436                 exit(-1);
00437         }
00438         
00439         NumNodes = NumRows(file,"node");
00440         NodeNum = new int[NumNodes];
00441         Nodex = new double[NumNodes];
00442         Nodey = new double[NumNodes];
00443         
00444         while(!in_file.eof())
00445         {
00446                 if(in_file.peek()=='n')
00447                 {
00448                         in_file.get(trash,5);
00449                         if(strcmp(trash,"node")==0)
00450                         {
00451                                 in_file >> NodeNum[i] >> Nodex[i] >> Nodey[i];
00452                                 i+=1;
00453                         }
00454                 }
00455                 while(in_file.get(ch))
00456                 {
00457                         if(ch=='\n')
00458                                 break;
00459                 }
00460         }
00461 
00462         delete[] trash;
00463         in_file.close();
00464         return;
00465 }
00466 
00468 // Function to get tz element numbers, material numbers, and direction tags
00469 void TzSimple1Gen::GetTzElements(const char *file)
00470 {
00471         int i = 0;
00472         char *trash = new char[1000];
00473         char ch;
00474 
00475         ifstream in_file;
00476         in_file.open(file, ios::in);
00477 
00478         if(!in_file)
00479         {
00480                 opserr << "File " << file << "does not exist.  Must exit." << endln;
00481                 exit(-1);
00482         }
00483 
00484         NumTzEle = NumRows(file,"element");
00485         TzEleNum = new int[NumTzEle];
00486         TzNode1 = new int[NumTzEle];
00487         TzNode2 = new int[NumTzEle];
00488         TzMat = new int[NumTzEle];
00489         TzDir = new int[NumTzEle];
00490 
00491         while(!in_file.eof())
00492         {
00493                 if(in_file.peek()=='e')
00494                 {
00495                         in_file.get(trash,8);
00496                         if(strcmp(trash,"element")==0)
00497                         {
00498                                 in_file >> trash >> TzEleNum[i] >> TzNode1[i] >> TzNode2[i] >> trash >> TzMat[i] >> trash >> TzDir[i];
00499                                 i+=1;
00500                         }
00501                         continue;
00502                 }
00503                 while(in_file.get(ch))
00504                 {
00505                         if(ch=='\n')
00506                                 break;
00507                 }
00508         }
00509 
00510         delete[] trash;
00511         in_file.close();
00512         return;
00513 }
00514 
00516 // Function to get pile element numbers and node numbers
00517 void TzSimple1Gen::GetPileElements(const char *file)
00518 {
00519         int i = 0;
00520         char* trash = new char[1000];
00521         char ch;
00522         
00523         ifstream in_file;
00524         in_file.open(file, ios::in);
00525 
00526         if(!in_file)
00527         {
00528                 opserr << "File " << file << "does not exist.  Must exit." << endln;
00529                 exit(-1);
00530         }
00531 
00532         NumPileEle = NumRows(file,"element");
00533         PileEleNum = new int[NumPileEle];
00534         PileNode1 = new int[NumPileEle];
00535         PileNode2 = new int[NumPileEle];
00536         
00537         while(!in_file.eof())
00538         {
00539                 if(in_file.peek()=='e')
00540                 {
00541                         in_file.get(trash,8);
00542                         if(strcmp(trash,"element")==0)
00543                         {
00544                                 in_file >> trash >> PileEleNum[i] >> PileNode1[i] >> PileNode2[i];
00545                                 i+=1;
00546                         }
00547                         continue;
00548                 }
00549                 while(in_file.get(ch))
00550                 {
00551                         if(ch=='\n')
00552                                 break;
00553                 }
00554         }
00555 
00556         delete[] trash;
00557         in_file.close();
00558         return;
00559 }
00560 
00562 // Function to get soil properties
00563 void TzSimple1Gen::GetSoilProperties(const char *file)
00564 {
00565         int i = 0;
00566         int I = 0;
00567         int J = 0;
00568         int K = 0;
00569         char OptionalTag[10];
00570         
00571         ifstream in1;
00572         in1.open(file, ios::in);        
00573         
00574         if(!in1)
00575         {
00576                 opserr << "File " << file << "does not exist.  Must exit." << endln;
00577                 exit(0);
00578         }
00579 
00580         // Define number of rows containing properties to define TzSimple1 materials
00581         NumMat = NumRows(file, "tz1") + NumRows(file, "tz2") + NumRows(file,"tz3") + NumRows(file,"tz4");  // Number of tz materials defined in file
00582         NumMt = NumRows(file,"mt"); // Number of t-multiplier terms defined in file
00583         NumSp = NumRows(file,"sp");                 // number of applied displacements defined in file
00584         NumLoad = NumRows(file,"load");     // number of applied distributed loads defined in file
00585         NumMtLoadSp = NumMt + NumSp + NumLoad + NumRows(file,"Pattern") + NumRows(file,"pattern");              // total number of applied patterns defined in file
00586 
00587         // Dynamically allocate memory for arrays containing information for each soil layer.
00588         // Arguments general to all layers
00589         MatType = new char*[4];
00590         for(i=0;i<NumMat;i++)
00591                 MatType[i] = new char[4];
00592         z_t = new double[NumMat];
00593         z_b = new double[NumMat];
00594         gamma_t = new double[NumMat];
00595         gamma_b = new double[NumMat];
00596         p_t = new double[NumMat];
00597         p_b = new double[NumMat];
00598         c_t = new double[NumMat];
00599         c_b = new double[NumMat];
00600         ca_t = new double[NumMat];
00601         ca_b = new double[NumMat];
00602         delta_t = new double[NumMat];
00603         delta_b = new double[NumMat];
00604         Sa_t = new double[NumMat];
00605         Sa_b = new double[NumMat];
00606         ru_t = new double[NumMat];
00607         ru_b = new double[NumMat];
00608         tzType = new int[NumMat];
00609         tult_t = new double[NumMat];
00610         tult_b = new double[NumMat];
00611         z50_t = new double[NumMat];
00612         z50_b = new double[NumMat];
00613 
00614         // Dynamically allocate memory for arrays containing information for p-multipliers
00615         zMt_t = new double[NumMt];
00616         zMt_b = new double[NumMt];
00617         mt_val_t = new double[NumMt];
00618         mt_val_b = new double[NumMt];
00619         
00620         // Dynamically allocate memory for arrays containing information for load pattern
00621         zLoad_t = new double[NumLoad];
00622         zLoad_b = new double[NumLoad];
00623         load_val_t = new double[NumLoad];
00624         load_val_b = new double[NumLoad];
00625 
00626         // Dynamically allocate memory for arryas containing information for displacement pattern
00627         zSp_t = new double[NumSp];
00628         zSp_b = new double[NumSp];
00629         sp_val_t = new double[NumSp];
00630         sp_val_b = new double[NumSp];
00631 
00632         for(i=0;i<NumMat;i++)
00633         {
00634                 // initialize variables to zero, then redefine later
00635                 c_t[i] = 0;
00636                 c_b[i] = 0;
00637                 ca_t[i] = 0;
00638                 ca_b[i] = 0;
00639                 delta_t[i] = 0;
00640                 delta_b[i] = 0;
00641 
00642                 // read in arguments that are common to all material types
00643                 in1 >> MatType[i] >> z_t[i] >> z_b[i] >> gamma_t[i] >> gamma_b[i];
00644         
00645                 // read in arguments that are specific to certain material types
00646                 if(strcmp(MatType[i],"tz1")==0)
00647                 {
00648                         in1 >> p_t[i] >> p_b[i] >> ca_t[i] >> ca_b[i];
00649                         if(in1.peek() != '\n')
00650                                 in1 >> c_t[i] >> c_b[i];
00651                 }
00652                 else if(strcmp(MatType[i],"tz2")==0)
00653                 {
00654                         in1 >> p_t[i] >> p_b[i] >> delta_t[i] >> delta_b[i];
00655                         if(in1.peek() != '\n')
00656                                 in1 >> c_t[i] >> c_b[i];
00657                 }               
00658                 else if(strcmp(MatType[i],"tz3")==0)
00659                 {
00660                         in1 >> p_t[i] >> p_b[i] >> delta_t[i] >> delta_b[i] >> Sa_t[i] >> Sa_b[i] >> ru_t[i] >> ru_b[i];
00661                         if(in1.peek() != '\n')  
00662                                 in1 >> c_t[i] >> c_b[i];
00663                 }
00664                 else if(strcmp(MatType[i],"tz4")==0)
00665                 {
00666                         in1 >> tzType[i] >> tult_t[i] >> tult_b[i] >> z50_t[i] >> z50_b[i];
00667                         if(in1.peek() != '\n')
00668                                 in1 >> c_t[i] >> c_b[i];
00669                 }
00670                 else
00671                 {
00672                         opserr << "MatType " << MatType[i] << "Is not supported in TzSimple1Gen.cpp.";
00673                         exit(0);
00674                 }
00675                 // read to next line or next character
00676                 if(in1.peek()=='\n')
00677                         in1.ignore(100000,'\n');
00678                 if(in1.peek()==' ')
00679                         in1.ignore(100000,' ');
00680         }
00681         
00682         // Read in values that define patterns (either loads applied directly to the pile nodes, or free-field
00683         // displacements applied to the backs of the tz elements).
00684         // Read in values that define patterns (either loads applied directly to the pile nodes, or free-field
00685         // displacements applied to the backs of the py elements).
00686         for(i=0;i<NumMtLoadSp;i++)
00687         {
00688                 in1 >> OptionalTag;
00689                 if(strcmp(OptionalTag,"load")==0)
00690                 {
00691                         in1 >> zLoad_t[I] >> zLoad_b[I] >> load_val_t[I] >> load_val_b[I];
00692                         I+=1;
00693                 }
00694                 if(strcmp(OptionalTag,"sp")==0)
00695                 {
00696                         in1 >> zSp_t[J] >> zSp_b[J] >> sp_val_t[J] >> sp_val_b[J];
00697                         J+=1;
00698                 }
00699                 if(strcmp(OptionalTag,"mt")==0)
00700                 {
00701                         in1 >> zMt_t[K] >> zMt_b[K] >> mt_val_t[K] >> mt_val_b[K];
00702                         K+=1;
00703                 }
00704                 if(in1.peek()=='\n')
00705                         in1.ignore(100000,'\n');
00706                 if(in1.peek()==' ')
00707                         in1.ignore(100000,' ');
00708         }
00709 
00710         in1.close();
00711 }
00712 
00713         
00715 // Member function to calculate pult
00716 double TzSimple1Gen::GetTult(const char *type)
00717 {
00718         double tult_0, tult_1, tult_ru;
00719 
00720         // Calculate tult for clay
00721         if(strcmp(type,"tz1")==0)
00722         {
00723                 return ca*p;
00724         }
00725 
00726         // Calculate tult for sand
00727         else if(strcmp(type,"tz2")==0)
00728         {
00729                 if(depth == 0)
00730                         return 0.00001;  // TzSimple1 does not support tult = 0;
00731 
00732                 double Ko;
00733                 double deg = 3.141592654/180.0;
00734                 Ko = 0.4; // Use 0.4 like LPile
00735                 return Ko*stress*tan(delta*deg)*p;
00736         }
00737         else if(strcmp(type,"tz3")==0)
00738         {
00739                 double Ko;
00740                 double deg = 3.141592654/180.0;
00741                 // convert phi, alpha and beta from degrees to radians
00742                 Ko = 0.4; // Use 0.4 like LPile
00743                 tult_0 = Ko*stress*tan(delta*deg)*p;
00744 
00745                 tult_1 = Sa*p*stress;
00746 
00747                 tult_ru = linterp(0.0, 1.0, tult_0, tult_1, ru);
00748 
00749                 return tult_ru;
00750         }
00751         else if(strcmp(type,"tz4")==0)
00752         {
00753                 return TULT;
00754         }
00755         else
00756         {
00757                 opserr << "TzType " << type << " is not supported in TzSimple1GenPushover::GetTult.  Setting tult = 0.00000001";
00758                 return 0.00000001;
00759         }
00760 
00761 }
00762 
00764 // Member function to return y50
00765 double TzSimple1Gen::GetZ50(const char *type)
00766 {
00767         if(strcmp(type,"tz4")==0)
00768                 return Z50;
00769 
00770         // Set z50 such that zult = 0.5% of pile diameter.  Calculate pile diameter from perimeter for a circular section.
00771         else
00772         return 0.005*p/3.14159/8.0;
00773 }
00774 
00776 // Member function to get the number of rows in a file that begin with a certain string
00777 int TzSimple1Gen::NumRows(const char *file, const char *begin)
00778 {
00779         if(!file)
00780         {
00781                 opserr << "File " << file << "does not exist.  Must exit." << endln;
00782                 exit(0);
00783         }
00784 
00785         ifstream in_file;
00786         in_file.open(file, ios::in);
00787         int i = 0;
00788         char *filein = new char[20];
00789         
00790         while(!in_file.eof())
00791         {
00792                 // check for blank lines
00793                 while(in_file.peek()=='\n')
00794                         in_file.getline(filein,1,'\n');
00795                 // Read first character string
00796                 in_file.get(filein,19,' ');
00797                 if(strcmp(filein, begin)==0)
00798                         i = i+1;
00799 
00800                 // Read remainder of line
00801                 in_file.ignore(1000,'\n');
00802         }
00803         
00804         delete [] filein;
00805 
00806         in_file.close();
00807         return i;
00808 
00809 }
00810 
00812 // Member function to calculate vertical effective stress at a depth given the unit weight and depth arrays already read in.
00813 double TzSimple1Gen::GetVStress(double z)
00814 {
00815         double stress, maxz, minz, z_top, z_bot, gamma_top, gamma_bot, gamma_z;
00816         int i;
00817         stress = 0;
00818         maxz = z_t[0];
00819         minz = z_b[0];
00820         z_top = 0;
00821         z_bot = 0;
00822         gamma_top = 0;
00823         gamma_bot = 0;
00824 
00825         
00826         // Find maximum and minimum of depth range specified in z_t and z_b
00827         for (i=0;i<NumMat;i++)
00828         {
00829                 if(z_t[i] >= maxz)
00830                         maxz = z_t[i];
00831                 if(z_b[i] <= minz)
00832                         minz = z_b[i];
00833         }
00834 
00835         // Check that z lies within range of z_t and z_b
00836         if(z > maxz || z < minz)
00837         {
00838                 opserr << "Depth lies out of range of specified depth vectors in function 'vstress' in PySimple1GenPushover. Setting stress = 0." << endln;
00839                 return 0.0;
00840         }
00841 
00842 
00843         // Extract coordinates of top and bottom of layer
00844         for(i=0;i<NumMat;i++)
00845         {
00846                 if(z >= z_b[i] && z <= z_t[i])
00847                 {
00848                         z_top = z_t[i];
00849                         z_bot = z_b[i];
00850                         gamma_top = gamma_t[i];
00851                         gamma_bot = gamma_b[i];
00852                 }
00853         }
00854         
00855 
00856 
00857         // Linearly interpolate unit weight at z
00858         gamma_z = linterp(z_top, z_bot, gamma_top, gamma_bot, z);
00859 
00860         // calculate stress
00861         for (i=0;i<NumMat;i++)
00862         {
00863                 if(z <= z_b[i])
00864                         stress = stress + 0.5*(gamma_t[i] + gamma_b[i])*(z_t[i] - z_b[i]);
00865                 if(z > z_b[i] && z < z_t[i])
00866                         stress = stress + 0.5*(gamma_t[i] + gamma_z)*(z_t[i] - z);
00867         }
00868         
00869         return stress;
00870 }
00871 
00873 // Function to linearly interpolate
00874 double TzSimple1Gen::linterp(double x1, double x2, double y1, double y2, double x3)
00875 {
00876         return y1 + (x3-x1)*(y2-y1)/(x2-x1);
00877 }
00878 
00880 // Function that returns the coordinates of the ends of the tributary length
00881 // based on t-z element locations.  Tributary length is based on 1/2 of the pile
00882 // length above nodenum1 and 1/2 of the pile length below nodenum1 as long as
00883 // the pile elements above and below nodenum1 both attach to t-z elements at both nodes.
00884 void TzSimple1Gen::GetTributaryCoordsTz(int nodenum1)
00885 {
00886         
00887         double coordnodenum1;
00888         int i, j, k, I, tzeletag;
00889         I = 0;
00890 
00891         // initialize tribcoord to the coordinate of nodenum1
00892         for(i=0; i<NumNodes; i++)
00893         {
00894                 if(nodenum1 == NodeNum[i])
00895                 {
00896                         coordnodenum1 = Nodey[i];
00897                         tribcoord[0] = Nodey[i];
00898                         tribcoord[1] = Nodey[i];
00899                 }
00900         }
00901         for(i=0; i<NumPileEle; i++)
00902         {
00903                 if(PileNode1[i] == nodenum1)
00904                 {
00905                         tzeletag = 0;
00906                         for(j=0; j<NumTzEle; j++)
00907                         {
00908                                 if(TzNode1[j] == PileNode1[i] || TzNode2[j] == PileNode1[i])
00909                                 {
00910                                         for(k=0; k<NumTzEle; k++)
00911                                         {
00912                                                 if(TzNode1[k] == PileNode2[i] || TzNode2[k] == PileNode2[i])
00913                                                         tzeletag = 1;  // set pyeletag = 1 if PileNode1 is attached to a py element
00914                                         }
00915                                 }
00916                         }
00917                         if(tzeletag==1)
00918                         {
00919                                 for(j=0; j<NumNodes; j++)
00920                                 {
00921                                         if(PileNode2[i] == NodeNum[j])
00922                                         {
00923                                                 tribcoord[0] = coordnodenum1 + 0.5*(Nodey[j] - coordnodenum1);
00924                                         }
00925                                 }
00926                         }
00927                 }
00928                 if(PileNode2[i] == nodenum1)
00929                 {
00930                         tzeletag = 0;
00931                         for(j=0;j<NumTzEle;j++)
00932                         {
00933                                 if(TzNode1[j] == PileNode2[i] || TzNode2[j] == PileNode2[i])
00934                                 {
00935                                         for(k=0; k<NumTzEle; k++)
00936                                         {
00937                                                 if(TzNode1[k] == PileNode1[i] || TzNode2[k] == PileNode1[i])
00938                             tzeletag = 1;  // set pyeletag = 1 if PileNode2 is attached to a py element
00939                                         }
00940                                 }
00941                         }
00942                         if(tzeletag==1)
00943                         {
00944                                 for(j=0; j<NumNodes; j++)
00945                                 {
00946                                         if(PileNode1[i] == NodeNum[j])
00947                                         {
00948                                                 tribcoord[1] = coordnodenum1 + 0.5*(Nodey[j] - coordnodenum1);
00949                                         }
00950                                 }
00951                         }
00952                 }
00953         }
00954 
00955         return;
00956 }
00957 
00959 // Function that returns the coordinates of the ends of the tributary length
00960 // based on pile element locations.  Tributary length is based on 1/2 of the pile
00961 // length above nodenum1 and 1/2 of the pile length below nodenum1 even if
00962 // the pile elements above and below nodenum1 do not both attach to p-y elements 
00963 // at both nodes.
00964 void TzSimple1Gen::GetTributaryCoordsPile(int nodenum1)
00965 {
00966         
00967         double coordnodenum1;
00968         int i, j, I;
00969         I = 0;
00970 
00971         // initialize tribcoord to the coordinate of nodenum1
00972         for(i=0; i<NumNodes; i++)
00973         {
00974                 if(nodenum1 == NodeNum[i])
00975                 {
00976                         coordnodenum1 = Nodey[i];
00977                         tribcoord[0] = Nodey[i];
00978                         tribcoord[1] = Nodey[i];
00979                 }
00980         }
00981         for(i=0; i<NumPileEle; i++)
00982         {
00983                 if(PileNode1[i] == nodenum1)
00984                 {
00985                         for(j=0; j<NumNodes; j++)
00986                         {
00987                                 if(PileNode2[i] == NodeNum[j])
00988                                 {
00989                                         tribcoord[0] = coordnodenum1 + 0.5*(Nodey[j] - coordnodenum1);
00990                                 }
00991                         }
00992                 }
00993                 if(PileNode2[i] == nodenum1)
00994                 {
00995                         for(j=0; j<NumNodes; j++)
00996                         {
00997                                 if(PileNode1[i] == NodeNum[j])
00998                                 {
00999                                         tribcoord[1] = coordnodenum1 + 0.5*(Nodey[j] - coordnodenum1);
01000                                 }
01001                         }
01002                 }
01003         }
01004 
01005         return;
01006 }

Generated on Mon Oct 23 15:05:21 2006 for OpenSees by doxygen 1.5.0