LagrangeSP_FE.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.5 $
00022 // $Date: 2006/02/08 20:20:00 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/fe_ele/lagrange/LagrangeSP_FE.cpp,v $
00024                                                                         
00025 // Written: fmk 
00026 // Created: 02/99
00027 // Revision: A
00028 //
00029 // Purpose: This file contains the code for iSPlementing the methods
00030 // of the LagrangeSP_FE class interface.
00031 //
00032 // the interface:
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     // create a Matrix and a Vector for the tangent and residual
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     // zero the Matrix and Vector
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     // set the tangent
00077     (*tang)(0,1) = alpha;
00078     (*tang)(1,0) = alpha;
00079     
00080     // set the myDOF_Groups tags indicating the attached id's of the
00081     // DOF_Group objects
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 // void setID(int index, int value);
00102 //      Method to set the correSPonding index of the ID to value.
00103 int
00104 LagrangeSP_FE::setID(void)
00105 {
00106     int result = 0;
00107 
00108     // first determine the IDs in myID for those DOFs marked
00109     // as constrained DOFs, this is obtained from the DOF_Group
00110     // associated with the constrained node
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 //    opserr << "LagrangeSP_FE::getResidual() " << constraint << " " << nodeDisp(constrainedDOF) << " " << constrainedDOF << nodeDisp;
00154 //    opserr << "LagrangeSP_FE::getResidual() " << *resid << this->getID();    
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 

Generated on Mon Oct 23 15:04:57 2006 for OpenSees by doxygen 1.5.0