Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

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.1.1.1 $
00022 // $Date: 2000/09/15 08:23:16 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/analysis/fe_ele/lagrange/LagrangeSP_FE.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/analysis/fe_ele/lagrange/LagrangeSP_FE.C
00027 //
00028 // Written: fmk 
00029 // Created: 02/99
00030 // Revision: A
00031 //
00032 // Purpose: This file contains the code for iSPlementing the methods
00033 // of the LagrangeSP_FE class interface.
00034 //
00035 // the interface:
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     // create a Matrix and a Vector for the tangent and residual
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     // zero the Matrix and Vector
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     // set the tangent
00080     (*tang)(0,1) = alpha;
00081     (*tang)(1,0) = alpha;
00082     
00083     // set the myDOF_Groups tags indicating the attached id's of the
00084     // DOF_Group objects
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 // void setID(int index, int value);
00105 // Method to set the correSPonding index of the ID to value.
00106 int
00107 LagrangeSP_FE::setID(void)
00108 {
00109     int result = 0;
00110 
00111     // first determine the IDs in myID for those DOFs marked
00112     // as constrained DOFs, this is obtained from the DOF_Group
00113     // associated with the constrained node
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 //    cerr << "LagrangeSP_FE::getResidual() " << constraint << " " << nodeDisp(constrainedDOF) << " " << constrainedDOF << nodeDisp;
00157 //    cerr << "LagrangeSP_FE::getResidual() " << *resid << this->getID();    
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 
Copyright Contact Us