LagrangeMP_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/LagrangeMP_FE.cpp,v $
00024                                                                         
00025                                                                         
00026 // Written: fmk 
00027 // Created: 02/99
00028 // Revision: A
00029 //
00030 // Purpose: This file contains the code for implementing the methods
00031 // of the LagrangeMP_FE class interface.
00032 
00033 #include <LagrangeMP_FE.h>
00034 #include <stdlib.h>
00035 
00036 #include <Element.h>
00037 #include <Domain.h>
00038 #include <Node.h>
00039 #include <DOF_Group.h>
00040 #include <Integrator.h>
00041 #include <Subdomain.h>
00042 #include <AnalysisModel.h>
00043 #include <Matrix.h>
00044 #include <Vector.h>
00045 #include <Node.h>
00046 #include <MP_Constraint.h>
00047 #include <DOF_Group.h>
00048 
00049 LagrangeMP_FE::LagrangeMP_FE(int tag, Domain &theDomain, MP_Constraint &TheMP,
00050                              DOF_Group &theGroup, double Alpha)
00051 :FE_Element(tag, 3,(tag, TheMP.getConstrainedDOFs()).Size()+
00052               (TheMP.getRetainedDOFs()).Size() + 
00053               (TheMP.getRetainedDOFs()).Size()),
00054  alpha(Alpha), theMP(&TheMP), 
00055  theConstrainedNode(0), theRetainedNode(0),
00056  theDofGroup(&theGroup), tang(0), resid(0)
00057 {
00058     const Matrix &constraint = theMP->getConstraint();
00059     int noRows = constraint.noRows();
00060     int noCols = constraint.noCols();
00061     int size = 2*noRows+noCols;
00062     
00063     tang = new Matrix(size,size);
00064     resid = new Vector(size);
00065     if (tang == 0 || resid == 0 || tang->noCols() == 0 || resid->Size() == 0) {
00066         opserr << "FATAL LagrangeMP_FE::LagrangeMP_FE() - out of memory\n";
00067         exit(-1);
00068     }
00069     tang->Zero();       
00070     resid->Zero();
00071 
00072     theRetainedNode = theDomain.getNode(theMP->getNodeRetained());    
00073     theConstrainedNode = theDomain.getNode(theMP->getNodeConstrained());
00074 
00075     if (theRetainedNode == 0) {
00076         opserr << "WARNING LagrangeMP_FE::LagrangeMP_FE()";
00077         opserr << "- no asscoiated Retained Node\n";
00078         exit(-1);
00079     }
00080     
00081     if (theConstrainedNode == 0) {
00082         opserr << "WARNING LagrangeMP_FE::LagrangeMP_FE()";
00083         opserr << "- no asscoiated Constrained Node\n";
00084         exit(-1);
00085     }
00086     
00087     if (theMP->isTimeVarying() == false) {
00088         this->determineTangent();
00089     }
00090     
00091     // set the myDOF_Groups tags indicating the attached id's of the
00092     // DOF_Group objects
00093     DOF_Group *theConstrainedNodesDOFs = theConstrainedNode->getDOF_GroupPtr();
00094     if (theConstrainedNodesDOFs == 0) {
00095         opserr << "WARNING LagrangeMP_FE::LagrangeMP_FE()";
00096         opserr << " - no DOF_Group with Constrained Node\n";
00097         exit(-1);       
00098     }    
00099 
00100     DOF_Group *theRetainedNodesDOFs = theRetainedNode->getDOF_GroupPtr();
00101     if (theRetainedNodesDOFs == 0) {
00102         opserr << "WARNING LagrangeMP_FE::LagrangeMP_FE()";
00103         opserr << " - no DOF_Group with Retained Node\n";
00104         exit(-1);       
00105     }            
00106     
00107     myDOF_Groups(0) = theConstrainedNodesDOFs->getTag();
00108     myDOF_Groups(1) = theRetainedNodesDOFs->getTag();
00109     myDOF_Groups(2) = theDofGroup->getTag();
00110 }
00111 
00112 LagrangeMP_FE::~LagrangeMP_FE()
00113 {
00114     if (tang != 0)
00115         delete tang;
00116     if (resid != 0)
00117         delete resid;
00118 }    
00119 
00120 // void setID(int index, int value);
00121 //      Method to set the correMPonding index of the ID to value.
00122 int
00123 LagrangeMP_FE::setID(void)
00124 {
00125     int result = 0;
00126 
00127     // first determine the IDs in myID for those DOFs marked
00128     // as constrained DOFs, this is obtained from the DOF_Group
00129     // associated with the constrained node
00130     if (theConstrainedNode == 0) {
00131         opserr << "WARNING LagrangeMP_FE::setID(void)";
00132         opserr << "- no asscoiated Constrained Node\n";
00133         return -1;
00134     }
00135     DOF_Group *theConstrainedNodesDOFs = theConstrainedNode->getDOF_GroupPtr();
00136     if (theConstrainedNodesDOFs == 0) {
00137         opserr << "WARNING LagrangeMP_FE::setID(void)";
00138         opserr << " - no DOF_Group with Constrained Node\n";
00139         return -2;
00140     }    
00141 
00142     const ID &constrainedDOFs = theMP->getConstrainedDOFs();
00143     const ID &theConstrainedNodesID = theConstrainedNodesDOFs->getID();    
00144     
00145     int size1 = constrainedDOFs.Size();
00146     for (int i=0; i<size1; i++) {
00147         int constrained = constrainedDOFs(i);
00148         if (constrained < 0 || 
00149             constrained >= theConstrainedNode->getNumberDOF()) {
00150             
00151             opserr << "WARNING LagrangeMP_FE::setID(void) - unknown DOF ";
00152             opserr << constrained << " at Node\n";
00153             myID(i) = -1; // modify so nothing will be added to equations
00154             result = -3;
00155         }       
00156         else {
00157             if (constrained >= theConstrainedNodesID.Size()) {
00158                 opserr << "WARNING LagrangeMP_FE::setID(void) - ";
00159                 opserr << " Nodes DOF_Group too small\n";
00160                 myID(i) = -1; // modify so nothing will be added to equations
00161                 result = -4;
00162             }
00163             else
00164                 myID(i) = theConstrainedNodesID(constrained);
00165         }
00166     }
00167     
00168     // now determine the IDs for the retained dof's
00169     if (theRetainedNode == 0) {
00170         opserr << "WARNING LagrangeMP_FE::setID(void)";
00171         opserr << "- no asscoiated Retained Node\n";
00172         return -1;
00173     }
00174     DOF_Group *theRetainedNodesDOFs = theRetainedNode->getDOF_GroupPtr();
00175     if (theRetainedNodesDOFs == 0) {
00176         opserr << "WARNING LagrangeMP_FE::setID(void)";
00177         opserr << " - no DOF_Group with Retained Node\n";
00178         return -2;
00179     }    
00180     
00181     const ID &RetainedDOFs = theMP->getRetainedDOFs();
00182     const ID &theRetainedNodesID = theRetainedNodesDOFs->getID();    
00183 
00184     int size2 = RetainedDOFs.Size();
00185     for (int j=0; j<size2; j++) {
00186         int retained = RetainedDOFs(j);
00187         if (retained < 0 || retained >= theRetainedNode->getNumberDOF()) {
00188             opserr << "WARNING LagrangeMP_FE::setID(void) - unknown DOF ";
00189             opserr << retained << " at Node\n";
00190             myID(j+size1) = -1; // modify so nothing will be added
00191             result = -3;
00192         }       
00193         else {
00194             if (retained >= theRetainedNodesID.Size()) {
00195                 opserr << "WARNING LagrangeMP_FE::setID(void) - ";
00196                 opserr << " Nodes DOF_Group too small\n";
00197                 myID(j+size1) = -1; // modify so nothing will be added 
00198                 result = -4;
00199             }
00200             else
00201                 myID(j+size1) = theRetainedNodesID(retained);
00202         }
00203     }
00204 
00205     // finally set the ID corresponding to the ID's at the LagrangeDOF_Group
00206     const ID &theGroupsID = theDofGroup->getID();
00207     int size3 = theGroupsID.Size();
00208     for (int k=0; k<size3; k++) 
00209         myID(k+size1+size2) = theGroupsID(k);
00210     
00211     
00212     return result;
00213 }
00214 
00215 const Matrix &
00216 LagrangeMP_FE::getTangent(Integrator *theNewIntegrator)
00217 {
00218     if (theMP->isTimeVarying() == true)
00219         this->determineTangent();
00220 
00221     return *tang;
00222 }
00223 
00224 const Vector &
00225 LagrangeMP_FE::getResidual(Integrator *theNewIntegrator)
00226 {
00227     return *resid;
00228 }
00229 
00230 
00231 
00232 const Vector &
00233 LagrangeMP_FE::getTangForce(const Vector &disp, double fact)
00234 {
00235  opserr << "WARNING lagrangeMP_FE::getTangForce() - not yet implemented\n";
00236  return *resid;
00237 }
00238 
00239 
00240 const Vector &
00241 LagrangeMP_FE::getK_Force(const Vector &disp, double fact)
00242 {
00243  opserr << "WARNING lagrangeMP_FE::getK_Force() - not yet implemented\n";
00244  return *resid;
00245 }
00246 
00247 const Vector &
00248 LagrangeMP_FE::getKi_Force(const Vector &disp, double fact)
00249 {
00250  opserr << "WARNING LagrangeMP_FE::getKi_Force() - not yet implemented\n";
00251  return *resid;
00252 }
00253 
00254 const Vector &
00255 LagrangeMP_FE::getC_Force(const Vector &disp, double fact)
00256 {
00257  opserr << "WARNING lagrangeMP_FE::getC_Force() - not yet implemented\n";
00258  return *resid;
00259 }
00260 
00261 const Vector &
00262 LagrangeMP_FE::getM_Force(const Vector &disp, double fact)
00263 {
00264  opserr << "WARNING lagrangeMP_FE::getM_Force() - not yet implemented\n";
00265  return *resid;
00266 }
00267 
00268 void  
00269 LagrangeMP_FE::determineTangent(void)
00270 {
00271     const Matrix &constraint = theMP->getConstraint();
00272     int noRows = constraint.noRows();
00273     int noCols = constraint.noCols();
00274     int n = noRows+noCols;
00275     
00276     tang->Zero();    
00277 
00278     for (int j=0; j<noRows; j++) {
00279         (*tang)(n+j, j) = -alpha;
00280         (*tang)(j, n+j) = -alpha;       
00281     }
00282     
00283     for (int i=0; i<noRows; i++)
00284         for (int j=0; j<noCols; j++) {
00285             double val = constraint(i,j) * alpha;
00286             (*tang)(n+i, j+noRows) = val;
00287             (*tang)(noRows+j, n+i) = val;
00288         }
00289 }
00290 
00291 
00292 
00293 
00294 

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