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 <LagrangeSP_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 LagrangeSP_FE::LagrangeSP_FE(Domain &theDomain, SP_Constraint &TheSP,
00054 DOF_Group &theGroup, double Alpha)
00055 :FE_Element(2,2),
00056 alpha(Alpha), tang(0), resid(0), theSP(&TheSP), theDofGroup(&theGroup)
00057 {
00058
00059 tang = new Matrix(2,2);
00060 resid = new Vector(2);
00061 if ((tang == 0) || (tang->noCols() == 0) || (resid == 0) ||
00062 (resid->Size() == 0)) {
00063 cerr << "WARNING LagrangeSP_FE::LagrangeSP_FE()";
00064 cerr << "- ran out of memory\n";
00065 exit(-1);
00066 }
00067
00068
00069 resid->Zero();
00070 tang->Zero();
00071
00072 theNode = theDomain.getNode(theSP->getNodeTag());
00073 if (theNode == 0) {
00074 cerr << "WARNING LagrangeSP_FE::LagrangeSP_FE()";
00075 cerr << "- no asscoiated Node\n";
00076 exit(-1);
00077 }
00078
00079
00080 (*tang)(0,1) = alpha;
00081 (*tang)(1,0) = alpha;
00082
00083
00084
00085 DOF_Group *theNodesDOFs = theNode->getDOF_GroupPtr();
00086 if (theNodesDOFs == 0) {
00087 cerr << "WARNING LagrangeSP_FE::LagrangeSP_FE()";
00088 cerr << " - no DOF_Group with Constrained Node\n";
00089 exit(-1);
00090 }
00091
00092 myDOF_Groups(0) = theNodesDOFs->getTag();
00093 myDOF_Groups(1) = theDofGroup->getTag();
00094 }
00095
00096 LagrangeSP_FE::~LagrangeSP_FE()
00097 {
00098 if (tang != 0)
00099 delete tang;
00100 if (resid != 0)
00101 delete resid;
00102 }
00103
00104
00105
00106 int
00107 LagrangeSP_FE::setID(void)
00108 {
00109 int result = 0;
00110
00111
00112
00113
00114 DOF_Group *theNodesDOFs = theNode->getDOF_GroupPtr();
00115 if (theNodesDOFs == 0) {
00116 cerr << "WARNING LagrangeSP_FE::setID(void)";
00117 cerr << " - no DOF_Group with Constrained Node\n";
00118 return -1;
00119 }
00120
00121 int restrainedDOF = theSP->getDOF_Number();
00122 const ID &theNodesID = theNodesDOFs->getID();
00123
00124 if (restrainedDOF < 0 || restrainedDOF >= theNodesID.Size()) {
00125 cerr << "WARNING LagrangeSP_FE::setID(void)";
00126 cerr << " - restrained DOF invalid\n";
00127 return -2;
00128 }
00129
00130 myID(0) = theNodesID(restrainedDOF);
00131 myID(1) = (theDofGroup->getID())(0);
00132
00133 return result;
00134 }
00135
00136 const Matrix &
00137 LagrangeSP_FE::getTangent(Integrator *theIntegrator)
00138 {
00139 return *tang;
00140 }
00141
00142 const Vector &
00143 LagrangeSP_FE::getResidual(Integrator *theNewIntegrator)
00144 {
00145 double constraint = theSP->getValue();
00146 int constrainedDOF = theSP->getDOF_Number();
00147 const Vector &nodeDisp = theNode->getTrialDisp();
00148
00149 if (constrainedDOF < 0 || constrainedDOF >= nodeDisp.Size()) {
00150 cerr << "LagrangeSP_FE::formResidual() -";
00151 cerr << " constrained DOF " << constrainedDOF << " ouside range\n";
00152 (*resid)(1) = 0;
00153 }
00154
00155 (*resid)(1) = alpha *(constraint - nodeDisp(constrainedDOF));
00156
00157
00158 return *resid;
00159 }
00160
00161
00162
00163
00164 const Vector &
00165 LagrangeSP_FE::getTangForce(const Vector &disp, double fact)
00166 {
00167 double constraint = theSP->getValue();
00168 int constrainedID = myID(1);
00169 if (constrainedID < 0 || constrainedID >= disp.Size()) {
00170 cerr << "WARNING LagrangeSP_FE::getTangForce() - ";
00171 cerr << " constrained DOF " << constrainedID << " outside disp\n";
00172 (*resid)(1) = constraint*alpha;
00173 return *resid;
00174 }
00175 (*resid)(1) = alpha * (constraint - disp(constrainedID));
00176 return *resid;
00177 }
00178
00179