int EnvelopeNodeRecorder::initialize(void) { if (theDofs == 0 || theDomain == 0) { opserr << "EnvelopeNodeRecorder::initialize() - either nodes, dofs or domain has not been set\n"; return -1; } // // create & set nodal array pointer // if (theNodes != 0) delete [] theNodes; numValidNodes = 0; if (theNodalTags != 0) { int numNode = theNodalTags->Size(); theNodes = new Node *[numNode]; if (theNodes == 0) { opserr << "EnvelopeNodeRecorder::domainChanged - out of memory\n"; return -1; } for (int i=0; i<numNode; i++) { int nodeTag = (*theNodalTags)(i); Node *theNode = theDomain->getNode(nodeTag); if (theNode != 0) { theNodes[numValidNodes] = theNode; numValidNodes++; } } } else { int numNodes = theDomain->getNumNodes(); if (numNodes != 0) { theNodes = new Node *[numNodes]; if (theNodes == 0) { opserr << "NodeRecorder::domainChanged - out of memory\n"; return -1; } NodeIter &theDomainNodes = theDomain->getNodes(); Node *theNode; numValidNodes = 0; while (((theNode = theDomainNodes()) != 0) && (numValidNodes < numNodes)) { theNodes[numValidNodes] = theNode; numValidNodes++; } } else numValidNodes = 0; } // // need to create the data description, i.e. what each column of data is // // // need to create the data description, i.e. what each column of data is // char outputData[32]; char dataType[10]; if (dataFlag == 0) { strcpy(dataType,"D"); } else if (dataFlag == 1) { strcpy(dataType,"V"); } else if (dataFlag == 2) { strcpy(dataType,"A"); } else if (dataFlag == 3) { strcpy(dataType,"dD"); } else if (dataFlag == 4) { strcpy(dataType,"ddD"); } else if (dataFlag == 5) { strcpy(dataType,"U"); } else if (dataFlag == 6) { strcpy(dataType,"U"); } else if (dataFlag == 7) { strcpy(dataType,"R"); } else if (dataFlag == 8) { strcpy(dataType,"R"); } else if (dataFlag > 10) { sprintf(dataType,"E%d", dataFlag-10); } else strcpy(dataType,"Unknown"); // // resize the output matrix // int numDOF = theDofs->Size(); int numValidResponse = numValidNodes*numDOF; if (echoTimeFlag == true) { numValidResponse *= 2; } currentData = new Vector(numValidResponse); data = new Matrix(3, numValidResponse); data->Zero(); ID dataOrder(numValidResponse); ID xmlOrder(numValidNodes); if (theNodalTags != 0 && addColumnInfo == 1) { int count = 0; int nodeCount = 0; int numNode = theNodalTags->Size(); for (int i=0; i<numNode; i++) { int nodeTag = (*theNodalTags)(i); Node *theNode = theDomain->getNode(nodeTag); if (theNode != 0) { xmlOrder(nodeCount++) = i+1; for (int j=0; j<numDOF; j++) dataOrder(count++) = i+1; if (echoTimeFlag == true) { for (int j=0; j<numDOF; j++) dataOrder(count++) = i+1; } } } theHandler->setOrder(xmlOrder); } for (int i=0; i<numValidNodes; i++) { int nodeTag = theNodes[i]->getTag(); theHandler->tag("NodeOutput"); theHandler->attr("nodeTag", nodeTag); for (int j=0; j<theDofs->Size(); j++) { if (echoTimeFlag == true) { theHandler->tag("TimeOutput"); theHandler->tag("ResponseType", "time"); theHandler->endTag(); } sprintf(outputData, "%s%d", dataType, j+1); theHandler->tag("ResponseType",outputData); } theHandler->endTag(); } if (theNodalTags != 0 && addColumnInfo == 1) { theHandler->setOrder(dataOrder); } initializationDone = true; return 0; }
int NodeRecorder::initialize(void) { if (theDofs == 0 || theDomain == 0) { opserr << "NodeRecorder::initialize() - either nodes, dofs or domain has not been set\n"; return -1; } // // create & set nodal array pointer // if (theNodes != 0) delete [] theNodes; numValidNodes = 0; if (theNodalTags != 0) { int numNode = theNodalTags->Size(); theNodes = new Node *[numNode]; if (theNodes == 0) { opserr << "NodeRecorder::domainChanged - out of memory\n"; return -1; } for (int i=0; i<numNode; i++) { int nodeTag = (*theNodalTags)(i); Node *theNode = theDomain->getNode(nodeTag); if (theNode != 0) { theNodes[numValidNodes] = theNode; numValidNodes++; } } } else { int numNodes = theDomain->getNumNodes(); theNodes = new Node *[numNodes]; if (theNodes == 0) { opserr << "NodeRecorder::domainChanged - out of memory\n"; return -1; } NodeIter &theDomainNodes = theDomain->getNodes(); Node *theNode; numValidNodes = 0; while (((theNode = theDomainNodes()) != 0) && (numValidNodes < numNodes)) { theNodes[numValidNodes] = theNode; numValidNodes++; } } // // resize the response vector // int timeOffset = 0; if (echoTimeFlag == true) timeOffset = 1; int numValidResponse = numValidNodes*theDofs->Size() + timeOffset; if (dataFlag == 10000) numValidResponse = numValidNodes + timeOffset; response.resize(numValidResponse); response.Zero(); ID orderResponse(numValidResponse); // // need to create the data description, i.e. what each column of data is // char outputData[32]; char dataType[10]; if (dataFlag == 0) { strcpy(dataType,"D"); } else if (dataFlag == 1) { strcpy(dataType,"V"); } else if (dataFlag == 2) { strcpy(dataType,"A"); } else if (dataFlag == 3) { strcpy(dataType,"dD"); } else if (dataFlag == 4) { strcpy(dataType,"ddD"); } else if (dataFlag == 5) { strcpy(dataType,"U"); } else if (dataFlag == 6) { strcpy(dataType,"U"); } else if (dataFlag == 7) { strcpy(dataType,"R"); } else if (dataFlag == 8) { strcpy(dataType,"R"); } else if (dataFlag == 10000) { strcpy(dataType,"|D|"); } else if (dataFlag > 10) { sprintf(dataType,"E%d", dataFlag-10); } else strcpy(dataType,"Unknown"); /************************************************************ } else if ((strncmp(dataToStore, "sensitivity",11) == 0)) { int grad = atoi(&(dataToStore[11])); if (grad > 0) dataFlag = 1000 + grad; else dataFlag = 6; } else if ((strncmp(dataToStore, "velSensitivity",14) == 0)) { int grad = atoi(&(dataToStore[14])); if (grad > 0) dataFlag = 2000 + grad; else dataFlag = 6; } else if ((strncmp(dataToStore, "accSensitivity",14) == 0)) { int grad = atoi(&(dataToStore[14])); if (grad > 0) dataFlag = 3000 + grad; else dataFlag = 6; ***********************************************************/ int numDOF = theDofs->Size(); // write out info to handler if parallel execution // ID xmlOrder(numValidNodes); if (echoTimeFlag == true) xmlOrder.resize(numValidNodes+1); if (theNodalTags != 0 && addColumnInfo == 1) { int numNode = theNodalTags->Size(); int count = 0; int nodeCount = 0; if (echoTimeFlag == true) { orderResponse(count++) = 0; xmlOrder(nodeCount++) = 0; } for (int i=0; i<numNode; i++) { int nodeTag = (*theNodalTags)(i); Node *theNode = theDomain->getNode(nodeTag); if (theNode != 0) { xmlOrder(nodeCount++) = i+1; for (int j=0; j<numDOF; j++) orderResponse(count++) = i+1; } } theOutputHandler->setOrder(xmlOrder); } char nodeCrdData[20]; sprintf(nodeCrdData,"coord"); if (echoTimeFlag == true) { if (theNodalTags != 0 && addColumnInfo == 1) { theOutputHandler->tag("TimeOutput"); theOutputHandler->tag("ResponseType", "time"); theOutputHandler->endTag(); } } for (int i=0; i<numValidNodes; i++) { int nodeTag = theNodes[i]->getTag(); const Vector &nodeCrd = theNodes[i]->getCrds(); int numCoord = nodeCrd.Size(); theOutputHandler->tag("NodeOutput"); theOutputHandler->attr("nodeTag", nodeTag); for (int j=0; j<3; j++) { sprintf(nodeCrdData,"coord%d",j+1); if (j < numCoord) theOutputHandler->attr(nodeCrdData, nodeCrd(j)); else theOutputHandler->attr(nodeCrdData, 0.0); } for (int k=0; k<theDofs->Size(); k++) { sprintf(outputData, "%s%d", dataType, k+1); theOutputHandler->tag("ResponseType",outputData); } theOutputHandler->endTag(); } if (theNodalTags != 0 && addColumnInfo == 1) { theOutputHandler->setOrder(orderResponse); } theOutputHandler->tag("Data"); initializationDone = true; return 0; }