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 | Private Member Functions | Private Attributes | List of all members
NodeDatabase Class Reference

#include <fei_NodeDatabase.hpp>

Public Member Functions

 NodeDatabase (std::map< int, int > *fieldDatabase, NodeCommMgr *nodeCommMgr)
 
virtual ~NodeDatabase ()
 
int getNumNodeDescriptors () const
 
std::map< GlobalID, int > & getNodeIDs ()
 
int getNodeWithID (GlobalID nodeID, const NodeDescriptor *&node) const
 
int getNodeWithID (GlobalID nodeID, NodeDescriptor *&node)
 
int getNodeWithNumber (int nodeNumber, const NodeDescriptor *&node) const
 
int getNodeWithEqn (int eqnNumber, const NodeDescriptor *&node) const
 
void getNodeAtIndex (int i, const NodeDescriptor *&node) const
 
void getNodeAtIndex (int i, NodeDescriptor *&node)
 
int countLocalNodalEqns (int localRank)
 
int countLocalNodeDescriptors (int localRank)
 
int getIndexOfID (GlobalID nodeID) const
 
int initNodeID (GlobalID nodeID)
 
int initNodeIDs (GlobalID *nodeIDs, int numNodes)
 
int synchronize (int firstLocalNodeNumber, int firstLocalEqn, int localRank, MPI_Comm comm)
 
int getAssociatedNodeNumber (int eqnNumber)
 
int getAssociatedFieldID (int eqnNumber)
 
bool isSynchronized ()
 

Private Member Functions

 NodeDatabase (const NodeDatabase &src)
 
NodeDatabaseoperator= (const NodeDatabase &src)
 
void deleteMemory ()
 

Private Attributes

std::vector< NodeDescriptor * > nodePtrs_
 
std::vector< int > eqnNumbers_
 
std::vector< int > eqnNodeIndices_
 
std::map< GlobalID, int > nodeIDs_
 
std::map< int, int > nodeNumbers_
 
bool synchronized_
 
bool need_to_alloc_and_sync_
 
std::map< int, int > * fieldDB_
 
NodeCommMgrnodeCommMgr_
 
int numLocalNodes_
 
int firstLocalNodeNumber_
 
int lastLocalNodeNumber_
 
fei_Pool_alloc< NodeDescriptornodePool_
 

Detailed Description

Container that holds NodeDescriptors, and is able to reference them by

global identifiers, or by nodeNumbers or eqnNumbers.

These are the 3 fundamental ways to refer to a node:

The goal of this class is to be able to provide a node's descriptor as fast as possible, given a nodeID, nodeNumber, or eqnNumber. Binary searches are used wherever possible.

The return-value of all functions in this class (except trivial query/accessor functions) is an error-code. If the function is successful, the error-code is 0. If a node-not-found error occurs, -1 is returned. If an allocation fails, -2 is returned.

This class is intended to be used by an FEI implementation, with usage proceeding in 3 distinct 'phases':

Definition at line 66 of file fei_NodeDatabase.hpp.

Constructor & Destructor Documentation

NodeDatabase::NodeDatabase ( std::map< int, int > *  fieldDatabase,
NodeCommMgr nodeCommMgr 
)

Constructor.

Definition at line 23 of file fei_NodeDatabase.cpp.

NodeDatabase::~NodeDatabase ( )
virtual

Destructor.

Definition at line 40 of file fei_NodeDatabase.cpp.

References deleteMemory().

NodeDatabase::NodeDatabase ( const NodeDatabase src)
private

Member Function Documentation

int NodeDatabase::getNumNodeDescriptors ( ) const
inline

Obtain number-of-node-descriptors (in function's return-value). Note that this remains 0 until after allocateNodeDescriptors() is called.

Definition at line 78 of file fei_NodeDatabase.hpp.

References nodePtrs_.

Referenced by Filter::calculateResidualNorms(), FEDataFilter::initLinSysCore(), LinSysCoreFilter::initLinSysCore(), and SNL_FEI_Structure::setNumNodesAndEqnsPerBlock().

std::map<GlobalID,int>& NodeDatabase::getNodeIDs ( )
inline

Obtain the set of nodeIDs. This is available anytime, and doesn't necessarily imply that there is a corresponding array of NodeDescriptors.

Definition at line 83 of file fei_NodeDatabase.hpp.

References nodeIDs_.

Referenced by SNL_FEI_Structure::getActiveNodeIDList(), FEI_Implementation::getLocalNodeIDList(), SNL_FEI_Structure::getNumActiveNodes(), FEI_Implementation::getNumLocalNodes(), SNL_FEI_Structure::initializeBlkEqnMapper(), SNL_FEI_Structure::setNodalEqnInfo(), and SNL_FEI_Structure::writeEqn2NodeMap().

int NodeDatabase::getNodeWithID ( GlobalID  nodeID,
const NodeDescriptor *&  node 
) const

Given a nodeID, return the corresponding node-descriptor. This function is only available after allocateNodeDescriptors() has been called (returns -1 if allocateNodeDescriptors() hasn't been called).

Parameters
nodeIDInput. nodeID for which a NodeDescriptor is required.
nodeOutput. NodeDescriptor corresponding to node 'nodeID'. If no corresponding node is found, or if allocatedNodeDescriptors() hasn't been called yet, node is not referenced.
Returns
error-code 0 if successful, -1 if nodeID not found.

Definition at line 55 of file fei_NodeDatabase.cpp.

References getIndexOfID(), and nodePtrs_.

Referenced by NodeCommMgr::allocateNodeDescriptorPtrs(), convert_field_and_nodes_to_eqns(), SNL_FEI_Structure::finalizeActiveNodes(), Filter::findNode(), SNL_FEI_Structure::findNode(), Filter::findNodeDescriptor(), SNL_FEI_Structure::findNodeDescriptor(), FEDataFilter::getBlockFieldNodeSolution(), LinSysCoreFilter::getBlockFieldNodeSolution(), FEDataFilter::getBlockNodeSolution(), LinSysCoreFilter::getBlockNodeSolution(), SNL_FEI_Structure::getElemNodeDescriptors(), fei::DirichletBCManager::getEqnNumber(), SNL_FEI_Structure::getEqnNumbers(), FEDataFilter::getNodalFieldSolution(), LinSysCoreFilter::getNodalFieldSolution(), FEDataFilter::getNodalSolution(), LinSysCoreFilter::getNodalSolution(), FEI_Implementation::getNumSolnParams(), FEDataFilter::loadFEDataMultCR(), FEDataFilter::loadFEDataPenCR(), FEDataFilter::loadNodeBCs(), FEDataFilter::putBlockFieldNodeSolution(), LinSysCoreFilter::putBlockFieldNodeSolution(), FEDataFilter::putNodalFieldData(), LinSysCoreFilter::putNodalFieldData(), FEDataFilter::putNodalFieldSolution(), LinSysCoreFilter::putNodalFieldSolution(), and LinSysCoreFilter::resolveConflictingCRs().

int NodeDatabase::getNodeWithID ( GlobalID  nodeID,
NodeDescriptor *&  node 
)

Definition at line 68 of file fei_NodeDatabase.cpp.

References getIndexOfID(), and nodePtrs_.

int NodeDatabase::getNodeWithNumber ( int  nodeNumber,
const NodeDescriptor *&  node 
) const

Given a nodeNumber, return the corresponding node-descriptor.

Parameters
nodeNumberInput. nodeNumber for which a NodeDescriptor is required. This function returns -1 (and doesn't reference 'node') if synchronize() hasn't been called yet.
nodeOutput. NodeDescriptor corresponding to node 'nodeNumber'. If no corresponding node is found, node is not referenced.
Returns
error-code 0 if successful, -1 if node with nodeNumber not present.

Definition at line 81 of file fei_NodeDatabase.cpp.

References ERReturn, nodeNumbers_, nodePtrs_, and synchronized_.

Referenced by SNL_FEI_Structure::getEqnNumber(), SNL_FEI_Structure::getNumSubdomains(), FEDataFilter::getReducedSolnEntry(), SNL_FEI_Structure::getSubdomainList(), FEDataFilter::giveToLocalReducedMatrix(), FEDataFilter::giveToLocalReducedRHS(), FEDataFilter::giveToMatrix(), and SNL_FEI_Structure::isInLocalElement().

int NodeDatabase::getNodeWithEqn ( int  eqnNumber,
const NodeDescriptor *&  node 
) const

Given an equation-number, return the corresponding node-descriptor.

Parameters
eqnNumberInput. eqnNumber for which a NodeDescriptor is required.
nodeOutput. NodeDescriptor corresponding to eqnNumber. If no corresponding node is found, node is not referenced.
Returns
error-code 0 if successful, -1 if node with eqnNumber not present.

Definition at line 100 of file fei_NodeDatabase.cpp.

References fei::binarySearch(), eqnNodeIndices_, eqnNumbers_, NodeDescriptor::getFieldEqnNumbers(), NodeDescriptor::getFieldIDList(), NodeDescriptor::getNumFields(), and nodePtrs_.

Referenced by SNL_FEI_Structure::calculateSlaveEqns(), convert_eqns_to_nodenumbers_and_dof_ids(), and FEDataFilter::giveToRHS().

void NodeDatabase::getNodeAtIndex ( int  i,
const NodeDescriptor *&  node 
) const
void NodeDatabase::getNodeAtIndex ( int  i,
NodeDescriptor *&  node 
)

Definition at line 149 of file fei_NodeDatabase.cpp.

References nodePtrs_.

int NodeDatabase::countLocalNodalEqns ( int  localRank)

Run through the locally-owned NodeDescriptors and count the number of nodal equations. (Returns 0 if the node-descriptors haven't been allocated or initialized yet.) The result is produced in the function's return-value.

Definition at line 161 of file fei_NodeDatabase.cpp.

References NodeDescriptor::getFieldIDList(), NodeDescriptor::getNumFields(), NodeDescriptor::getOwnerProc(), and nodePtrs_.

Referenced by SNL_FEI_Structure::initComplete().

int NodeDatabase::countLocalNodeDescriptors ( int  localRank)

Return the number of internal node-descriptors that are locally-owned. This function runs through all currently allocated NodeDescriptors, counting the ones for which ownerProc()==localRank. The result is produced in the return-value. (Obviously returns 0 if the node-descriptors haven't been allocated or initialized yet.)

Definition at line 184 of file fei_NodeDatabase.cpp.

References nodePtrs_.

Referenced by SNL_FEI_Structure::initComplete().

int NodeDatabase::getIndexOfID ( GlobalID  nodeID) const

Given a nodeID, return (in function's return-value) the index of that nodeID.

Parameters
nodeIDInput
Returns
offset if nodeID is found, -1 if nodeID not present.

Definition at line 195 of file fei_NodeDatabase.cpp.

References nodeIDs_.

Referenced by getNodeWithID(), and synchronize().

int NodeDatabase::initNodeID ( GlobalID  nodeID)

Initialization, add node with global identifier 'nodeID'. Only available before 'allocatedNodeDescriptors' has been called. Note that nodeIDs can be initialized multiple times using this function, but nodeID is only stored once in the internal array.

Parameters
nodeIDInput.
Returns
error-code 0 if successful. -2 if allocation failed.

Definition at line 206 of file fei_NodeDatabase.cpp.

References fei_Pool_alloc< T >::allocate(), fei_Pool_alloc< T >::construct(), need_to_alloc_and_sync_, nodeIDs_, nodePool_, nodePtrs_, and NodeDescriptor::setGlobalNodeID().

Referenced by SNL_FEI_Structure::finalizeActiveNodes(), and initNodeIDs().

int NodeDatabase::initNodeIDs ( GlobalID nodeIDs,
int  numNodes 
)

Initialization, add nodes with global identifiers 'nodeIDs'. Only available before 'allocatedNodeDescriptors' has been called. Note that nodeIDs can be initialized multiple times using this function, but each nodeID is only stored once in the internal array.

Parameters
nodeIDsInput.
Returns
error-code 0 if successful. -2 if allocation failed.

Definition at line 231 of file fei_NodeDatabase.cpp.

References initNodeID().

Referenced by SNL_FEI_Structure::initElem().

int NodeDatabase::synchronize ( int  firstLocalNodeNumber,
int  firstLocalEqn,
int  localRank,
MPI_Comm  comm 
)

Signal that node-descriptor initialization is complete. In other words, that the calling code has set fieldIDs, equation-numbers and owner-proc information on each node-descriptor. At this point, this class will run through the array of node-descriptors and set the nodeNumber for each node, as well as setting the cross-referencing info required to look up nodes by equation-number.

Parameters
firstLocalNodeNumberInput. This will be the starting point for assigning node-numbers within this function.
firstLocalEqnInput. This will be the starting point for assigning equation-numbers within this function.
localRankInput. MPI rank of the local processor.
Returns
error-code 0 if successful

Definition at line 243 of file fei_NodeDatabase.cpp.

References CHK_ERR, eqnNodeIndices_, eqnNumbers_, ERReturn, NodeCommMgr::exchangeEqnInfo(), firstLocalNodeNumber_, NodeDescriptor::getFieldEqnNumbers(), NodeDescriptor::getFieldIDList(), NodeDescriptor::getGlobalNodeID(), getIndexOfID(), getNodeAtIndex(), NodeDescriptor::getNodeNumber(), NodeDescriptor::getNumFields(), NodeDescriptor::getNumNodalDOF(), NodeCommMgr::getNumSharedNodes(), NodeDescriptor::getOwnerProc(), NodeCommMgr::getSharedNodeAtIndex(), lastLocalNodeNumber_, need_to_alloc_and_sync_, nodeCommMgr_, nodeIDs_, nodeNumbers_, nodePtrs_, numLocalNodes_, NodeDescriptor::setFieldEqnNumber(), NodeDescriptor::setNodeNumber(), NodeDescriptor::setNumNodalDOF(), fei::sortedListInsert(), and synchronized_.

Referenced by SNL_FEI_Structure::initComplete().

int NodeDatabase::getAssociatedNodeNumber ( int  eqnNumber)

Given an equation-number, return the associated nodeNumber. i.e., return the nodeNumber of the node that contains eqnNumber.

Definition at line 344 of file fei_NodeDatabase.cpp.

References fei::binarySearch(), eqnNodeIndices_, eqnNumbers_, ERReturn, fieldDB_, NodeDescriptor::getFieldEqnNumbers(), NodeDescriptor::getFieldIDList(), NodeDescriptor::getNodeNumber(), NodeDescriptor::getNumFields(), and nodePtrs_.

Referenced by SNL_FEI_Structure::getAssociatedNodeNumber().

int NodeDatabase::getAssociatedFieldID ( int  eqnNumber)

Given an equation-number, return the associated fieldID. i.e., return the fieldID of the nodal solution field that contains eqnNumber.

Definition at line 380 of file fei_NodeDatabase.cpp.

References fei::binarySearch(), eqnNodeIndices_, eqnNumbers_, ERReturn, fieldDB_, NodeDescriptor::getFieldEqnNumbers(), NodeDescriptor::getFieldIDList(), NodeDescriptor::getNumFields(), and nodePtrs_.

Referenced by SNL_FEI_Structure::getAssociatedFieldID().

bool NodeDatabase::isSynchronized ( )
inline

Query whether synchronize() has been called.

Definition at line 193 of file fei_NodeDatabase.hpp.

References synchronized_.

NodeDatabase& NodeDatabase::operator= ( const NodeDatabase src)
private
void NodeDatabase::deleteMemory ( )
private

Member Data Documentation

std::vector<NodeDescriptor*> NodeDatabase::nodePtrs_
private
std::vector<int> NodeDatabase::eqnNumbers_
private
std::vector<int> NodeDatabase::eqnNodeIndices_
private
std::map<GlobalID,int> NodeDatabase::nodeIDs_
private

Definition at line 212 of file fei_NodeDatabase.hpp.

Referenced by getIndexOfID(), getNodeIDs(), initNodeID(), and synchronize().

std::map<int,int> NodeDatabase::nodeNumbers_
private

Definition at line 215 of file fei_NodeDatabase.hpp.

Referenced by getNodeWithNumber(), and synchronize().

bool NodeDatabase::synchronized_
private

Definition at line 217 of file fei_NodeDatabase.hpp.

Referenced by getNodeWithNumber(), isSynchronized(), and synchronize().

bool NodeDatabase::need_to_alloc_and_sync_
private

Definition at line 218 of file fei_NodeDatabase.hpp.

Referenced by initNodeID(), and synchronize().

std::map<int,int>* NodeDatabase::fieldDB_
private

Definition at line 220 of file fei_NodeDatabase.hpp.

Referenced by getAssociatedFieldID(), and getAssociatedNodeNumber().

NodeCommMgr* NodeDatabase::nodeCommMgr_
private

Definition at line 221 of file fei_NodeDatabase.hpp.

Referenced by synchronize().

int NodeDatabase::numLocalNodes_
private

Definition at line 223 of file fei_NodeDatabase.hpp.

Referenced by synchronize().

int NodeDatabase::firstLocalNodeNumber_
private

Definition at line 224 of file fei_NodeDatabase.hpp.

Referenced by synchronize().

int NodeDatabase::lastLocalNodeNumber_
private

Definition at line 224 of file fei_NodeDatabase.hpp.

Referenced by synchronize().

fei_Pool_alloc<NodeDescriptor> NodeDatabase::nodePool_
private

Definition at line 226 of file fei_NodeDatabase.hpp.

Referenced by deleteMemory(), and initNodeID().


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