FEI Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
EqnBuffer Class Reference

#include <fei_EqnBuffer.hpp>

Public Member Functions

 EqnBuffer ()
 
 EqnBuffer (const EqnBuffer &src)
 
virtual ~EqnBuffer ()
 
EqnBufferdeepCopy ()
 
EqnBufferoperator= (const EqnBuffer &src)
 
int getNumEqns ()
 
std::vector< int > & eqnNumbers ()
 
std::vector< fei::CSVec * > & eqns ()
 
int getNumRHSs ()
 
void setNumRHSs (int n)
 
int addRHS (int eqnNumber, int rhsIndex, double value, bool accumulate=true)
 
std::vector< std::vector
< double > * > * 
rhsCoefsPtr ()
 
int getEqnIndex (int eqn)
 
int isInIndices (int eqn)
 
int addEqn (int eqnNumber, const double *coefs, const int *indices, int len, bool accumulate, bool create_indices_union=false)
 
int addEqns (EqnBuffer &inputEqns, bool accumulate)
 
int getCoef (int eqnNumber, int colIndex, double &coef)
 
int removeIndex (int eqnNumber, int colIndex)
 
int getCoefAndRemoveIndex (int eqnNumber, int colIndex, double &coef)
 
void resetCoefs ()
 
int addIndices (int eqnNumber, const int *indices, int len)
 

Public Attributes

int newCoefData_
 
int newRHSData_
 

Private Member Functions

void deleteMemory ()
 
int insertNewEqn (int eqn, int insertPoint)
 
int internalAddEqn (int index, const double *coefs, const int *indices, int len, bool accumulate)
 

Private Attributes

std::vector< int > eqnNumbers_
 
std::vector< fei::CSVec * > eqns_
 
std::vector< int > indices_union_
 
int numRHSs_
 
std::vector< std::vector
< double > * > 
rhsCoefs_
 
bool setNumRHSsCalled_
 
bool rhsCoefsAllocated_
 
std::vector< double > dummyCoefs_
 

Detailed Description

A class for holding equation data, along with optional RHS coefficients for the equations.

Definition at line 21 of file fei_EqnBuffer.hpp.

Constructor & Destructor Documentation

EqnBuffer::EqnBuffer ( )

Constructor

Definition at line 17 of file fei_EqnBuffer.cpp.

Referenced by deepCopy().

EqnBuffer::EqnBuffer ( const EqnBuffer src)

copy constructor

Definition at line 32 of file fei_EqnBuffer.cpp.

EqnBuffer::~EqnBuffer ( )
virtual

Destructor

Definition at line 78 of file fei_EqnBuffer.cpp.

References deleteMemory().

Member Function Documentation

EqnBuffer * EqnBuffer::deepCopy ( )

Return a 'clone' of this object, including a copy of all internal data.

Definition at line 83 of file fei_EqnBuffer.cpp.

References EqnBuffer().

Referenced by EqnCommMgr::operator=(), and test_EqnBuffer::test1().

EqnBuffer & EqnBuffer::operator= ( const EqnBuffer src)

assignment operator

Definition at line 48 of file fei_EqnBuffer.cpp.

References eqnNumbers_, eqns_, numRHSs_, and rhsCoefs_.

int EqnBuffer::getNumEqns ( )
inline
std::vector<int>& EqnBuffer::eqnNumbers ( )
inline
std::vector<fei::CSVec*>& EqnBuffer::eqns ( )
inline
int EqnBuffer::getNumRHSs ( )
inline

Return the number of right-hand-side coefficientss stored for each equation.

Definition at line 52 of file fei_EqnBuffer.hpp.

References numRHSs_.

Referenced by addEqns(), EqnCommMgr::exchangeEqnBuffers(), and EqnCommMgr::exchangeIndices().

void EqnBuffer::setNumRHSs ( int  n)

Set the number of right-hand-side coefficients to be stored for each equation. This function internally allocates a table to hold the rhs coefficients. This table has number-of-rows == 'getNumEqns()', and number-of-columns == 'n'. Note that this function should not be called after rhs coefficients have been added, because it destroys and re-allocates the rhs-coef table.

Parameters
n

Definition at line 112 of file fei_EqnBuffer.cpp.

References getNumEqns(), numRHSs_, and rhsCoefs_.

Referenced by addRHS(), EqnCommMgr::exchangeEqnBuffers(), EqnCommMgr::exchangeIndices(), LinSysCoreFilter::getEqnsFromRHS(), EqnCommMgr::setNumRHSs(), and test_EqnBuffer::test1().

int EqnBuffer::addRHS ( int  eqnNumber,
int  rhsIndex,
double  value,
bool  accumulate = true 
)

Set a right-hand-side coefficient.

Parameters
eqnNumberMust correspond to one of the equation-numbers in the list 'eqnNumbers()'.
rhsIndexMust be in the range [0 .. getNumRHSs()-1].
valueThe coefficient.

Definition at line 127 of file fei_EqnBuffer.cpp.

References fei::binarySearch(), fei::console_out(), eqnNumbers_, FEI_ENDL, rhsCoefs_, and setNumRHSs().

Referenced by addEqns(), EqnCommMgr::addRemoteRHS(), EqnCommMgr::exchangeEqnBuffers(), LinSysCoreFilter::getEqnsFromRHS(), and test_EqnBuffer::test1().

std::vector<std::vector<double>*>* EqnBuffer::rhsCoefsPtr ( )
inline

Return the table (actually an array of pointers to arrays) of right-hand-side coefficients. Number-of-arrays == 'getNumEqns()', number-of-columns == 'getNumRHSs()'.

Definition at line 76 of file fei_EqnBuffer.hpp.

References rhsCoefs_.

Referenced by addEqns(), EqnCommMgr::exchangeEqnBuffers(), SNL_FEI_Structure::getMasterEqnRHS(), EqnCommMgr::localRHSsPtr(), and operator<<().

int EqnBuffer::getEqnIndex ( int  eqn)

Return an offset into the 'eqnNumbers()' list, being the position at which equation-number 'eqn' is located.

Parameters
eqn
Returns
offset 'eqn's location, or -1 if 'eqn' is not found.

Definition at line 106 of file fei_EqnBuffer.cpp.

References fei::binarySearch(), and eqnNumbers_.

Referenced by EqnCommMgr::exchangeEqnBuffers(), EqnCommMgr::exchangeIndices(), and EqnCommMgr::exchangeSoln().

int EqnBuffer::isInIndices ( int  eqn)

Query whether 'eqn' is present in the table of column-indices.

Parameters
eqn
Returns
offset Row of the table that contains 'eqn', or -1 if not found.

Definition at line 148 of file fei_EqnBuffer.cpp.

References fei::binarySearch(), eqns_, getNumEqns(), fei::CSVec::indices(), and indices_union_.

Referenced by SNL_FEI_Structure::removeCouplings(), and test_EqnBuffer::test1().

int EqnBuffer::addEqn ( int  eqnNumber,
const double *  coefs,
const int *  indices,
int  len,
bool  accumulate,
bool  create_indices_union = false 
)

Add an equation, with associated coefficients and column-indices.

Parameters
eqnNumber
coefs
indices
lenNumber of coefficients and indices
accumulateIf this equation is already present, indicate whether incoming coefficients should replace existing ones, or be accumulated into them. Note that this only matters if eqnNumber is already present AND if one or more of 'indices' are already present.
create_indices_uniondefaults to false. If true, adds each set of indices to a union of all indices. This will be used if the 'isInIndices' method is called later.
Returns
error-code, 0 if successful

Definition at line 172 of file fei_EqnBuffer.cpp.

References fei::binarySearch(), eqnNumbers_, indices_union_, insertNewEqn(), internalAddEqn(), and fei::sortedListInsert().

Referenced by addEqns(), EqnCommMgr::addRemoteEqn(), SNL_FEI_Structure::calculateSlaveEqns(), EqnCommMgr::exchangeEqnBuffers(), EqnCommMgr::exchangeRemEssBCs(), fei::DirichletBCManager::finalizeBCEqns(), EqnCommMgr::gatherSharedBCs(), LinSysCoreFilter::getEqnsFromMatrix(), SNL_FEI_Structure::removeCouplings(), LinSysCoreFilter::resolveConflictingCRs(), and test_EqnBuffer::test1().

int EqnBuffer::addEqns ( EqnBuffer inputEqns,
bool  accumulate 
)

Add the equations in inputEqns. Upon completion, the set of equations in 'this' EqnBuffer is the union of the equations that were already present, and the equations in inputEqns.

Parameters
inputEqnsEqnBuffer containing equations to be added to this EqnBuffer.
accumulateIf an equation is already present, determines whether to add its coefficients to those already in place, or replace them.

Definition at line 271 of file fei_EqnBuffer.cpp.

References addEqn(), addRHS(), fei::CSVec::coefs(), eqnNumbers(), eqns(), getNumEqns(), getNumRHSs(), fei::CSVec::indices(), and rhsCoefsPtr().

Referenced by EqnCommMgr::gatherSharedBCs(), and test_EqnBuffer::test1().

int EqnBuffer::getCoef ( int  eqnNumber,
int  colIndex,
double &  coef 
)

Given an equation number and a column-index in that equation, get the corresponding coefficient.

Parameters
eqnNumberInput Equation-number
colIndexInput Column-index in equation-number.
coefOutput coefficient corresponding to colIndex in eqnNumber.
Returns
error-code 0 if successful. If eqnNumber is not found, or if equation 'eqnNumber' doesn't contain 'colIndex', then -1 is returned and coef is not referenced.

Definition at line 201 of file fei_EqnBuffer.cpp.

References fei::binarySearch(), eqnNumbers_, and eqns_.

Referenced by test_EqnBuffer::test1().

int EqnBuffer::removeIndex ( int  eqnNumber,
int  colIndex 
)

Remove the specified column-index from the specified equation-number.

Returns
error-code 0 if successful. If eqnNumber is not found, -1 is returned. If equation eqnNumber doesn't contain 'colIndex', the remove request is considered successful and 0 is returned.

Definition at line 214 of file fei_EqnBuffer.cpp.

References fei::binarySearch(), eqnNumbers_, and eqns_.

Referenced by test_EqnBuffer::test1().

int EqnBuffer::getCoefAndRemoveIndex ( int  eqnNumber,
int  colIndex,
double &  coef 
)

Combine the functions 'getCoef()' and 'removeIndex()'. Has the same effect as calling those two functions separately, but saves two searches.

Returns
error-code 0 if successful. -1 is returned if position (eqnNumber, colIndex is not found.

Definition at line 242 of file fei_EqnBuffer.cpp.

References fei::binarySearch(), eqnNumbers_, and eqns_.

Referenced by SNL_FEI_Structure::removeCouplings(), and test_EqnBuffer::test1().

void EqnBuffer::resetCoefs ( )

Reset all coefficients to 0.0

Definition at line 351 of file fei_EqnBuffer.cpp.

References eqns_, getNumEqns(), and fei::set_values().

Referenced by EqnCommMgr::exchangeEqns(), EqnCommMgr::resetCoefs(), and test_EqnBuffer::test1().

int EqnBuffer::addIndices ( int  eqnNumber,
const int *  indices,
int  len 
)

Add an equation, with associated column-indices but not coefficients.

Definition at line 359 of file fei_EqnBuffer.cpp.

References fei::binarySearch(), dummyCoefs_, eqnNumbers_, insertNewEqn(), and internalAddEqn().

Referenced by EqnCommMgr::addRemoteIndices(), EqnCommMgr::exchangeIndices(), LinSysCoreFilter::getEqnsFromRHS(), and test_EqnBuffer::test1().

void EqnBuffer::deleteMemory ( )
private

Definition at line 93 of file fei_EqnBuffer.cpp.

References eqns_, getNumEqns(), numRHSs_, and rhsCoefs_.

Referenced by ~EqnBuffer().

int EqnBuffer::insertNewEqn ( int  eqn,
int  insertPoint 
)
private

Definition at line 302 of file fei_EqnBuffer.cpp.

References fei::console_out(), eqnNumbers_, eqns_, FEI_ENDL, numRHSs_, and rhsCoefs_.

Referenced by addEqn(), and addIndices().

int EqnBuffer::internalAddEqn ( int  index,
const double *  coefs,
const int *  indices,
int  len,
bool  accumulate 
)
private

Definition at line 326 of file fei_EqnBuffer.cpp.

References fei::add_entry(), eqns_, and fei::put_entry().

Referenced by addEqn(), and addIndices().

Member Data Documentation

int EqnBuffer::newCoefData_
int EqnBuffer::newRHSData_
std::vector<int> EqnBuffer::eqnNumbers_
private
std::vector<fei::CSVec*> EqnBuffer::eqns_
private
std::vector<int> EqnBuffer::indices_union_
private

Definition at line 162 of file fei_EqnBuffer.hpp.

Referenced by addEqn(), and isInIndices().

int EqnBuffer::numRHSs_
private

Definition at line 164 of file fei_EqnBuffer.hpp.

Referenced by deleteMemory(), getNumRHSs(), insertNewEqn(), operator=(), and setNumRHSs().

std::vector<std::vector<double>*> EqnBuffer::rhsCoefs_
private
bool EqnBuffer::setNumRHSsCalled_
private

Definition at line 167 of file fei_EqnBuffer.hpp.

bool EqnBuffer::rhsCoefsAllocated_
private

Definition at line 168 of file fei_EqnBuffer.hpp.

std::vector<double> EqnBuffer::dummyCoefs_
private

Definition at line 170 of file fei_EqnBuffer.hpp.

Referenced by addIndices().


The documentation for this class was generated from the following files: