fei_NodeDescriptor.cpp

00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #include <fei_macros.hpp>
00010 #include <fei_defs.h>
00011 
00012 #include <fei_NodeDescriptor.hpp>
00013 
00014 //======Constructor=============================================================
00015 NodeDescriptor::NodeDescriptor()
00016  : nodeID_((GlobalID)-1),
00017    nodeNumber_(-1),
00018    numNodalDOF_(0),
00019    fieldIDList_(NULL),
00020    fieldEqnNumbers_(NULL),
00021    numFields_(0),
00022    blkEqnNumber_(0),
00023    ownerProc_(-1),
00024    blockList_(NULL),
00025    numBlocks_(0)
00026 {
00027    //There's nothing for this constructor to do, apart from the
00028    //above initializations.
00029 }
00030 
00031 //======Destructor==============================================================
00032 NodeDescriptor::~NodeDescriptor() {
00033   delete [] fieldIDList_;
00034   delete [] fieldEqnNumbers_;
00035   numFields_ = 0;
00036 
00037   delete [] blockList_;
00038   numBlocks_ = 0;
00039 }
00040 
00041 //==============================================================================
00042 void NodeDescriptor::addField(int fieldID) {
00043 //
00044 //Add a field identifier to this node, ONLY if that field identifier
00045 //is not already present.
00046 //
00047 //If fieldID is added, lengthen the corresponding list for equation numbers.
00048 //
00049 
00050    int tmp = numFields_;
00051    int allocLen = numFields_;
00052    int index = fei::sortedListInsert(fieldID, fieldIDList_, numFields_,
00053                                          allocLen);
00054 
00055    //index is the position at which fieldID was inserted, or found
00056 
00057    //if tmp < numFields_ then fieldID wasn't already present
00058    if (tmp < numFields_) {
00059       //
00060       //if the length of fieldIDList_ changed, let's lengthen the 
00061       //fieldEqnNumbers_ list.
00062       //fieldEqnNumbers_ will have an empty position 'index', which we'll set to
00063       //-99 for now. The calling code (BASE_FEI) will set the fieldEqnNumber for
00064       //this fieldID using setFieldEqnNumber(...).
00065       //
00066 
00067       allocLen = numFields_ - 1;
00068       fei::listInsert(-99, index, fieldEqnNumbers_, tmp, allocLen);
00069    }
00070 }
00071 
00072 //==============================================================================
00073 void NodeDescriptor::setFieldEqnNumber(int fieldID, int eqn) {
00074 //
00075 //Set the equation number corresponding to fieldID. fieldID must
00076 //already have been added to this node using the addField function.
00077 //If it was already added, then the fieldEqnNumbers_ list was lengthened
00078 //appropriately, with an empty spot left for this eqn number.
00079 //
00080    int insert = -1;
00081    int index = fei::binarySearch(fieldID, fieldIDList_,
00082               numFields_, insert);
00083 
00084    if (index < 0) {
00085       return;
00086    }
00087 
00088    fieldEqnNumbers_[index] = eqn;
00089 }
00090 
00091 //==============================================================================
00092 bool NodeDescriptor::getFieldEqnNumber(int fieldID, int& eqnNumber) const
00093 {
00094    int insert = -1;
00095    int index = fei::binarySearch(fieldID, fieldIDList_,
00096               numFields_, insert);
00097 
00098    if (index < 0) {
00099       return(false);
00100    }
00101 
00102    eqnNumber = fieldEqnNumbers_[index];
00103    return(true);
00104 }
00105 
00106 //==============================================================================
00107 bool NodeDescriptor::containedInBlock(GlobalID blk) const
00108 {
00109   //return true if this node is contained in element-block 'blk'.
00110 
00111    int insert;
00112    int index = fei::binarySearch(blk, blockList_, numBlocks_, insert);
00113    if (index >= 0) return(true);
00114    else return(false);
00115 }
00116 

Generated on Tue Jul 13 09:27:45 2010 for FEI by  doxygen 1.4.7