TclBrick_u_p.cpp

Go to the documentation of this file.
00001 
00002 //
00003 // COPYRIGHT (C):     :-))
00004 // PROJECT:           Object Oriented Finite Element Program
00005 // FILE:              EightNodeBrick_u_p.cpp
00006 // CLASS:             EightNodeBrick_u_p
00007 // VERSION:
00008 // LANGUAGE:          C++
00009 // TARGET OS:         DOS || UNIX || . . .
00010 // DESIGNER:          Zhao Cheng, Boris Jeremic
00011 // PROGRAMMER:        Zhao Cheng, Boris Jeremic
00012 // DATE:              Aug. 2006
00013 // UPDATE HISTORY:    
00014 //
00016 
00017 //  "Coupled system": Z.Cheng & B.Jeremic @ UCDavis
00018 //                    u-- Solid displacement
00019 //                    p-- Pore pressure
00020 
00021 //
00022 #include <stdlib.h>
00023 #include <string.h>
00024 #include <Domain.h>
00025 
00026 #include <ErrorHandler.h>
00027 //#include <TwentyNodeBrick.h>
00028 
00029 #include <EightNode_LDBrick_u_p.h>  //large deformation
00030 #include <EightNode_Brick_u_p.h>    //small deformation
00031 
00032 #include <TclModelBuilder.h>
00033 
00034 extern void printCommand(int argc, TCL_Char **argv);
00035 
00036 
00037 int
00038 TclModelBuilder_addEightNode_LDBrick_u_p(ClientData clientData, Tcl_Interp *interp,  int argc, 
00039                                   TCL_Char **argv, Domain *theTclDomain,
00040                                   TclModelBuilder *theTclBuilder, int eleArgStart)
00041 {
00042   // ensure the destructor has not been called - 
00043   if (theTclBuilder == 0) {
00044       opserr << "command: element EightNode_LDBrick_u_p - no modelbuilder\n";
00045       return TCL_ERROR;
00046   }
00047 
00048   // check the number of arguments is correct
00049   // should have 35 arguments.  
00050   if ((argc-eleArgStart) < 21) {
00051     opserr << "command: element EightNode_LDBrick_u_p - insufficient args ";
00052       return TCL_ERROR;
00053   }    
00054   // get the id and end nodes
00055   int eleID = 0;
00056   int matID = 0;
00057   int nodes[8] = {0,0,0,0,0,0,0,0};
00058   double bodyforces[3] = {0.0, 0.0, 0.0};
00059   double fluidfraction = 0.0;
00060   double solidDensity = 0.0;
00061   double fluidDensity = 0.0;
00062   double perm_x = 0.0; 
00063   double perm_y = 0.0;
00064   double perm_z = 0.0;
00065   double kkf = 0.0;
00066   
00067   // read the eleTag
00068   if (Tcl_GetInt(interp, argv[1+eleArgStart], &eleID) != TCL_OK) {
00069     opserr << "command: element EightNode_LDBrick_u_p - invalid integer tag " << argv[1+eleArgStart] << "\n";                        
00070     return TCL_ERROR;
00071   }
00072   
00073   // read the 20 node tags
00074   int i;
00075   for (i=0; i<8; i++) {
00076       if (Tcl_GetInt(interp, argv[2+i+eleArgStart], &nodes[i]) != TCL_OK) {
00077         opserr << "command: EightNode_LDBrick_u_p " << eleID << " - invalid integer tag " << argv[2+i+eleArgStart] << endln;
00078         return TCL_ERROR;
00079       }
00080   }
00081 
00082   // read in material tag & check the material exists in the model builder
00083   if (Tcl_GetInt(interp, argv[10+eleArgStart], &matID) != TCL_OK) {
00084     opserr << "command: element EightNode_LDBrick_u_p " << eleID << " - invalid matID tag " << argv[10+eleArgStart] << "\n";      
00085     return TCL_ERROR;
00086   }
00087 
00088   NDMaterial *theMaterial = theTclBuilder->getNDMaterial(matID);
00089   
00090   if (theMaterial == 0) {
00091     opserr << "command: element EightNode_LDBrick_u_p " << eleID << " - no NDMaterial with tag " << argv[10+eleArgStart] << " exists\n";
00092     return TCL_ERROR;      
00093   }
00094 
00095   // read the 3 bodyforces 
00096   for (i=0; i<3; i++) {
00097       if (Tcl_GetDouble(interp, argv[11+i+eleArgStart], &bodyforces[i]) != TCL_OK) {
00098         opserr << "command: element EightNode_LDBrick_u_p " << eleID << " - invalid body forces tag " << argv[11+i+eleArgStart] << "\n";   
00099         return TCL_ERROR;
00100       }
00101   }
00102 
00103   // now get the void fraction
00104   if (Tcl_GetDouble(interp, argv[14+eleArgStart], &fluidfraction) != TCL_OK) {
00105     opserr << "command: element EightNode_LDBrick_u_p " << eleID << " - invalid void fraction " << argv[14+eleArgStart] << endln;
00106     return TCL_ERROR;
00107   }  
00108  
00109   // now get the solid density
00110   if (Tcl_GetDouble(interp, argv[15+eleArgStart], &solidDensity) != TCL_OK) {
00111      opserr << "command: element EightNode_LDBrick_u_p " << eleID << " - invalid solidDensity " << argv[15+eleArgStart] << endln;
00112      return TCL_ERROR;
00113   }  
00114  
00115    // now get the fluid density
00116    if (Tcl_GetDouble(interp, argv[16+eleArgStart], &fluidDensity) != TCL_OK) {
00117      opserr << "command: element EightNode_LDBrick_u_p " << eleID << " - invalid fluidDensity " << argv[16+eleArgStart] << endln;
00118      return TCL_ERROR;
00119   }  
00120 
00121   // permeability in x direction
00122   if (Tcl_GetDouble(interp, argv[17+eleArgStart], &perm_x) != TCL_OK) {
00123     opserr << "command: element EightNode_LDBrick_u_p " << eleID << " - invalid permeability in x direction " << argv[17+eleArgStart] << endln;      
00124     return TCL_ERROR;
00125   }  
00126   // permeability in y direction
00127   if (Tcl_GetDouble(interp, argv[18+eleArgStart], &perm_y) != TCL_OK) {
00128     opserr << "command: element EightNode_LDBrick_u_p " << eleID << " - invalid permeability in y direction " << argv[18+eleArgStart] << endln;      
00129     return TCL_ERROR;
00130   }  
00131   // permeability in z direction
00132   if (Tcl_GetDouble(interp, argv[19+eleArgStart], &perm_z) != TCL_OK) {
00133     opserr << "command: element EightNode_LDBrick_u_p " << eleID << " - invalid permeability in z direction " << argv[19+eleArgStart] << endln;
00134     return TCL_ERROR;
00135   }  
00136 
00137  
00138   // now get the bulk modulus of fluid
00139   if (Tcl_GetDouble(interp, argv[20+eleArgStart], &kkf) != TCL_OK) { 
00140     opserr << "command: element EightNode_LDBrick_u_p " << eleID << "  - invalid bulk modulus of fluid " << argv[20+eleArgStart] << endln;      
00141     return TCL_ERROR;
00142   }  
00143   
00144 
00145   // now create the Twenty_EightNode_LDBrick_u_p and add it to the Domain
00146   EightNode_LDBrick_u_p *theEle = new EightNode_LDBrick_u_p(eleID, 
00147                                 nodes[0], nodes[1], nodes[2], nodes[3],
00148                                 nodes[4], nodes[5], nodes[6], nodes[7],
00149                                 theMaterial, bodyforces[0], bodyforces[1], bodyforces[2], 
00150                                 fluidfraction, solidDensity, fluidDensity,
00151                                 perm_x, perm_y, perm_z, kkf); 
00152   if (theEle == 0) {
00153     opserr << "command: element EightNode_LDBrick_u_p " << eleID << "  - out of memory\n";      
00154     return TCL_ERROR;
00155   }
00156 
00157   if (theTclDomain->addElement(theEle) == false) {
00158     opserr << "command: element EightNode_LDBrick_u_p " << eleID << " - could not add ele to domain\n"; 
00159     delete theEle;
00160     return TCL_ERROR;
00161   }
00162   
00163   return TCL_OK;
00164 }
00165 
00166 
00167 
00168 int
00169 TclModelBuilder_addEightNode_Brick_u_p(ClientData clientData, Tcl_Interp *interp,  int argc, 
00170                                   TCL_Char **argv, Domain *theTclDomain,
00171                                   TclModelBuilder *theTclBuilder, int eleArgStart)
00172 {
00173   // ensure the destructor has not been called - 
00174   if (theTclBuilder == 0) {
00175       opserr << "command: element EightNode_Brick_u_p - no modelbuilder\n";
00176       return TCL_ERROR;
00177   }
00178 
00179   // check the number of arguments is correct
00180   // should have 35 arguments.  
00181   if ((argc-eleArgStart) < 23) {
00182     opserr << "command: element EightNode_Brick_u_p - insufficient args ";
00183       return TCL_ERROR;
00184   }    
00185   // get the id and end nodes
00186   int eleID = 0;
00187   int matID = 0;
00188   int nodes[8] = {0,0,0,0,0,0,0,0};
00189   double bodyforces[3] = {0.0, 0.0, 0.0};
00190   double fluidfraction = 0.0;
00191   double solidDensity = 0.0;
00192   double fluidDensity = 0.0;
00193   double perm_x = 0.0; 
00194   double perm_y = 0.0;
00195   double perm_z = 0.0;
00196   double kks = 0.0;
00197   double kkf = 0.0;
00198   double alphaf = 1.0;
00199   
00200   // read the eleTag
00201   if (Tcl_GetInt(interp, argv[1+eleArgStart], &eleID) != TCL_OK) {
00202     opserr << "command: element EightNode_Brick_u_p - invalid integer tag " << argv[1+eleArgStart] << "\n";                          
00203     return TCL_ERROR;
00204   }
00205   
00206   // read the 20 node tags
00207   int i;
00208   for (i=0; i<8; i++) {
00209       if (Tcl_GetInt(interp, argv[2+i+eleArgStart], &nodes[i]) != TCL_OK) {
00210         opserr << "command: EightNode_Brick_u_p " << eleID << " - invalid integer tag " << argv[2+i+eleArgStart] << endln;
00211         return TCL_ERROR;
00212       }
00213   }
00214 
00215   // read in material tag & check the material exists in the model builder
00216   if (Tcl_GetInt(interp, argv[10+eleArgStart], &matID) != TCL_OK) {
00217     opserr << "command: element EightNode_Brick_u_p " << eleID << " - invalid matID tag " << argv[10+eleArgStart] << "\n";      
00218     return TCL_ERROR;
00219   }
00220 
00221   NDMaterial *theMaterial = theTclBuilder->getNDMaterial(matID);
00222   
00223   if (theMaterial == 0) {
00224     opserr << "command: element EightNode_Brick_u_p " << eleID << " - no NDMaterial with tag " << argv[10+eleArgStart] << " exists\n";
00225     return TCL_ERROR;      
00226   }
00227 
00228   // read the 3 bodyforces 
00229   for (i=0; i<3; i++) {
00230       if (Tcl_GetDouble(interp, argv[11+i+eleArgStart], &bodyforces[i]) != TCL_OK) {
00231         opserr << "command: element EightNode_Brick_u_p " << eleID << " - invalid body forces tag " << argv[11+i+eleArgStart] << "\n";   
00232         return TCL_ERROR;
00233       }
00234   }
00235 
00236   // now get the void fraction
00237   if (Tcl_GetDouble(interp, argv[14+eleArgStart], &fluidfraction) != TCL_OK) {
00238     opserr << "command: element EightNode_Brick_u_p " << eleID << " - invalid void fraction " << argv[14+eleArgStart] << endln;
00239     return TCL_ERROR;
00240   }
00241     
00242   // now get the alpha
00243   if (Tcl_GetDouble(interp, argv[15+eleArgStart], &alphaf) != TCL_OK) { 
00244     opserr << "command: element EightNode_Brick_u_p " << eleID << "  - invalid alpha " << argv[15+eleArgStart] << endln;      
00245     return TCL_ERROR;
00246   }
00247    
00248   // now get the solid density
00249   if (Tcl_GetDouble(interp, argv[16+eleArgStart], &solidDensity) != TCL_OK) {
00250      opserr << "command: element EightNode_Brick_u_p " << eleID << " - invalid solidDensity " << argv[16+eleArgStart] << endln;
00251      return TCL_ERROR;
00252   }  
00253  
00254    // now get the fluid density
00255    if (Tcl_GetDouble(interp, argv[17+eleArgStart], &fluidDensity) != TCL_OK) {
00256      opserr << "command: element EightNode_Brick_u_p " << eleID << " - invalid fluidDensity " << argv[17+eleArgStart] << endln;
00257      return TCL_ERROR;
00258   }  
00259 
00260   // permeability in x direction
00261   if (Tcl_GetDouble(interp, argv[18+eleArgStart], &perm_x) != TCL_OK) {
00262     opserr << "command: element EightNode_Brick_u_p " << eleID << " - invalid permeability in x direction " << argv[18+eleArgStart] << endln;      
00263     return TCL_ERROR;
00264   }  
00265   // permeability in y direction
00266   if (Tcl_GetDouble(interp, argv[19+eleArgStart], &perm_y) != TCL_OK) {
00267     opserr << "command: element EightNode_Brick_u_p " << eleID << " - invalid permeability in y direction " << argv[19+eleArgStart] << endln;      
00268     return TCL_ERROR;
00269   }  
00270   // permeability in z direction
00271   if (Tcl_GetDouble(interp, argv[20+eleArgStart], &perm_z) != TCL_OK) {
00272     opserr << "command: element EightNode_Brick_u_p " << eleID << " - invalid permeability in z direction " << argv[20+eleArgStart] << endln;
00273     return TCL_ERROR;
00274   }  
00275 
00276   // now get the bulk modulus of solid
00277   if (Tcl_GetDouble(interp, argv[21+eleArgStart], &kks) != TCL_OK) { 
00278     opserr << "command: element EightNode_Brick_u_p " << eleID << "  - invalid bulk modulus of solid " << argv[21+eleArgStart] << endln;      
00279     return TCL_ERROR;
00280   } 
00281  
00282   // now get the bulk modulus of fluid
00283   if (Tcl_GetDouble(interp, argv[22+eleArgStart], &kkf) != TCL_OK) { 
00284     opserr << "command: element EightNode_Brick_u_p " << eleID << "  - invalid bulk modulus of fluid " << argv[22+eleArgStart] << endln;      
00285     return TCL_ERROR;
00286   }     
00287 
00288   // now create the Twenty_EightNode_LDBrick_u_p and add it to the Domain
00289   EightNode_Brick_u_p *theEle = new EightNode_Brick_u_p(eleID, 
00290                                 nodes[0], nodes[1], nodes[2], nodes[3],
00291                                 nodes[4], nodes[5], nodes[6], nodes[7],
00292                                 theMaterial, bodyforces[0], bodyforces[1], bodyforces[2], 
00293                                 fluidfraction, alphaf, solidDensity, fluidDensity,
00294                                 perm_x, perm_y, perm_z, kks, kkf); 
00295   if (theEle == 0) {
00296     opserr << "command: element EightNode_Brick_u_p " << eleID << "  - out of memory\n";      
00297     return TCL_ERROR;
00298   }
00299 
00300   if (theTclDomain->addElement(theEle) == false) {
00301     opserr << "command: element EightNode_Brick_u_p " << eleID << " - could not add ele to domain\n"; 
00302     delete theEle;
00303     return TCL_ERROR;
00304   }
00305   
00306   return TCL_OK;
00307 }
00308 

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