PenaltySP_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.6 $
00022 // $Date: 2006/02/08 20:20:00 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/fe_ele/penalty/PenaltySP_FE.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/analysis/fe_ele/penalty/PenaltySP_FE.C
00027 //
00028 // Written: fmk 
00029 // Created: 11/96
00030 // Revision: A
00031 //
00032 // Purpose: This file contains the code for implementing the methods
00033 // of the PenaltySP_FE class interface.
00034 //
00035 // the interface:
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     // create a matrix and a vector for tangent and residual
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     // get a pointer to the Node
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     // set the DOF_Group tags
00075     DOF_Group *dofGrpPtr = theNode->getDOF_GroupPtr();
00076     if (dofGrpPtr != 0) 
00077         myDOF_Groups(0) = dofGrpPtr->getTag();      
00078     
00079     // set the tangent
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 // void setID(int index, int value);
00093 //      Method to set the corresponding index of the ID to value.
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     //    (*resid)(0) = alpha * (constraint - nodeDisp(constrainedDOF));    
00145     // is replace with the following to remove possible problems with
00146     // subtracting very small numbers
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 

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