/usr/include/trilinos/fei_Lookup_Impl.hpp is in libtrilinos-dev 10.4.0.dfsg-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 | /*--------------------------------------------------------------------*/
/* Copyright 2005 Sandia Corporation. */
/* Under the terms of Contract DE-AC04-94AL85000, there is a */
/* non-exclusive license for use of this work by or on behalf */
/* of the U.S. Government. Export of this program may require */
/* a license from the United States Government. */
/*--------------------------------------------------------------------*/
#ifndef _fei_Lookup_Impl_hpp_
#define _fei_Lookup_Impl_hpp_
#include <fei_macros.hpp>
#include <fei_MatrixGraph.hpp>
#include <fei_Pattern.hpp>
#include <fei_ConnectivityBlock.hpp>
#include <fei_SharedIDs.hpp>
#include <snl_fei_RecordCollection.hpp>
#include <snl_fei_PointBlockMap.hpp>
#include <fei_TemplateUtils.hpp>
#include <fei_Lookup.hpp>
#include <vector>
namespace fei {
/** An implementation of the Lookup interface.
*/
class Lookup_Impl : public virtual Lookup {
public:
/** Constructor */
Lookup_Impl(fei::SharedPtr<fei::MatrixGraph> matGraph,
int nodeIDType);
/** Destructor */
virtual ~Lookup_Impl();
/** Implementation of Lookup:: method */
int getNumFields()
{
return( vspace_->getNumFields() );
}
/** Implementation of Lookup:: method */
int getFieldSize(int fieldID)
{
return(vspace_->getFieldSize(fieldID));
}
/** Implementation of Lookup:: method */
const int* getFieldIDsPtr()
{
int len = getNumFields();
if (len < 1) return(NULL);
vspace_->getFields(fieldIDs_);
return(&fieldIDs_[0]);
}
/** Implementation of Lookup:: method */
const int* getFieldSizesPtr()
{
const int* fieldIDs = getFieldIDsPtr();
if (fieldIDs == NULL) return(NULL);
unsigned numFields = fieldIDs_.size();
fieldSizes_.resize(numFields);
int* fsPtr = &fieldSizes_[0];
for(unsigned i=0; i<numFields; ++i) {
fsPtr[i] = vspace_->getFieldSize(fieldIDs[i]);
}
return(fsPtr);
}
/** Implementation of Lookup:: method */
int getNumElemBlocks()
{ return(matGraph_->getConnectivityBlocks().size()); }
/** Implementation of Lookup:: method */
const GlobalID* getElemBlockIDs()
{
int err = matGraph_->getConnectivityBlockIDs(elemBlockIDs_);
return(err==0 ? &elemBlockIDs_[0] : NULL);
}
/** Implementation of Lookup:: method */
void getElemBlockInfo(GlobalID blockID,
int& interleaveStrategy, int& lumpingStrategy,
int& numElemDOF, int& numElements,
int& numNodesPerElem, int& numEqnsPerElem)
{
interleaveStrategy = 0; lumpingStrategy = 0;
numElemDOF = 0;
const fei::ConnectivityBlock* cblock =
matGraph_->getConnectivityBlock(blockID);
numElements = cblock->getConnectivityIDs().size();
numNodesPerElem = cblock->getRowPattern()->getNumIDs();
numEqnsPerElem = cblock->getRowPattern()->getNumIndices();
}
/** Implementation of Lookup:: method */
const int* getNumFieldsPerNode(GlobalID blockID)
{
const fei::ConnectivityBlock* cblock = matGraph_->getConnectivityBlock(blockID);
if (cblock==NULL) return(NULL);
return(cblock->getRowPattern()->getNumFieldsPerID());
}
/** Implementation of Lookup:: method */
const int* const* getFieldIDsTable(GlobalID blockID)
{
const fei::ConnectivityBlock* cblock = matGraph_->getConnectivityBlock(blockID);
if (cblock==NULL) return(NULL);
int numNodes = cblock->getRowPattern()->getNumIDs();
const int* numFieldsPerNode = cblock->getRowPattern()->getNumFieldsPerID();
const int* fieldIDs = cblock->getRowPattern()->getFieldIDs();
fieldIDs_2D_.resize(numNodes);
const int** f2dPtr = &fieldIDs_2D_[0];
int offset = 0;
for(int i=0; i<numNodes; ++i) {
f2dPtr[i] = fieldIDs + offset;
offset += numFieldsPerNode[i];
}
return(f2dPtr);
}
/** Implementation of Lookup:: method */
int getEqnNumber(int nodeNumber, int fieldID);
/** Implementation of Lookup:: method */
int getAssociatedNodeNumber(int eqnNumber);
int getAssociatedNodeID(int eqnNumber);
/** Implementation of Lookup:: method */
int getAssociatedFieldID(int eqnNumber);
/** Implementation of Lookup:: method */
bool isInLocalElement(int nodeNumber);
/** Implementation of Lookup:: method */
int getNumSubdomains(int nodeNumber)
{
std::vector<int>* subdomains = NULL;
std::map<int,std::vector<int>* >::iterator
nns_iter = nodenumSubdomainDB_.find(nodeNumber);
if (nns_iter != nodenumSubdomainDB_.end()) subdomains = (*nns_iter).second;
return( subdomains==0 ? 0 : subdomains->size() );
}
/** Implementation of Lookup:: method */
int* getSubdomainList(int nodeNumber)
{
std::vector<int>* subdomains = NULL;
std::map<int,std::vector<int>* >::iterator
nns_iter = nodenumSubdomainDB_.find(nodeNumber);
if (nns_iter != nodenumSubdomainDB_.end()) subdomains = (*nns_iter).second;
return( subdomains==0 ? NULL : &(*subdomains)[0] );
}
/** Implementation of Lookup:: method */
int getNumSharedNodes()
{
int numShared;
int err = vspace_->getNumSharedIDs(nodeIDType_, numShared);
return(err==0 ? numShared : -1);
}
/** Implementation of Lookup:: method */
const int* getSharedNodeNumbers()
{
fei::SharedIDs<int>& sharedIDs = vspace_->getSharedIDs_private(nodeIDType_);
int numShared = sharedIDs.getSharedIDs().size();
workspace_.resize(numShared*2);
int* wkPtr = &workspace_[0];
fei::copyKeysToArray(sharedIDs.getSharedIDs(), numShared, wkPtr);
snl_fei::RecordCollection* collection = NULL;
vspace_->getRecordCollection(nodeIDType_, collection);
for(int i=0; i<numShared; ++i) {
fei::Record<int>* node = collection->getRecordWithID(wkPtr[i]);
if (node == NULL) return NULL;
wkPtr[numShared+i] = node->getNumber();
}
return(wkPtr+numShared);
}
/** Implementation of Lookup:: method */
const int* getSharedNodeProcs(int nodeNumber)
{
std::map<int,fei::Record<int>*>::iterator
nnp_iter = nodenumPairs_.find(nodeNumber);
if (nnp_iter == nodenumPairs_.end()) return(0);
fei::Record<int>* node = (*nnp_iter).second;
const fei::SharedIDs<int>& sharedIDs = vspace_->getSharedIDs_private(nodeIDType_);
int shID = node->getID();
fei::SharedIDs<int>::map_type::const_iterator
iter = sharedIDs.getSharedIDs().find(shID);
if (iter == sharedIDs.getSharedIDs().end()) return(NULL);
const std::set<int>& shprocs = iter->second;
fei::copySetToVector(shprocs, workspace_);
return(&workspace_[0]);
}
/** Implementation of Lookup:: method */
int getNumSharingProcs(int nodeNumber)
{
std::map<int,fei::Record<int>*>::iterator
nnp_iter = nodenumPairs_.find(nodeNumber);
if (nnp_iter == nodenumPairs_.end()) return(0);
fei::Record<int>* node = (*nnp_iter).second;
const fei::SharedIDs<int>& sharedIDs = vspace_->getSharedIDs_private(nodeIDType_);
int shID = node->getID();
fei::SharedIDs<int>::map_type::const_iterator
iter = sharedIDs.getSharedIDs().find(shID);
if (iter == sharedIDs.getSharedIDs().end()) return(0);
const std::set<int>& shprocs = iter->second;
return(shprocs.size());
}
/** Implementation of Lookup:: method */
bool isExactlyBlkEqn(int ptEqn)
{ return( ptBlkMap_->isExactlyBlkEqn(ptEqn) ); }
/** Implementation of Lookup:: method */
int ptEqnToBlkEqn(int ptEqn)
{ return( ptBlkMap_->eqnToBlkEqn(ptEqn) ); }
/** Implementation of Lookup:: method */
int getOffsetIntoBlkEqn(int blkEqn, int ptEqn);
/** Implementation of Lookup:: method */
int getBlkEqnSize(int blkEqn)
{
return( ptBlkMap_->getBlkEqnSize(blkEqn) );
}
private:
int buildDatabases();
fei::SharedPtr<fei::MatrixGraph> matGraph_;
snl_fei::PointBlockMap* ptBlkMap_;
fei::SharedPtr<fei::VectorSpace> vspace_;
int nodeIDType_;
std::map<int, fei::Record<int>*> nodenumPairs_;
std::map<int,fei::Record<int>*> eqnnumPairs_;
std::map<int,std::vector<int>*> nodenumSubdomainDB_;
bool databasesBuilt_;
std::vector<int> fieldIDs_;
std::vector<int> fieldSizes_;
std::vector<GlobalID> elemBlockIDs_;
std::vector<const int*> fieldIDs_2D_;
std::vector<int> workspace_;
};//class Lookup_Impl
}//namespace fei
#endif // _fei_Lookup_Impl_hpp_
|