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 <PlainHandler.h>
00034 #include <stdlib.h>
00035
00036 #include <AnalysisModel.h>
00037 #include <Domain.h>
00038 #include <FE_Element.h>
00039 #include <DOF_Group.h>
00040 #include <Node.h>
00041 #include <Element.h>
00042 #include <NodeIter.h>
00043 #include <ElementIter.h>
00044 #include <SP_ConstraintIter.h>
00045 #include <SP_Constraint.h>
00046 #include <MP_ConstraintIter.h>
00047 #include <MP_Constraint.h>
00048 #include <Integrator.h>
00049 #include <ID.h>
00050 #include <Subdomain.h>
00051 #include <Channel.h>
00052 #include <FEM_ObjectBroker.h>
00053
00054 PlainHandler::PlainHandler()
00055 :ConstraintHandler(HANDLER_TAG_PlainHandler)
00056 {
00057
00058 }
00059
00060 PlainHandler::~PlainHandler()
00061 {
00062
00063 }
00064
00065 int
00066 PlainHandler::handle(const ID *nodesLast)
00067 {
00068
00069 Domain *theDomain = this->getDomainPtr();
00070 AnalysisModel *theModel = this->getAnalysisModelPtr();
00071 Integrator *theIntegrator = this->getIntegratorPtr();
00072
00073 if ((theDomain == 0) || (theModel == 0) || (theIntegrator == 0)) {
00074 opserr << "WARNING PlainHandler::handle() - ";
00075 opserr << " setLinks() has not been called\n";
00076 return -1;
00077 }
00078
00079
00080
00081
00082 NodeIter &theNod = theDomain->getNodes();
00083 Node *nodPtr;
00084 SP_Constraint *spPtr;
00085 DOF_Group *dofPtr;
00086
00087 int numDOF = 0;
00088 int count3 = 0;
00089 int countDOF =0;
00090 while ((nodPtr = theNod()) != 0) {
00091 if ((dofPtr = new DOF_Group(numDOF++, nodPtr)) == 0) {
00092 opserr << "WARNING PlainHandler::handle() - ran out of memory";
00093 opserr << " creating DOF_Group " << numDOF << endln;
00094 return -4;
00095 }
00096
00097 const ID &id = dofPtr->getID();
00098 for (int j=0; j < id.Size(); j++) {
00099 dofPtr->setID(j,-2);
00100 countDOF++;
00101 }
00102
00103
00104 int nodeID = nodPtr->getTag();
00105 SP_ConstraintIter &theSPs = theDomain->getDomainAndLoadPatternSPs();
00106 while ((spPtr = theSPs()) != 0)
00107 if (spPtr->getNodeTag() == nodeID) {
00108 if (spPtr->isHomogeneous() == false) {
00109 opserr << "WARNING PlainHandler::handle() - ";
00110 opserr << " non-homogeneos constraint";
00111 opserr << " for node " << spPtr->getNodeTag();
00112 opserr << " homo assumed\n";
00113 }
00114 const ID &id = dofPtr->getID();
00115 int dof = spPtr->getDOF_Number();
00116 if (id(dof) == -2) {
00117 dofPtr->setID(spPtr->getDOF_Number(),-1);
00118 countDOF--;
00119 } else {
00120 opserr << "WARNING PlainHandler::handle() - ";
00121 opserr << " multiple single pointconstraints at DOF " << dof;
00122 opserr << " for node " << spPtr->getNodeTag() << endln;
00123 }
00124 }
00125
00126
00127
00128
00129 MP_ConstraintIter &theMPs = theDomain->getMPs();
00130 MP_Constraint *mpPtr;
00131 while ((mpPtr = theMPs()) != 0)
00132 if (mpPtr->getNodeConstrained() == nodeID) {
00133 if (mpPtr->isTimeVarying() == true) {
00134 opserr << "WARNING PlainHandler::handle() - ";
00135 opserr << " time-varying constraint";
00136 opserr << " for node " << nodeID;
00137 opserr << " non-varyng assumed\n";
00138 }
00139 const Matrix &C = mpPtr->getConstraint();
00140 int numRows = C.noRows();
00141 int numCols = C.noCols();
00142 if (numRows != numCols) {
00143 opserr << "WARNING PlainHandler::handle() - ";
00144 opserr << " constraint matrix not diagonal, ignoring constraint";
00145 opserr << " for node " << nodeID << endln;
00146 opserr << " non-varyng assumed\n";
00147 } else {
00148 int ok = 0;
00149 for (int i=0; i<numRows; i++) {
00150 if (C(i,i) != 1.0) ok = 1;
00151 for (int j=0; j<numRows; j++)
00152 if (i != j)
00153 if (C(i,j) != 0.0)
00154 ok = 1;
00155 }
00156 if (ok != 0) {
00157 opserr << "WARNING PlainHandler::handle() - ";
00158 opserr << " constraint matrix not identity, ignoring constraint";
00159 opserr << " for node " << nodeID << endln;
00160 opserr << " non-varyng assumed\n";
00161 } else {
00162 const ID &dofs = mpPtr->getConstrainedDOFs();
00163 const ID &id = dofPtr->getID();
00164 for (int i=0; i<dofs.Size(); i++) {
00165 int dof = dofs(i);
00166 if (id(dof) == -2) {
00167 dofPtr->setID(dof,-4);
00168 countDOF--;
00169 } else {
00170 opserr << "WARNING PlainHandler::handle() - ";
00171 opserr << " constraint at dof " << dof << " already specified for constrained node";
00172 opserr << " in MP_Constraint at node " << nodeID << endln;
00173 }
00174
00175 }
00176 }
00177 }
00178 }
00179
00180 nodPtr->setDOF_GroupPtr(dofPtr);
00181 theModel->addDOF_Group(dofPtr);
00182 }
00183
00184
00185 theModel->setNumEqn(countDOF);
00186
00187
00188
00189 if (nodesLast != 0)
00190 for (int i=0; i<nodesLast->Size(); i++) {
00191 int nodeID = (*nodesLast)(i);
00192 Node *nodPtr = theDomain->getNode(nodeID);
00193 if (nodPtr != 0) {
00194 dofPtr = nodPtr->getDOF_GroupPtr();
00195
00196 const ID &id = dofPtr->getID();
00197
00198 for (int j=0; j < id.Size(); j++)
00199 if (id(j) == -2) {
00200 dofPtr->setID(j,-3);
00201 count3++;
00202 } else {
00203 opserr << "WARNING PlainHandler::handle() ";
00204 opserr << " - boundary sp constraint in subdomain";
00205 opserr << " this should not be - results suspect \n";
00206 }
00207 }
00208 }
00209
00210
00211 ElementIter &theEle = theDomain->getElements();
00212 Element *elePtr;
00213
00214 int numFe = 0;
00215 FE_Element *fePtr;
00216 while ((elePtr = theEle()) != 0) {
00217
00218
00219
00220
00221 if (elePtr->isSubdomain() == true) {
00222
00223 Subdomain *theSub = (Subdomain *)elePtr;
00224 if (theSub->doesIndependentAnalysis() == false) {
00225
00226 if ((fePtr = new FE_Element(numFe++, elePtr)) == 0) {
00227 opserr << "WARNING PlainHandler::handle() - ran out of memory";
00228 opserr << " creating FE_Element " << elePtr->getTag() << endln;
00229 return -5;
00230 }
00231
00232 theModel->addFE_Element(fePtr);
00233 theSub->setFE_ElementPtr(fePtr);
00234
00235 }
00236
00237 } else {
00238
00239
00240 if ((fePtr = new FE_Element(numFe++, elePtr)) == 0) {
00241 opserr << "WARNING PlainHandler::handle() - ran out of memory";
00242 opserr << " creating FE_Element " << elePtr->getTag() << endln;
00243 return -5;
00244 }
00245
00246 theModel->addFE_Element(fePtr);
00247 }
00248 }
00249 return count3;
00250 }
00251
00252
00253 void
00254 PlainHandler::clearAll(void)
00255 {
00256
00257 Domain *theDomain = this->getDomainPtr();
00258 if (theDomain == 0)
00259 return;
00260
00261 NodeIter &theNod = theDomain->getNodes();
00262 Node *nodPtr;
00263 while ((nodPtr = theNod()) != 0)
00264 nodPtr->setDOF_GroupPtr(0);
00265 }
00266
00267 int
00268 PlainHandler::sendSelf(int cTag,
00269 Channel &theChannel)
00270 {
00271 return 0;
00272 }
00273
00274 int
00275 PlainHandler::recvSelf(int cTag,
00276 Channel &theChannel,
00277 FEM_ObjectBroker &theBroker)
00278 {
00279 return 0;
00280 }