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