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

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.1.1.1 $
00022 // $Date: 2000/09/15 08:23:18 $
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     Vector data(7);  // we send as double to avoid having 
00134                      // to send two messages.
00135     
00136     data(0) = this->getTag(); 
00137     data(1) = nodeTag;
00138     data(2) = dofNumber;
00139     data(3) = valueC;
00140     if (isConstant == true)
00141  data(4) = 1.0;
00142     else
00143  data(4) = 0.0;
00144     data(5) = valueR;
00145     data(6) = this->getLoadPatternTag();
00146 
00147     int result = theChannel.sendVector(this->getDbTag(), cTag, data);
00148     if (result < 0) 
00149  cerr << "WARNING SP_Constraint::sendSelf - error sending Vector data\n";
00150 
00151     return result;
00152 }
00153 
00154 int 
00155 SP_Constraint::recvSelf(int cTag, Channel &theChannel, 
00156    FEM_ObjectBroker &theBroker)
00157 {
00158     Vector data(7);  // we sent the data as double to avoid having to send
00159                      // two messages
00160     int result = theChannel.recvVector(this->getDbTag(), cTag, data);
00161     if (result < 0) {
00162  cerr << "WARNING SP_Constraint::recvSelf - error receiving Vector data\n";
00163  return result;
00164     }
00165     
00166     // if o.k. set the data
00167     this->setTag(data(0));
00168     nodeTag = data(1);
00169     dofNumber = data(2);
00170     valueC = data(3);
00171 
00172     if (data(4) == 1.0)
00173  isConstant = true;
00174     else
00175  isConstant = false;
00176     valueR = data(5);
00177     valueC = valueR;
00178     this->setLoadPatternTag(data(6));
00179     return 0;
00180 }
00181 
00182 
00183 void
00184 SP_Constraint::Print(ostream &s, int flag) 
00185 {
00186     s << "SP_Constraint: " << this->getTag();
00187     s << "\t Node: " << nodeTag << " DOF: " << dofNumber;
00188     s << " value: " << valueC << endl;
00189 }
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
Copyright Contact Us