PlaneFrame.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.3 $
00022 // $Date: 2003/02/25 23:34:25 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/modelbuilder/PlaneFrame.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/model/PlaneFrame.C
00027 //
00028 // Written: fmk 
00029 // Created: Mon Sept 15 14:47:47: 1996
00030 // Revision: A
00031 //
00032 // Description: This file contains the class definition for PlaneFrame
00033 // PlaneFrame is a class used to model a structure with a plane frame. 
00034 // The object creates the components of the model and adds these to the
00035 // Domain with which it is associated.
00036 
00037 #include <PlaneFrame.h>
00038 #include <Domain.h>
00039 #include <fstream>
00040 using std::ifstream;
00041 
00042 #include <iostream>
00043 using std::cout;
00044 using std::cin;
00045 
00046 #include <iomanip>
00047 using std::ios;
00048 #include <stdlib.h>
00049 
00050 #include <ElasticBeam2d.h>
00051 #include <LinearCrdTransf2d.h>
00052 #include <NodalLoad.h>
00053 #include <Node.h>
00054 #include <SP_Constraint.h>
00055 #include <MP_Constraint.h>
00056 #include <LoadPattern.h>
00057 #include <LinearSeries.h>
00058 
00059 //  PlaneFrameModel();
00060 //      constructor
00061 PlaneFrame::PlaneFrame(Domain &theDomain)
00062 :ModelBuilder(theDomain)
00063 {
00064 
00065 }
00066 
00067 // ~PlaneFrame();    
00068 //      destructor,
00069 
00070 PlaneFrame::~PlaneFrame()
00071 {
00072 
00073 }    
00074 
00075 int
00076 PlaneFrame::buildFE_Model(void) 
00077 {
00078     int numEle, numNode, numSPs, numMPs, numNodLoads;
00079     int res = 0;
00080     Domain *theDomain = this->getDomainPtr();    
00081     if (theDomain == 0) {
00082         opserr << "FATAL::PlaneFrame::buildModel(void) -";
00083         opserr << " no associated domain !! - what have you been doing\n";
00084         exit(-1);
00085     }   
00086     
00087     // get the input file and open it for reading
00088     char fileName[15];
00089     cout << "Enter File Containing Model: ";
00090     cin >> fileName;
00091     cout << fileName;
00092     
00093     ifstream inputFile(fileName, ios::in);
00094     if (!inputFile) {
00095         opserr << "FATAL:PlaneFrame::buildModel(void) -";
00096         opserr << " could not open file: " << fileName << endln;
00097         exit(-1);
00098     }
00099     
00100     //
00101     // read in the model paramaters
00102     //    :numNodes numElements numSP_Constraints Num MP_Constraints 
00103     //     numLoadCases
00104 
00105     inputFile >> numNode >> numEle >> numSPs >> numMPs >> numNodLoads;
00106 
00107     //
00108     // read in the nodal data
00109     //  each of numNode nodes: tag xCrd yCrd
00110 
00111     Node *NodePtr;
00112     int tag, ndof;
00113     double xCrd, yCrd;
00114     bool result;
00115     ndof = 3;
00116     int i;
00117         Vector dummy(2);
00118         CrdTransf2d *theTransf = new LinearCrdTransf2d (1,dummy,dummy);
00119 
00120     
00121     // for each node read in the data, create a node & add it to the domain
00122         for (i=0; i<numNode; i++) {
00123         inputFile >> tag >> xCrd >> yCrd;
00124         NodePtr = new Node(tag,ndof,xCrd,yCrd);
00125         result = theDomain->addNode(NodePtr);
00126         if (result == false) {
00127                 res =-1;
00128                 opserr << "PlaneFrame::buildModel(void) -";
00129                 opserr << " problems adding node " << tag << endln;
00130         }
00131     }
00132 
00133 
00134     // read in the elemental data, model only recognises type 2 and 3
00135     // for element type beam2d04 and beam2d03.
00136     //    each of numEle elements: type tag A E I node1 node2
00137 
00138     Element *elePtr;
00139     double A,E,I;
00140     int nd1, nd2;
00141     for (i=0; i<numEle; i++) {
00142         inputFile >> tag >> A >> E >> I >> nd1 >> nd2;
00143         elePtr = new ElasticBeam2d(tag,A,E,I,nd1,nd2,*theTransf);
00144         result = theDomain->addElement(elePtr);
00145         if (result == false) {
00146                 res =-1;
00147                 opserr << "PlaneFrame::buildModel(void) -";
00148                 opserr << " problems adding element " << tag << endln;
00149         }
00150     }
00151 
00152     // add a LoadPattern with a LinearSeries
00153     LoadPattern *theLoadPattern = new LoadPattern(0);
00154     TimeSeries  *theSeries = new LinearSeries(1.0);
00155     theLoadPattern->setTimeSeries(theSeries);
00156     result = theDomain->addLoadPattern(theLoadPattern);
00157     if (result == false) {
00158       opserr << "PlaneFrame::buildModel(void) -";
00159       opserr << " problems adding load pattern " << *theLoadPattern;
00160       res =-1;
00161     }    
00162 
00163     
00164     //
00165     // read in the SP Constraint data
00166     //   each of numSPs SP_Constraints: nodeTag dof value
00167     
00168     SP_Constraint *SPPtr;
00169     for (i=0; i<numSPs; i++) {
00170         inputFile >> nd1 >> nd2 >> E;
00171         SPPtr = new SP_Constraint(i,nd1,nd2,E);
00172         result = theDomain->addSP_Constraint(SPPtr, 0);
00173         if (result == false) {
00174                 res =-1;
00175                 opserr << "PlaneFrame::buildModel(void) -";
00176                 opserr << " problems adding SP_Constraint on " << nd1 << endln;
00177         }
00178     }    
00179 
00180     //
00181     // read in the MP Constraint data
00182     //   each of numMPs SP_Constraints: nodeTag dof value
00183     
00184     MP_Constraint *MPPtr;
00185     int numDOF1, numDOF2;
00186     for (i=0; i<numMPs; i++) {
00187         inputFile >> nd1 >> nd2 >> numDOF1 >> numDOF2;
00188         ID constrainedDOF(numDOF1);
00189         ID retainedDOF(numDOF2);        
00190         for (int j=0; j<numDOF1; j++)
00191           inputFile >> constrainedDOF(j);
00192         for (int k=0; k<numDOF2; k++)
00193           inputFile >> retainedDOF(k);
00194         Matrix Ccr(numDOF1,numDOF2);
00195         for (int jj=0; jj<numDOF1; jj++)
00196           for (int kk=0; kk<numDOF2; kk++)
00197           inputFile >> Ccr(jj,kk);
00198         MPPtr = new MP_Constraint(i,nd2,nd1,Ccr,constrainedDOF,retainedDOF);
00199         result = theDomain->addMP_Constraint(MPPtr);
00200         if (result == false) {
00201                 res =-1;
00202                 opserr << "PlaneFrame::buildModel(void) -";
00203                 opserr << " problems adding MP_Constraint on " << nd1 << endln;
00204         }
00205 
00206     }        
00207 
00208     Vector forces(3);
00209     NodalLoad *nodeLoadPtr;    
00210     for (i=0; i<numNodLoads; i++) {
00211         inputFile >> tag >> forces(0) >> forces(1) >> forces(2);
00212         nodeLoadPtr = new NodalLoad(i, tag, forces);
00213         bool result = theDomain->addNodalLoad(nodeLoadPtr, 0);
00214         if (result == false) {
00215                 opserr << "PlaneFrame::buildModel(void) -";
00216                 opserr << " problems adding load " << *nodeLoadPtr;
00217                 res =-1;
00218         }
00219     }    
00220 
00221     //
00222     // done inputing the model
00223     //
00224     return res;
00225 }       
00226         
00227 
00228 
00229 
00230 
00231 

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