SP_Constraint.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: 2005/12/22 00:35:08 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/domain/constraints/SP_Constraint.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/domain/constraints/SP_Constraint.C
00027 //
00028 // Written: fmk 
00029 // Created: 11/96
00030 // Revision: A
00031 //
00032 // Purpose: This file contains the implementation of class SP_Constraint.
00033 
00034 #include <SP_Constraint.h>
00035 #include <classTags.h>
00036 #include <Vector.h>
00037 #include <Channel.h>
00038 #include <FEM_ObjectBroker.h>
00039 
00040 // constructor for FEM_ObjectBroker
00041 SP_Constraint::SP_Constraint(int clasTag)
00042 :DomainComponent(0,clasTag),
00043  nodeTag(0), dofNumber(0), valueR(0.0), valueC(0.0), isConstant(true), 
00044  loadPatternTag(-1)
00045 {
00046     // does nothing else
00047 }
00048 
00049 // constructor for a subclass to use
00050 SP_Constraint::SP_Constraint(int tag, int node, int ndof, int clasTag)
00051 :DomainComponent(tag, clasTag),
00052  nodeTag(node), dofNumber(ndof), valueR(0.0), valueC(0.0), isConstant(true), 
00053  loadPatternTag(-1)
00054  // valueC is set to 1.0 so that homo will be false when recvSelf() invoked
00055  // should be ok as valueC cannot be used by subclasses and subclasses should
00056  // not be used if it is a homogeneous constraint.
00057 {
00058 
00059 }
00060 
00061 // constructor for object of type SP_Constraint
00062 SP_Constraint::SP_Constraint(int tag, int node, int ndof, double value, bool ISconstant)
00063 :DomainComponent(tag, CNSTRNT_TAG_SP_Constraint),
00064  nodeTag(node), dofNumber(ndof), valueR(value), valueC(value), isConstant(ISconstant),
00065  loadPatternTag(-1)
00066 {
00067 
00068 }
00069 
00070 SP_Constraint::~SP_Constraint()
00071 {
00072     // does nothing
00073 }
00074 
00075 
00076 int
00077 SP_Constraint::getNodeTag(void) const
00078 {
00079     // return id of constrained node
00080     return nodeTag;
00081 }
00082 
00083 int
00084 SP_Constraint::getDOF_Number(void) const
00085 {
00086     //  return the number of the constrained DOF    
00087     return dofNumber;
00088 }
00089 
00090 
00091 double
00092 SP_Constraint::getValue(void)
00093 {
00094     // return the value of the constraint
00095     return valueC;
00096 }
00097 
00098 int
00099 SP_Constraint::applyConstraint(double loadFactor)
00100 {
00101     // as SP_Constraint objects are time invariant nothing is done
00102     if (isConstant == false)
00103         valueC = loadFactor*valueR;
00104 
00105     return 0;
00106 }
00107 
00108 
00109 bool
00110 SP_Constraint::isHomogeneous(void) const
00111 {
00112     if (valueR == 0.0)
00113         return true;
00114     else
00115         return false;
00116 }
00117 
00118 void
00119 SP_Constraint::setLoadPatternTag(int tag)
00120 {
00121   loadPatternTag = tag;
00122 }
00123 
00124 int
00125 SP_Constraint::getLoadPatternTag(void) const
00126 {
00127   return loadPatternTag;
00128 }
00129 
00130 int 
00131 SP_Constraint::sendSelf(int cTag, Channel &theChannel)
00132 {
00133     static Vector data(7);  // we send as double to avoid having 
00134                      // to send two messages.
00135     data(0) = this->getTag(); 
00136     data(1) = nodeTag;
00137     data(2) = dofNumber;
00138     data(3) = valueC;
00139     if (isConstant == true)
00140         data(4) = 1.0;
00141     else
00142         data(4) = 0.0;
00143     data(5) = valueR;
00144     data(6) = this->getLoadPatternTag();
00145 
00146     int result = theChannel.sendVector(this->getDbTag(), cTag, data);
00147     if (result != 0) {
00148       opserr << "WARNING SP_Constraint::sendSelf - error sending Vector data\n";
00149       return result;
00150     }
00151 
00152     return 0;
00153 }
00154 
00155 int 
00156 SP_Constraint::recvSelf(int cTag, Channel &theChannel, 
00157                         FEM_ObjectBroker &theBroker)
00158 {
00159     static Vector data(7);  // we sent the data as double to avoid having to send
00160                      // two messages
00161     int result = theChannel.recvVector(this->getDbTag(), cTag, data);
00162     if (result < 0) {
00163         opserr << "WARNING SP_Constraint::recvSelf - error receiving Vector data\n";
00164         return result;
00165     }
00166     
00167     // if o.k. set the data
00168     this->setTag(data(0));
00169     nodeTag = data(1);
00170     dofNumber = data(2);
00171     valueC = data(3);
00172 
00173     if (data(4) == 1.0)
00174         isConstant = true;
00175     else
00176         isConstant = false;
00177     valueR = data(5);
00178     valueC = valueR;
00179     this->setLoadPatternTag(data(6));
00180     return 0;
00181 }
00182 
00183 
00184 void
00185 SP_Constraint::Print(OPS_Stream &s, int flag) 
00186 {
00187     s << "SP_Constraint: " << this->getTag();
00188     s << "\t Node: " << nodeTag << " DOF: " << dofNumber;
00189     s << " ref value: " << valueR << " current value: " << valueC << endln;
00190 }
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 

Generated on Mon Oct 23 15:05:00 2006 for OpenSees by doxygen 1.5.0