TclTLFD20NodeBrickCommand.cpp

Go to the documentation of this file.
00001 //===============================================================================
00002 
00003 //# COPYRIGHT (C): Woody's license (by BJ):
00004 
00005 //                 ``This    source  code is Copyrighted in
00006 
00007 //                 U.S.,  for  an  indefinite  period,  and anybody
00008 
00009 //                 caught  using it without our permission, will be
00010 
00011 //                 mighty good friends of ourn, cause we don't give
00012 
00013 //                 a  darn.  Hack it. Compile it. Debug it. Run it.
00014 
00015 //                 Yodel  it.  Enjoy it. We wrote it, that's all we
00016 
00017 //                 wanted to do.''
00018 
00019 //
00020 
00021 //# PROJECT:           Object Oriented Finite Element Program
00022 
00023 //# PURPOSE:           Finite Deformation Hyper-Elastic classes
00024 
00025 //# CLASS:
00026 
00027 //#
00028 
00029 //# VERSION:           0.6_(1803398874989) (golden section)
00030 
00031 //# LANGUAGE:          C++
00032 
00033 //# TARGET OS:         all...
00034 
00035 //# DESIGN:            Zhao Cheng, Boris Jeremic (jeremic@ucdavis.edu)
00036 
00037 //# PROGRAMMER(S):     Zhao Cheng, Boris Jeremic
00038 
00039 //#
00040 
00041 //#
00042 
00043 //# DATE:              Sept2003
00044 
00045 //# UPDATE HISTORY:
00046 
00047 //#
00048 
00049 //#
00050 
00051 //===============================================================================
00052 
00053 #include <stdlib.h>
00054 
00055 #include <string.h>
00056 
00057 #include <OPS_Stream.h>
00058 
00059 #include <Domain.h>
00060 
00061 
00062 
00063 #include <ErrorHandler.h>
00064 
00065 #include <TotalLagrangianFD20NodeBrick.h>
00066 
00067 #include <TotalLagrangianFD8NodeBrick.h>
00068 
00069 #include <TclModelBuilder.h>
00070 
00071 
00072 
00073 //#define NumNodes 20
00074 
00075 //#define NumDof 3
00076 
00077 
00078 
00079 extern void printCommand(int argc, TCL_Char **argv);
00080 
00081 
00082 
00083 int
00084 
00085 TclModelBuilder_addTLFD20nBrick(ClientData clientData,
00086 
00087                                 Tcl_Interp *interp,
00088 
00089                                 int argc,
00090 
00091                                 TCL_Char **argv,
00092 
00093                                 Domain*theTclDomain,
00094 
00095                                 TclModelBuilder *theTclBuilder,
00096 
00097                                 int eleArgStart)
00098 
00099 {
00100 
00101   // ensure the destructor has not been called -
00102 
00103   if (theTclBuilder == 0)
00104 
00105   {
00106 
00107     opserr << "command: element TotalLagrangianFD20nbrick - no modelbuilder \n";
00108 
00109     return TCL_ERROR;
00110 
00111   }
00112 
00113 
00114 
00115   // check the number of arguments is correct
00116 
00117   if ((argc-eleArgStart) < 26)
00118 
00119   {
00120 
00121     opserr << "command: element TotalLagrangianFD20nbrick - insufficient args - want " <<
00122 
00123       "element TotalLagrangianFD20nbrick eleTag? node1? node2? .. node20? matTag? bforce1? bforce2? bforce3? \n";
00124 
00125     return TCL_ERROR;
00126 
00127   }
00128 
00129 
00130 
00131   // get the id and end nodes
00132 
00133   int eleID, matID;
00134 
00135   int nodes[20];
00136 
00137   double bodyforces[3];
00138 
00139 
00140 
00141   // read the eleTag
00142 
00143   if (Tcl_GetInt(interp, argv[1+eleArgStart], &eleID) != TCL_OK)
00144 
00145   {
00146 
00147     opserr << "command: element TotalLagrangianFD20nbrick - invalid integer tag " << argv[1+eleArgStart] << "\n";
00148 
00149     return TCL_ERROR;
00150 
00151   }
00152 
00153 
00154 
00155   // read the 20 node tags
00156 
00157   for (int i=0; i<20; i++)
00158 
00159   {
00160 
00161       if (Tcl_GetInt(interp, argv[2+i+eleArgStart], &nodes[i]) != TCL_OK)
00162 
00163       {
00164 
00165   opserr << "command: element TotalLagrangianFD20nbrick " << eleID << " - invalid integer tag " <<
00166 
00167     argv[2+i+eleArgStart] << "\n";
00168 
00169   return TCL_ERROR;
00170 
00171       }
00172 
00173   }
00174 
00175 
00176 
00177   // read in material tag & check the material exists in the model builder
00178 
00179   if (Tcl_GetInt(interp, argv[22+eleArgStart], &matID) != TCL_OK)
00180 
00181   {
00182 
00183     opserr << "command: element TotalLagrangianFD20nbrick " << eleID << " - invalid matID tag " <<
00184 
00185       argv[22+eleArgStart] << "\n";
00186 
00187     return TCL_ERROR;
00188 
00189   }
00190 
00191 
00192 
00193   NDMaterial *theMaterial = theTclBuilder->getNDMaterial(matID);
00194 
00195 
00196 
00197   if (theMaterial == 0)
00198 
00199   {
00200 
00201     opserr << "command: element TotalLagrangianFD20nbrick " << eleID <<
00202 
00203       " - no NDMaterial with tag " << argv[22+eleArgStart] << "exists \n";
00204 
00205     return TCL_ERROR;
00206 
00207   }
00208 
00209 
00210 
00211   // read the 3 bodyforce accel's
00212 
00213   for (int j=0; j<3; j++)
00214 
00215   {
00216 
00217       if (Tcl_GetDouble(interp, argv[23+j+eleArgStart], &bodyforces[j]) != TCL_OK)
00218 
00219       {
00220 
00221   opserr << "command: element TotalLagrangianFD20nbrick " << eleID << " - invalid bodyforces tag " <<
00222 
00223     argv[23+j+eleArgStart] << "\n";
00224 
00225   return TCL_ERROR;
00226 
00227       }
00228 
00229   }
00230 
00231 
00232 
00233   // now create the TwentyNodeBrick and add it to the Domain
00234 
00235   TotalLagrangianFD20NodeBrick *theEle = new TotalLagrangianFD20NodeBrick(eleID,
00236 
00237                                                                           nodes[ 0],
00238 
00239                                                                           nodes[ 1],
00240 
00241                                                                           nodes[ 2],
00242 
00243                                                                           nodes[ 3],
00244 
00245                                                                           nodes[ 4],
00246 
00247                                                                           nodes[ 5],
00248 
00249                                                                           nodes[ 6],
00250 
00251                                                                           nodes[ 7],
00252 
00253                                                                           nodes[ 8],
00254 
00255                                                                           nodes[ 9],
00256 
00257                                                                           nodes[10],
00258 
00259                                                                           nodes[11],
00260 
00261                                                                           nodes[12],
00262 
00263                                                                           nodes[13],
00264 
00265                                                                           nodes[14],
00266 
00267                                                                           nodes[15],
00268 
00269                                                                           nodes[16],
00270 
00271                                                                           nodes[17],
00272 
00273                                                                           nodes[18],
00274 
00275                                                                           nodes[19],
00276 
00277                                                                          *theMaterial,
00278 
00279                                                                           bodyforces[0],
00280 
00281                                                                           bodyforces[1],
00282 
00283                                                                           bodyforces[2]);
00284 
00285 
00286 
00287   if (theEle == 0)
00288 
00289   {
00290 
00291     opserr << "command: element TotalLagrangianFD20nbrick " << eleID << " - out of memory \n";
00292 
00293     return TCL_ERROR;
00294 
00295   }
00296 
00297 
00298 
00299   if (theTclDomain->addElement(theEle) == false)
00300 
00301   {
00302 
00303     opserr << "command: element TotalLagrangianFD20nbrick  - could not add ele: " << eleID << " to domain \n";
00304 
00305     delete theEle;
00306 
00307     return TCL_ERROR;
00308 
00309   }
00310 
00311 
00312 
00313    // if get here we have sucessfully created the node and added it to the domain
00314 
00315   return TCL_OK;
00316 
00317 }
00318 
00319 
00320 
00321 
00322 
00323 
00324 
00325 int
00326 
00327 TclModelBuilder_addTLFD8nBrick(ClientData clientData,
00328 
00329                                 Tcl_Interp *interp,
00330 
00331                                 int argc,
00332 
00333                                 TCL_Char **argv,
00334 
00335                                 Domain*theTclDomain,
00336 
00337                                 TclModelBuilder *theTclBuilder,
00338 
00339                                 int eleArgStart)
00340 
00341 {
00342 
00343   // ensure the destructor has not been called -
00344 
00345   if (theTclBuilder == 0)
00346 
00347   {
00348 
00349     opserr << "command: element TotalLagrangianFD8nbrick - no modelbuilder \n";
00350 
00351     return TCL_ERROR;
00352 
00353   }
00354 
00355 
00356 
00357   // check the number of arguments is correct
00358 
00359   if ((argc-eleArgStart) < 14)
00360 
00361   {
00362 
00363     opserr << "command: element TotalLagrangianFD8nbrick - insufficient args - want " <<
00364 
00365       "element TotalLagrangianFD8nbrick eleTag? node1? node2? .. node8? matTag? bforce1? bforce2? bforce3? \n";
00366 
00367     return TCL_ERROR;
00368 
00369   }
00370 
00371 
00372 
00373   // get the id and end nodes
00374 
00375   int eleID, matID;
00376 
00377   int nodes[8];
00378 
00379   double bodyforces[3];
00380 
00381 
00382 
00383   // read the eleTag
00384 
00385   if (Tcl_GetInt(interp, argv[1+eleArgStart], &eleID) != TCL_OK)
00386 
00387   {
00388 
00389     opserr << "command: element TotalLagrangianFD8nbrick - invalid integer tag " << argv[1+eleArgStart] << "\n";
00390 
00391     return TCL_ERROR;
00392 
00393   }
00394 
00395 
00396 
00397   // read the 8 node tags
00398 
00399   for (int i=0; i<8; i++)
00400 
00401   {
00402 
00403       if (Tcl_GetInt(interp, argv[2+i+eleArgStart], &nodes[i]) != TCL_OK)
00404 
00405       {
00406 
00407   opserr << "command: element TotalLagrangianFD8nbrick " << eleID << " - invalid integer tag " <<
00408 
00409     argv[2+i+eleArgStart] << "\n";
00410 
00411   return TCL_ERROR;
00412 
00413       }
00414 
00415   }
00416 
00417 
00418 
00419   // read in material tag & check the material exists in the model builder
00420 
00421   if (Tcl_GetInt(interp, argv[10+eleArgStart], &matID) != TCL_OK)
00422 
00423   {
00424 
00425     opserr << "command: element TotalLagrangianFD8nbrick " << eleID << " - invalid matID tag " <<
00426 
00427       argv[10+eleArgStart] << "\n";
00428 
00429     return TCL_ERROR;
00430 
00431   }
00432 
00433 
00434 
00435   NDMaterial *theMaterial = theTclBuilder->getNDMaterial(matID);
00436 
00437 
00438 
00439   if (theMaterial == 0)
00440 
00441   {
00442 
00443     opserr << "command: element TotalLagrangianFD8nbrick " << eleID <<
00444 
00445       " - no NDMaterial with tag " << argv[10+eleArgStart] << "exists \n";
00446 
00447     return TCL_ERROR;
00448 
00449   }
00450 
00451 
00452 
00453   // read the 3 bodyforce accel's
00454 
00455   for (int j=0; j<3; j++)
00456 
00457   {
00458 
00459       if (Tcl_GetDouble(interp, argv[11+j+eleArgStart], &bodyforces[j]) != TCL_OK)
00460 
00461       {
00462 
00463   opserr << "command: element TotalLagrangianFD8nbrick " << eleID << " - invalid bodyforces tag " <<
00464 
00465     argv[11+j+eleArgStart] << "\n";
00466 
00467   return TCL_ERROR;
00468 
00469       }
00470 
00471   }
00472 
00473 
00474 
00475   // now create the TwentyNodeBrick and add it to the Domain
00476 
00477   TotalLagrangianFD8NodeBrick *theEle = new TotalLagrangianFD8NodeBrick(eleID,
00478 
00479                                                                           nodes[ 0],
00480 
00481                                                                           nodes[ 1],
00482 
00483                                                                           nodes[ 2],
00484 
00485                                                                           nodes[ 3],
00486 
00487                                                                           nodes[ 4],
00488 
00489                                                                           nodes[ 5],
00490 
00491                                                                           nodes[ 6],
00492 
00493                                                                           nodes[ 7],
00494 
00495                                                                          *theMaterial,
00496 
00497                                                                           bodyforces[0],
00498 
00499                                                                           bodyforces[1],
00500 
00501                                                                           bodyforces[2]);
00502 
00503 
00504 
00505   if (theEle == 0)
00506 
00507   {
00508 
00509     opserr << "command: element TotalLagrangianFD8nbrick " << eleID << " - out of memory \n";
00510 
00511     return TCL_ERROR;
00512 
00513   }
00514 
00515 
00516 
00517   if (theTclDomain->addElement(theEle) == false)
00518 
00519   {
00520 
00521     opserr << "command: element TotalLagrangianFD8nbrick  - could not add ele: " << eleID << " to domain \n";
00522 
00523     delete theEle;
00524 
00525     return TCL_ERROR;
00526 
00527   }
00528 
00529 
00530 
00531    // if get here we have sucessfully created the node and added it to the domain
00532 
00533   return TCL_OK;
00534 
00535 }
00536 
00537 
00538 
00539 
00540 
00541 
00542 

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