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
00028
00029
00030
00031
00032
00033 #include <DamageRecorder.h>
00034 #include <Domain.h>
00035 #include <Element.h>
00036 #include <Matrix.h>
00037 #include <Vector.h>
00038 #include <ID.h>
00039 #include <string.h>
00040 #include <Response.h>
00041 #include <FE_Datastore.h>
00042 #include <DamageModel.h>
00043
00044 #include <OPS_Globals.h>
00045
00046 #include <iomanip>
00047 using std::ios;
00048
00049 DamageRecorder::DamageRecorder( int elemid, ID &secIDs, int dofid, DamageModel *dmgPtr,
00050 Domain &theDomainPtr, bool echotimeflag, double deltat , OPS_Stream &output)
00051 :Recorder(RECORDER_TAGS_DamageRecorder),
00052 eleID(elemid) , numSec(secIDs.Size()), dofID(dofid),
00053 responseID(secIDs.Size()), sectionTags(secIDs.Size()),theDomain(&theDomainPtr),
00054 echoTimeFlag(echotimeflag), deltaT(deltat), nextTimeStampToRecord(0.0),
00055 theOutput(&output), data(0)
00056 {
00057
00058 if ( dmgPtr == NULL ) {
00059 opserr << "DamageRecorder::DamageRecorder - no damage pointer associated with the damge recorder" <<endln;
00060 exit(-1);
00061 }
00062
00063 theOutput->tag("OpenSeesOutput");
00064
00065 int numDbColumns = 0;
00066 if (echoTimeFlag == true) {
00067 theOutput->tag("TimeOutput");
00068 theOutput->attr("ResponseType", "time");
00069 theOutput->endTag();
00070 numDbColumns += 1;
00071 }
00072
00073 theDamageModels = new DamageModel *[numSec];
00074
00075 int j;
00076 for (j= 0; j<numSec; j++) {
00077 theDamageModels[j] = dmgPtr->getCopy();
00078 if ( theDamageModels [j] == NULL ) {
00079 opserr << "DamageRecorder::DamageRecorder - out of memory copying damage models ";
00080 exit(-1);
00081 }
00082 theDamageModels[j]->revertToStart();
00083 }
00084
00085
00086 Information eleInfo(1.0);
00087 Element *theEle = theDomainPtr.getElement(eleID);
00088 if ( theEle == NULL ) {
00089 opserr << "WARNING DamageRecorder::DamageRecorder() - no element with tag: "
00090 << eleID << " exists in Domain\n";
00091 exit(-1);
00092 }
00093
00094
00095 theResponses = new Response *[3*numSec];
00096 for ( j=0; j<3*numSec; j++)
00097 theResponses[j] = NULL;
00098
00099
00100 const int argc = 3;
00101 char *argv[argc];
00102 for ( j = 0; j<argc ; j++ )
00103 argv[j] = new char[20];
00104
00105 strcpy( argv[0] , "-section" );
00106 strcpy( argv[2] , "deformation" );
00107 for ( j=0 ; j<numSec ; j++) {
00108 sectionTags(j) = secIDs(j);
00109 sprintf(argv[1],"%d",sectionTags(j));
00110
00111
00112 theResponses[j] = theEle->setResponse( ( const char**)argv, argc, eleInfo, *theOutput);
00113 if (theResponses[j] == 0) {
00114 opserr << "DamageRecorder::DamageRecorder - out of memory creating deformation response ";
00115 exit(-1);
00116 }
00117 }
00118
00119
00120 strcpy( argv[2] , "force" );
00121 for ( j=0 ; j<numSec ; j++) {
00122 sectionTags(j) = secIDs(j);
00123 sprintf(argv[1],"%d",sectionTags(j));
00124
00125 theResponses[j+numSec] = theEle->setResponse( ( const char**) argv, argc, eleInfo, *theOutput);
00126 if (theResponses[j+numSec] == 0) {
00127 opserr << "DamageRecorder::DamageRecorder - out of memory creating force response ";
00128 exit(-1);
00129 }
00130 }
00131
00132 strcpy( argv[2] , "stiffness" );
00133 for ( j=0 ; j<numSec ; j++) {
00134 sectionTags(j) = secIDs(j);
00135 sprintf(argv[1],"%d",sectionTags(j));
00136
00137 theResponses[j+2*numSec] = theEle->setResponse( ( const char**) argv, argc, eleInfo, *theOutput);
00138 if (theResponses[j+2*numSec] == 0) {
00139 opserr << "DamageRecorder::DamageRecorder - out of memory creating tanegnt response ";
00140 exit(-1);
00141 }
00142 }
00143
00144 for ( j = 0; j<argc ; j++ )
00145 delete( argv[j] );
00146
00147
00148 numDbColumns += numSec;
00149
00150
00151 data = new Vector(numDbColumns);
00152
00153 theOutput->tag("Data");
00154 }
00155
00156
00157 DamageRecorder::~DamageRecorder()
00158 {
00159 if (data != 0)
00160 delete data;
00161
00162
00163
00164
00165
00166 if (theResponses != 0) {
00167 for (int i = 0; i < 3*numSec; i++)
00168 delete theResponses[i];
00169 delete [] theResponses;
00170 }
00171
00172 if (theDamageModels!=0) {
00173 for ( int i=0; i<numSec; i++)
00174 delete theDamageModels[i];
00175 delete []theDamageModels;
00176 }
00177
00178 theOutput->endTag();
00179 theOutput->endTag();
00180
00181 if (theOutput != 0)
00182 delete theOutput;
00183 }
00184
00185
00186 int
00187 DamageRecorder::record(int commitTag, double timeStamp)
00188 {
00189 int result = 0;
00190 if (deltaT == 0.0 || timeStamp >= nextTimeStampToRecord) {
00191
00192 if (deltaT != 0.0)
00193 nextTimeStampToRecord = timeStamp + deltaT;
00194
00195
00196 int counter = 0;
00197 if (echoTimeFlag == true) {
00198 (*data)(counter++) = timeStamp;
00199 }
00200
00201 Vector DamageInformation(3);
00202
00203
00204 for (int i=0; i< numSec; i++) {
00205 DamageInformation.Zero();
00206 for ( int j=0 ; j<2 ; j++) {
00207 if ( theResponses[i+numSec*j] == 0) {
00208 DamageInformation(j) = 0.0;
00209 } else {
00210 if ( theResponses[i+numSec*j]->getResponse() < 0) {
00211 DamageInformation(j) = 0.0;
00212 } else {
00213
00214 Information &eleinfo = theResponses[i+numSec*j]->getInformation();
00215 const Vector &infovector = eleinfo.getData();
00216 DamageInformation(j) = infovector(dofID);
00217 }
00218 }
00219 }
00220 DamageInformation(2) = 0.0;
00221 theDamageModels[i]->setTrial(DamageInformation);
00222 theDamageModels[i]->commitState();
00223 double Damageindex = theDamageModels[i]->getDamage();
00224
00225
00226
00227
00228 (*data)(counter++) = Damageindex;
00229 }
00230 }
00231
00232 theOutput->write(*data);
00233
00234
00235 return result;
00236 }
00237
00238
00239 int
00240 DamageRecorder::playback(int commitTag)
00241 {
00242 return 0;
00243 }
00244
00245 int
00246 DamageRecorder::restart(void)
00247 {
00248 return 0;
00249 }
00250