00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <PartitionedQuick2dFrame.h>
00028 #include <PartitionedDomain.h>
00029 #include <Subdomain.h>
00030 #include <iOPS_Stream.h>
00031 #include <fstream.h>
00032 #include <stdlib.h>
00033
00034 #include <beam2d02.h>
00035 #include <beam2d03.h>
00036 #include <beam2d04.h>
00037
00038 #include <NodalLoad.h>
00039 #include <Node.h>
00040 #include <SP_Constraint.h>
00041 #include <MP_Constraint.h>
00042
00043
00044
00045 PartitionedQuick2dFrame::PartitionedQuick2dFrame(PartitionedDomain &theDomain,
00046 int numXX, int numYY,
00047 int eleTType)
00048 :PartitionedModelBuilder(theDomain,
00049 PartitionedModelBuilder_TAGS_PartitionedQuick2dFrameModel),
00050 numX(numXX), numY(numYY), eleType(eleTType),
00051 numEle(0),numNode(0),numSPs(0),numMPs(0),numLCs(0)
00052 {
00053
00054 }
00055
00056
00057 PartitionedQuick2dFrame::PartitionedQuick2dFrame(Subdomain &theDomain)
00058 :PartitionedModelBuilder(theDomain,
00059 PartitionedModelBuilder_TAGS_PartitionedQuick2dFrameModel),
00060 numX(0), numY(0), eleType(0),
00061 numEle(0),numNode(0),numSPs(0),numMPs(0),numLCs(0)
00062 {
00063
00064 }
00065
00066
00067
00068
00069
00070
00071 PartitionedQuick2dFrame::~PartitionedQuick2dFrame()
00072 {
00073
00074 }
00075
00076 int
00077 PartitionedQuick2dFrame::buildInterface(int numSubdomains)
00078 {
00079
00080 Domain *theDomain = this->getDomainPtr();
00081 if (theDomain == 0) {
00082 opserr << "FATAL:PlaneFrame::buildModel(void) -";
00083 opserr << " no associated domain.\n";
00084 exit(-1);
00085 return -1;
00086 }
00087
00088 if (numSubdomains == 0) {
00089 opserr << "FATAL:PlaneFrame::buildModel(void) -";
00090 opserr << " numSubdomains = 0\n";
00091 exit(-1);
00092 return -2;
00093 }
00094
00095
00096
00097
00098 int i,j;
00099 double LL_x, LL_y, UR_x, UR_y, DIV_x, DIV_y, CURR_y, CURR_x;
00100 int NO_x, NO_y;
00101 LL_x = 0;
00102 LL_y = 0;
00103 UR_x = 1;
00104 UR_y = 2;
00105
00106 NO_x = numX + 1;
00107 NO_y = numY + 1;
00108 numNode = NO_x * NO_y;
00109 numSPs = NO_x;
00110 int numLoads = NO_y-1;
00111 numLCs = 1;
00112
00113 DIV_x = (UR_x - LL_x) / (NO_x - 1);
00114 DIV_y = (UR_y - LL_y) / (NO_y - 1);
00115 CURR_y = LL_y;
00116
00117 int numSubstructureStories = numY / numSubdomains;
00118
00119 DIV_y *= numSubstructureStories;
00120 LL_y += DIV_y;
00121 int ok;
00122 int nodeNum = 1 + NO_x*numSubstructureStories;
00123
00124 for (i=1; i<numSubdomains; i++) {
00125 CURR_x = LL_x;
00126
00127 for (j=0; j<NO_x; j++) {
00128
00129 Node *nodePtr = new Node(nodeNum,3,CURR_x,CURR_y);
00130 if (nodePtr != 0) {
00131 ok = theDomain->addNode(nodePtr);
00132 if (ok < 0) {
00133 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00134 opserr << " could not add Node " << nodeNum << endln;
00135 return -1;
00136 }
00137 nodeNum++;
00138 CURR_x += DIV_x;
00139 } else {
00140 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00141 opserr << " ran out of memory creating Node " << nodeNum << endln;
00142 return -1;
00143 }
00144
00145 }
00146 CURR_y += DIV_y;
00147 nodeNum += (numSubstructureStories-1)*NO_x;
00148 }
00149
00150
00151 double x_ld = 10;
00152 double y_ld = 0;
00153 double theta_ld = 0;
00154
00155
00156
00157
00158
00159 numLoads = numSubdomains-1;
00160
00161 Vector forces(3);
00162 forces(0) = x_ld; forces(1) = y_ld; forces(2) = theta_ld;
00163 for (i=0; i<numLoads; i++) {
00164
00165 nodeNum = (i+1)*NO_x*numSubstructureStories+1;
00166 NodalLoad *nodeLoadPtr = new NodalLoad(nodeNum,forces);
00167 if (nodeLoadPtr != 0) {
00168 ok = theDomain->addNodalLoad(nodeLoadPtr);
00169 if (ok < 0) {
00170 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00171 opserr << " could not add nodal load " << nodeNum << endln;
00172 return -1;
00173 }
00174 } else {
00175 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ran out of ";
00176 opserr << "memory creating Nodal Load " << nodeNum << endln;
00177 return -1;
00178 }
00179 }
00180
00181
00182 return 0;
00183 }
00184
00185
00186
00187
00188
00189 int
00190 PartitionedQuick2dFrame::buildSubdomain(int subdomain,
00191 int numSubdomains,
00192 Subdomain &theSubdomain)
00193 {
00194 subdomain--;
00195
00196 int numSect, numMat, numLoads;
00197 int i,j;
00198
00199 int x_rst,y_rst,theta_rst;
00200 float x_ld, y_ld, theta_ld;
00201
00202 numSect = 2;
00203 numMat = 2;
00204
00205
00206
00207
00208 int SectDat = 2;
00209 int MatDat = 1;
00210
00211 Vector Sections(numSect*SectDat);
00212 Vector Materials(numMat*MatDat);
00213
00214
00215
00216
00217
00218
00219 for (i=0; i<numSect; i++) {
00220 Sections(i*SectDat) = 1; Sections(i*SectDat+1) = 1;
00221 }
00222
00223 for (i=0; i<numMat; i++) {
00224 Materials(i*MatDat) = 1;
00225 }
00226
00227
00228
00229
00230 double LL_x, LL_y, UR_x, UR_y, DIV_x, DIV_y, CURR_y, CURR_x;
00231 int NO_x, NO_y;
00232 LL_x = 0;
00233 LL_y = 0;
00234 UR_x = 1;
00235 UR_y = 2;
00236
00237 NO_x = numX + 1;
00238 NO_y = numY + 1;
00239 numNode = NO_x * NO_y;
00240 numSPs = NO_x;
00241 numLoads = NO_y-1;
00242 numLCs = 1;
00243
00244 DIV_x = (UR_x - LL_x) / (NO_x - 1);
00245 DIV_y = (UR_y - LL_y) / (NO_y - 1);
00246 CURR_y = LL_y;
00247
00248 int numSubdomainStories = numY / numSubdomains;
00249 int nodeNum = 1 + subdomain*numSubdomainStories*NO_x;
00250 LL_y += DIV_y*numSubdomainStories*subdomain;
00251 if (subdomain == (numSubdomains-1))
00252 numSubdomainStories += numY - numSubdomainStories*numSubdomains;
00253
00254 int ok;
00255 for (i=0; i<numSubdomainStories+1; i++) {
00256 CURR_x = LL_x;
00257 for (j=0; j<NO_x; j++) {
00258 Node *nodePtr = new Node(nodeNum,3,CURR_x,CURR_y);
00259 if (nodePtr != 0) {
00260 if (i == 0 && subdomain != 0)
00261 ok = theSubdomain.addExternalNode(nodePtr);
00262 else if (i == numSubdomainStories && subdomain != (numSubdomains-1))
00263 ok = theSubdomain.addExternalNode(nodePtr);
00264 else
00265 ok = theSubdomain.addNode(nodePtr);
00266
00267 if (ok < 0) {
00268 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00269 opserr << " could not add Node " << nodeNum << endln;
00270 return -1;
00271 }
00272 nodeNum++;
00273 CURR_x += DIV_x;
00274 } else {
00275 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00276 opserr << " ran out of memory creating Node " << nodeNum << endln;
00277 return -1;
00278 }
00279 }
00280 CURR_y += DIV_y;
00281 }
00282
00283
00284
00285
00286
00287
00288
00289 numSubdomainStories = numY / numSubdomains;
00290 int start_node = 1 + subdomain*numSubdomainStories*NO_x;
00291 int eleNum = 0 + NO_x * numSubdomainStories*subdomain + (NO_x-1)*numSubdomainStories*subdomain;
00292 if (subdomain == (numSubdomains-1))
00293 numSubdomainStories += numY - numSubdomainStories*numSubdomains;
00294
00295
00296 for (i=0; i<numSubdomainStories; i++) {
00297 int inode = start_node;
00298 int jnode = start_node + NO_x;
00299 Element *elePtr =0;
00300
00301
00302 double A = Sections(0);
00303 double E = Materials(0);
00304 double I = Sections(1);
00305
00306 for (j=0; j < NO_x; j++) {
00307
00308 if (eleType == 2)
00309 elePtr = new beam2d02(eleNum,A,E,I,inode,jnode);
00310 else if (eleType == 3)
00311 elePtr = new beam2d03(eleNum,A,E,I,inode,jnode);
00312 else
00313 elePtr = new beam2d04(eleNum,A,E,I,inode,jnode);
00314
00315
00316 if (elePtr != 0) {
00317 ok = theSubdomain.addElement(elePtr);
00318
00319 if (ok < 0) {
00320 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00321 opserr << " could not add Element " << eleNum << endln;
00322 return -1;
00323 }
00324 } else {
00325 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00326 opserr << " ran out of memory creating Element " << eleNum << endln;
00327 return -1;
00328 }
00329 inode++;
00330 jnode++;
00331 eleNum++;
00332 }
00333
00334 A = Sections(2);
00335 E = Materials(1);
00336 I = Sections(3);
00337 jnode = inode++;
00338 for (j=0; j< (NO_x-1); j++) {
00339
00340 if (eleType == 2)
00341 elePtr = new beam2d02(eleNum,A,E,I,jnode,inode);
00342 else if (eleType == 3)
00343 elePtr = new beam2d03(eleNum,A,E,I,jnode,inode);
00344 else
00345 elePtr = new beam2d04(eleNum,A,E,I,jnode,inode);
00346
00347
00348 if (elePtr != 0) {
00349 ok = theSubdomain.addElement(elePtr);
00350 if (ok < 0) {
00351 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00352 opserr << " could not add Element " << eleNum << endln;
00353 return -1;
00354 }
00355 } else {
00356 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00357 opserr << " ran out of memory creating Element " << eleNum << endln;
00358 return -1;
00359 }
00360 inode++;
00361 jnode++;
00362 eleNum++;
00363 }
00364 start_node += NO_x;
00365 }
00366
00367
00368
00369
00370
00371 x_rst = 1;
00372 y_rst = 1;
00373 theta_rst = 1;
00374
00375 if (subdomain == 0) {
00376 nodeNum = 1;
00377 for (i=0; i<NO_x; i++) {
00378 SP_Constraint *spPtr;
00379
00380 if (x_rst == 1) {
00381 spPtr = new SP_Constraint(nodeNum,0,0.0);
00382
00383 if (spPtr != 0) {
00384 ok = theSubdomain.addSP_Constraint(spPtr);
00385 if (ok < 0) {
00386 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00387 opserr << " could not add SP_Constraint " << nodeNum << endln;
00388 return -1;
00389 }
00390 } else {
00391 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ran out of ";
00392 opserr << "memory creating SP_Constraint " << nodeNum << endln;
00393 return -1;
00394 }
00395 }
00396
00397 if (y_rst == 1) {
00398 spPtr = new SP_Constraint(nodeNum,1,0.0);
00399
00400 if (spPtr != 0) {
00401 ok = theSubdomain.addSP_Constraint(spPtr);
00402 if (ok < 0) {
00403 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00404 opserr << " could not add SP_Constraint " << nodeNum << endln;
00405 return -1;
00406 }
00407 } else {
00408 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ran out of ";
00409 opserr << "memory creating SP_Constraint " << nodeNum << endln;
00410 return -1;
00411 }
00412 }
00413
00414 if (theta_rst == 1) {
00415 spPtr = new SP_Constraint(nodeNum,2,0.0);
00416
00417 if (spPtr != 0) {
00418 ok = theSubdomain.addSP_Constraint(spPtr);
00419 if (ok < 0) {
00420 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00421 opserr << " could not add SP_Constraint " << nodeNum << endln;
00422 return -1;
00423 }
00424 } else {
00425 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ran out of ";
00426 opserr << "memory creating SP_Constraint " << nodeNum << endln;
00427 return -1;
00428 }
00429 }
00430 nodeNum++;
00431 }
00432 }
00433
00434
00435 numSubdomainStories = numY / numSubdomains;
00436 start_node = 1 + subdomain*numSubdomainStories*NO_x;
00437 if (subdomain == (numSubdomains-1))
00438 numSubdomainStories += numY - numSubdomainStories*numSubdomains;
00439
00440 x_ld = 10;
00441 y_ld = 0;
00442 theta_ld = 0;
00443
00444
00445
00446
00447
00448 Vector forces(3);
00449 forces(0) = x_ld; forces(1) = y_ld; forces(2) = theta_ld;
00450 for (i=1; i<numSubdomainStories; i++) {
00451
00452 nodeNum = start_node+i*NO_x;
00453 NodalLoad *nodeLoadPtr = new NodalLoad(nodeNum,forces);
00454 if (nodeLoadPtr != 0) {
00455 ok = theSubdomain.addNodalLoad(nodeLoadPtr);
00456 if (ok < 0) {
00457 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00458 opserr << " could not add nodal load " << nodeNum << endln;
00459 return -1;
00460 }
00461 } else {
00462 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ran out of ";
00463 opserr << "memory creating Nodal Load " << nodeNum << endln;
00464 return -1;
00465 }
00466 }
00467
00468 if (subdomain == (numSubdomains-1)) {
00469 nodeNum = start_node+numSubdomainStories*NO_x;
00470 NodalLoad *nodeLoadPtr = new NodalLoad(nodeNum,forces);
00471 if (nodeLoadPtr != 0) {
00472 ok = theSubdomain.addNodalLoad(nodeLoadPtr);
00473 if (ok < 0) {
00474 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ";
00475 opserr << " could not add nodal load " << nodeNum << endln;
00476 return -1;
00477 }
00478 } else {
00479 opserr << "PartitionedQuick2dFrame::PartitionedQuick2dFrame::Input ran out of ";
00480 opserr << "memory creating Nodal Load " << nodeNum << endln;
00481 return -1;
00482 }
00483 }
00484
00485 return 0;
00486 }
00487
00488
00489
00490 int
00491 PartitionedQuick2dFrame::sendSelf(int cTag, Channel &theChannel)
00492 {
00493 int dataTag = this->getDbTag();
00494 ID data(3);
00495 data(0) = numX;
00496 data(1) = numY;
00497 data(2) = eleType;
00498
00499 theChannel.sendID(dataTag, cTag, data);
00500 return 0;
00501 }
00502
00503 int
00504 PartitionedQuick2dFrame::recvSelf(int cTag, Channel &theChannel,
00505 FEM_ObjectBroker &theBroker)
00506 {
00507 int dataTag = this->getDbTag();
00508 ID data(3);
00509 theChannel.recvID(dataTag, cTag, data);
00510 numX = data(0);
00511 numY = data(1);
00512 eleType = data(2);
00513
00514 return 0;
00515
00516 }