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
00034
00035
00036
00037 #include <PenaltySP_FE.h>
00038 #include <stdlib.h>
00039
00040 #include <Element.h>
00041 #include <Domain.h>
00042 #include <Node.h>
00043 #include <DOF_Group.h>
00044 #include <Integrator.h>
00045 #include <Subdomain.h>
00046 #include <AnalysisModel.h>
00047 #include <Matrix.h>
00048 #include <Vector.h>
00049 #include <Node.h>
00050 #include <SP_Constraint.h>
00051 #include <DOF_Group.h>
00052
00053 PenaltySP_FE::PenaltySP_FE(int tag, Domain &theDomain,
00054 SP_Constraint &TheSP, double Alpha)
00055 :FE_Element(tag, 1,1), alpha(Alpha),
00056 theSP(&TheSP), theNode(0), tang(0), resid(0)
00057 {
00058
00059 tang = new Matrix(1,1);
00060 resid = new Vector(1);
00061 if (tang == 0 || resid == 0 || tang->noCols() == 0 || resid->Size() == 0) {
00062 opserr << "FATAL PenaltySP_FE::PenaltySP_FE() - ran out of memory\n";
00063 exit(-1);
00064 }
00065
00066
00067 theNode = theDomain.getNode(theSP->getNodeTag());
00068 if (theNode == 0) {
00069 opserr << "FATAL PenaltySP_FE::PenaltySP_FE() - no Node: ";
00070 opserr << theSP->getNodeTag() << "in domain\n";
00071 exit(-1);
00072 }
00073
00074
00075 DOF_Group *dofGrpPtr = theNode->getDOF_GroupPtr();
00076 if (dofGrpPtr != 0)
00077 myDOF_Groups(0) = dofGrpPtr->getTag();
00078
00079
00080 (*tang)(0,0) = alpha;
00081
00082
00083 }
00084
00085
00086 PenaltySP_FE::~PenaltySP_FE()
00087 {
00088 if (tang != 0) delete tang;
00089 if (resid != 0) delete resid;
00090 }
00091
00092
00093
00094
00095 int
00096 PenaltySP_FE::setID(void)
00097 {
00098 DOF_Group *theNodesDOFs = theNode->getDOF_GroupPtr();
00099 if (theNodesDOFs == 0) {
00100 opserr << "WARNING PenaltySP_FE::setID(void) - no DOF_Group with Node\n";
00101 return -2;
00102 }
00103 myDOF_Groups(0) = theNodesDOFs->getTag();
00104
00105 int restrainedDOF = theSP->getDOF_Number();
00106 if (restrainedDOF < 0 || restrainedDOF >= theNode->getNumberDOF()) {
00107 opserr << "WARNING PenaltySP_FE::setID(void) - unknown DOF ";
00108 opserr << restrainedDOF << " at Node\n";
00109 return -3;
00110 }
00111 const ID &theNodesID = theNodesDOFs->getID();
00112 if (restrainedDOF >= theNodesID.Size()) {
00113 opserr << "WARNING PenaltySP_FE::setID(void) - ";
00114 opserr << " Nodes DOF_Group too small\n";
00115 return -4;
00116 }
00117
00118 myID(0) = theNodesID(restrainedDOF);
00119
00120 return 0;
00121 }
00122
00123
00124 const Matrix &
00125 PenaltySP_FE::getTangent(Integrator *theNewIntegrator)
00126 {
00127 return *tang;
00128 }
00129
00130
00131 const Vector &
00132 PenaltySP_FE::getResidual(Integrator *theNewIntegrator)
00133 {
00134 double constraint = theSP->getValue();
00135 int constrainedDOF = theSP->getDOF_Number();
00136 const Vector &nodeDisp = theNode->getTrialDisp();
00137
00138 if (constrainedDOF < 0 || constrainedDOF >= nodeDisp.Size()) {
00139 opserr << "WARNING PenaltySP_FE::getTangForce() - ";
00140 opserr << " constrained DOF " << constrainedDOF << " outside disp\n";
00141 (*resid)(0) = 0;
00142 }
00143
00144
00145
00146
00147
00148 (*resid)(0) = alpha * (constraint - nodeDisp(constrainedDOF));
00149
00150 return *resid;
00151 }
00152
00153
00154 const Vector &
00155 PenaltySP_FE::getTangForce(const Vector &disp, double fact)
00156 {
00157 double constraint = theSP->getValue();
00158 int constrainedID = myID(0);
00159 if (constrainedID < 0 || constrainedID >= disp.Size()) {
00160 opserr << "WARNING PenaltySP_FE::getTangForce() - ";
00161 opserr << " constrained DOF " << constrainedID << " outside disp\n";
00162 (*resid)(0) = 0.0;
00163 return *resid;
00164 }
00165 (*resid)(0) = alpha * disp(constrainedID);
00166
00167 return *resid;
00168 }
00169
00170 const Vector &
00171 PenaltySP_FE::getK_Force(const Vector &disp, double fact)
00172 {
00173 opserr << "WARNING PenaltySP_FE::getK_Force() - not yet implemented\n";
00174 (*resid)(0) = 0.0;
00175 return *resid;
00176 }
00177
00178 const Vector &
00179 PenaltySP_FE::getKi_Force(const Vector &disp, double fact)
00180 {
00181 opserr << "WARNING PenaltySP_FE::getKi_Force() - not yet implemented\n";
00182 (*resid)(0) = 0.0;
00183 return *resid;
00184 }
00185
00186
00187 const Vector &
00188 PenaltySP_FE::getC_Force(const Vector &disp, double fact)
00189 {
00190 opserr << "WARNING PenaltySP_FE::getC_Force() - not yet implemented\n";
00191 (*resid)(0) = 0.0;
00192 return *resid;
00193 }
00194
00195 const Vector &
00196 PenaltySP_FE::getM_Force(const Vector &disp, double fact)
00197 {
00198 opserr << "WARNING PenaltySP_FE::getM_Force() - not yet implemented\n";
00199 (*resid)(0) = 0.0;
00200 return *resid;
00201 }
00202
00203
00204
00205