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 #include <GSA_Recorder.h>
00033 #include <Domain.h>
00034 #include <Node.h>
00035 #include <Element.h>
00036 #include <SP_Constraint.h>
00037 #include <NodeIter.h>
00038 #include <ElementIter.h>
00039 #include <SP_ConstraintIter.h>
00040 #include <Vector.h>
00041 #include <ID.h>
00042 #include <Matrix.h>
00043
00044 GSA_Recorder::GSA_Recorder(Domain &theDom,
00045 const char *fileName,
00046 const char *title1,
00047 const char *title2,
00048 const char *title3,
00049 const char *jobno,
00050 const char *initials,
00051 const char *spec,
00052 const char *currency,
00053 const char *length,
00054 const char *force,
00055 const char *temp,
00056 double dT)
00057 : Recorder(RECORDER_TAGS_GSA_Recorder),
00058 theDomain(&theDom), ndm(3), ndf(6), counter(0), deltaT(dT), nextTimeStampToRecord(0.0)
00059 {
00060
00061 if (theFile.setFile(fileName, OVERWRITE) < 0) {
00062 opserr << "WARNING - GSA_Recorder::GSA_Recorder()";
00063 opserr << " - could not open file " << fileName << endln;
00064 exit(-1);
00065 }
00066
00067
00068 if (title1 != 0)
00069 theFile << "TITLE\t" << title1;
00070 else
00071 theFile << "TITLE\t" << "No Title";
00072
00073
00074 if (title2 != 0)
00075 theFile << "\t" << title2;
00076 else
00077 theFile << "\t" << "BLANK";
00078
00079
00080 if (title3 != 0)
00081 theFile << "\t" << title3;
00082 else
00083 theFile << "\t" << "BLANK";
00084
00085
00086 if (jobno != 0)
00087 theFile << "\t" << jobno;
00088 else
00089 theFile << "\t" << "0000";
00090
00091
00092 if (initials != 0)
00093 theFile<< "\t" << initials << endln;
00094 else
00095 theFile << "\t" << "ANOTHER\n";
00096
00097
00098 if (spec != 0)
00099 theFile << "SPEC\t" << spec << endln;
00100
00101
00102 if (currency != 0)
00103 theFile << "CURRENCY\t" << currency << endln;
00104
00105
00106 if (length != 0)
00107 theFile << "UNIT_DATA\tLENGTH\t" << length << endln;
00108
00109
00110 if (force != 0)
00111 theFile << "UNIT_DATA\tFORCE\t" << force << endln;
00112
00113
00114 if (temp != 0)
00115 theFile << "UNIT_DATA\tTEMP\t" << temp << endln;
00116
00117
00118
00119 NodeIter &theNodes = theDomain->getNodes();
00120 Node *theNode;
00121 while ((theNode=theNodes()) != 0) {
00122 int nodeTag = theNode->getTag();
00123 theFile << "NODE\t" << nodeTag;
00124 const Vector &crds = theNode->getCrds();
00125 if (crds.Size() != ndm) {
00126 opserr << "WARNING - GSA_Recorder::GSA_Recorder() - node: " << nodeTag ;
00127 opserr << " has invalid number of coordinates, expecting: " << ndm << " got: " << crds.Size() << endln;
00128 exit(-1);
00129 }
00130 const Vector &disp = theNode->getTrialDisp();
00131 if (disp.Size() != ndf) {
00132 opserr << "WARNING - GSA_Recorder::GSA_Recorder() - node: " << nodeTag ;
00133 opserr << " has invalid number of dof, expecting: " << ndf << " got: " << disp.Size() << endln;
00134 exit(-1);
00135 }
00136 for (int i=0; i<ndm; i++)
00137 theFile << "\t" << crds(i);
00138 theFile << endln;
00139 }
00140
00141
00142
00143 SP_ConstraintIter &theSPs = theDomain->getSPs();
00144 SP_Constraint *theSP;
00145 ID theConstrainedNodes(0,6);
00146 ID theSpMatrix(0, 6*ndf);
00147 int numNodesWithSP = 0;
00148 while ((theSP=theSPs()) != 0) {
00149 int nodeTag = theSP->getNodeTag();
00150 int location = theConstrainedNodes.getLocation(nodeTag);
00151 if (location < 0) {
00152 theConstrainedNodes[numNodesWithSP] = nodeTag;
00153 for (int i=0; i<ndf; i++)
00154 theSpMatrix[numNodesWithSP*ndf+i] = 0;
00155 location = numNodesWithSP++;
00156 }
00157 int id = theSP->getDOF_Number();
00158 theSpMatrix[location*ndf + id] = 1;
00159 }
00160
00161 for (int j=0; j<numNodesWithSP; j++) {
00162 theFile << "SPC\t" << theConstrainedNodes[j] << "\t0";
00163 for (int i=0; i<ndf; i++)
00164 theFile << "\t" << theSpMatrix[j*ndf+i];
00165 theFile << endln;
00166 }
00167
00168 ElementIter &theElements = theDomain->getElements();
00169 Element *theElement;
00170 while ((theElement=theElements()) != 0) {
00171 theElement->Print(theFile, -1);
00172 }
00173
00174 }
00175
00176 GSA_Recorder::~GSA_Recorder()
00177 {
00178 theFile << "END\n";
00179 theFile.close();
00180 }
00181
00182 int
00183 GSA_Recorder::record(int commitTag, double timeStamp)
00184 {
00185
00186 if (deltaT == 0.0 || timeStamp >= nextTimeStampToRecord) {
00187
00188 if (deltaT != 0.0)
00189 nextTimeStampToRecord = timeStamp + deltaT;
00190
00191 counter++;
00192
00193 theFile << "ANAL_CASE\t" << counter << "\tStep" << counter << "\tL" << counter <<
00194 "\tGSS\tSTATIC\tPOST\t" << counter << "\topensees\t" << "20030204165318 0" << endln;
00195
00196 theFile << "!\n!RESULTS FOR ANALYSIS CASE\t" << counter << "\n!\n";
00197
00198
00199 NodeIter &theNodes = theDomain->getNodes();
00200 Node *theNode;
00201 while ((theNode=theNodes()) != 0) {
00202 int nodeTag = theNode->getTag();
00203 const Vector &disp = theNode->getTrialDisp();
00204 if (ndm == 3 && ndf == 6) {
00205 theFile << "DISP\t" << nodeTag << "\t" << counter;
00206 for (int i=0; i<ndm; i++)
00207 theFile << "\t" << disp(i);
00208 theFile << endln;
00209 theFile << "ROTN\t" << nodeTag << "\t" << counter;
00210 for (int j=0; j<ndm; j++)
00211 theFile << "\t" << disp(ndm+j);
00212 theFile << endln;
00213 }
00214 }
00215
00216 ElementIter &theElements = theDomain->getElements();
00217 Element *theElement;
00218 while ((theElement=theElements()) != 0) {
00219 theElement->Print(theFile, (counter+1)*-1);
00220
00221 }
00222 }
00223
00224 return 0;
00225 }
00226
00227 int
00228 GSA_Recorder::playback(int commitTag)
00229 {
00230
00231 return 0;
00232 }
00233
00234 int
00235 GSA_Recorder::restart(void)
00236 {
00237 return 0;
00238 }
00239
00240
00241
00242
00243