Exemplo n.º 1
0
int fei::Vector_core::copyOutFieldData(int fieldID,
					   int idType,
					   int numIDs,
					   const int* IDs,
					   double* data,
					   int vectorIndex)
{
  if (vecSpace_.get() == NULL) ERReturn(-1);

  int fieldSize = vecSpace_->getFieldSize(fieldID);

  if (haveFEVector_) {
    snl_fei::RecordCollection* collection = NULL;
    CHK_ERR( vecSpace_->getRecordCollection(idType, collection) );
    int nodeNumber;
    int dofOffset;
    int numInstances;
    int foffset;
    std::vector<int>& eqnNums = vecSpace_->getEqnNumbers();
    int* vspcEqnPtr = eqnNums.size() > 0 ? &eqnNums[0] : NULL;

    int offset = 0;
    for(int i=0; i<numIDs; ++i) {
      fei::Record<int>* node = collection->getRecordWithID(IDs[i]);
      if (node == NULL) {
        ERReturn(-1);
      }

      nodeNumber = node->getNumber();
      int* eqnNumbers = vspcEqnPtr+node->getOffsetIntoEqnNumbers();
      node->getFieldMask()->getFieldEqnOffset(fieldID, foffset, numInstances);
      dofOffset = eqnNumbers[foffset] - eqnNumbers[0];
      for(int j=0; j<fieldSize; ++j) {
	CHK_ERR( copyOut_FE(nodeNumber, dofOffset+j, data[offset++]));
      }
    }
  }
  else {
    work_indices_.resize(numIDs*fieldSize*2);
    int* indicesPtr = &work_indices_[0];

    CHK_ERR( vecSpace_->getGlobalIndices(numIDs, IDs, idType,
					 fieldID, indicesPtr) );

    CHK_ERR( copyOut(numIDs*fieldSize, indicesPtr, data) );
  }

  return(0);
}
int snl_fei::RecordMsgHandler::mergeMaskIDs(int srcProc, std::vector<int>& msg)
{
  fei::comm_map::row_type* ids = recvPattern_->getRow(srcProc);

  fei::comm_map::row_type::const_iterator
    id_iter = ids->begin(),
    id_end = ids->end();

  int offset = 0;
  int* msgPtr = &msg[0];

  for(; id_iter != id_end; ++id_iter) {
    int ID = *id_iter;
    fei::Record<int>* rec = recordCollection_->getRecordWithID(ID);
    if (rec == NULL) {
      ERReturn(-1);
    }

    int maskID = msgPtr[offset++];

    if (maskID != rec->getFieldMask()->getMaskID()) {
      //if the masks don't match, we need to add the fields from the
      //incoming-field-mask-id to our record's field-mask.

      //first, find the field-mask for 'maskID'
      fei::FieldMask* mask = NULL;
      for(unsigned fm=0; fm<fieldMasks_.size(); ++fm) {
	if (fieldMasks_[fm]->getMaskID() == maskID) mask = fieldMasks_[fm];
      }
      if (mask == NULL) {
	fei::console_out() << "mergeMaskIDs didn't find mask for maskID="
           << maskID<<FEI_ENDL;
	ERReturn(-1);
      }

      int numFields = mask->getNumFields();
      std::vector<int>& fieldIDs = mask->getFieldIDs();
      std::vector<int>& fieldSizes = mask->getFieldSizes();

      for(int nf=0; nf<numFields; ++nf) {
	recordCollection_->initRecords(fieldIDs[nf], fieldSizes[nf],
				       1, &ID, fieldMasks_);
      }
    }
  }

  return(0);
}
Exemplo n.º 3
0
int
DirichletBCManager::getEqnNumber(int IDType, int ID, int fieldID, int offsetIntoField)
{
  int eqn = -1;
  try {
    if (vecSpace_.get() != NULL) {
      vecSpace_->getGlobalIndex(IDType, ID, fieldID, eqn);
    }
    else {
      if (structure_ == NULL) {
        throw std::runtime_error("fei::DirichletBCManager has NULL SNL_FEI_Structure.");
      }
      NodeDatabase& nodeDB = structure_->getNodeDatabase();
      const NodeDescriptor* node = NULL;
      nodeDB.getNodeWithID(ID, node);
      if (node == NULL) {
        throw std::runtime_error("fei::DirichletBCManager::getEqnNumber failed to get node.");
      }
      node->getFieldEqnNumber(fieldID, eqn);
    }
  }
  catch(std::runtime_error& exc) {
    FEI_OSTRINGSTREAM osstr;
    osstr << "fei::DirichletBCManager::finalizeBCEqns caught exception: "
       << exc.what() << " BC IDType="<<IDType<<", ID="<<ID
       << ", fieldID="<<fieldID;
    fei::console_out() << osstr.str() << FEI_ENDL;
    ERReturn(-1);
  }

  return eqn + offsetIntoField;
}
int snl_fei::RecordMsgHandler::packEqnNumbersMsg(int destProc,
						 std::vector<int>& msg)
{
  fei::comm_map::row_type* ids = sendPattern_->getRow(destProc);
  int len = ids->size()*3;
  msg.resize(len);
  const int* eqnNumPtr = &eqnNumbers_[0];

  fei::comm_map::row_type::const_iterator
    id_iter = ids->begin(),
    id_end = ids->end();
  int offset = 0;
  for(; id_iter != id_end; ++id_iter) {
    int ID = *id_iter;
    fei::Record<int>* rec = recordCollection_->getRecordWithID(ID);
    if (rec == NULL) {
      ERReturn(-1);
    }

    len = rec->getFieldMask()->getNumIndices();

    msg[offset++] = ID;
    msg[offset++] = rec->getNumber();
    msg[offset++] = len;

    const int* eqnNumbers = eqnNumPtr+rec->getOffsetIntoEqnNumbers();
    for(int i=0; i<len; ++i) {
      msg.push_back(eqnNumbers[i]);
    }
  }

  return(0);
}
Exemplo n.º 5
0
int snl_fei::SubdMsgHandler::processRecvMessage(int srcProc,
						std::vector<int>& message)
{
  fei::comm_map::row_type* ids = recvPattern_->getRow(srcProc);
  fei::comm_map::row_type::const_iterator
    id_iter = ids->begin(),
    id_end = ids->end();

  int* msgPtr = &message[0];

  if (message.size() != ids->size()) {
    ERReturn(-1);
  }

  int offset = 0;
  for(; id_iter != id_end; ++id_iter) {
    int ID = *id_iter;

    bool isInRemoteSubdomain = msgPtr[offset++] > 1 ? true : false;

    if (isInRemoteSubdomain) {
      subdomainIDTable_->addSharedID(ID, 1, &srcProc);
    }
  }

  return(0);
}
int snl_fei::RecordMsgHandler::storeEqnNumbers(int srcProc, std::vector<int>& msg)
{
  int numIDs = recvPattern_->getRow(srcProc)->size();
  int offset = numIDs*3;
  int* msgPtr = &msg[0];
  int* eqnNumPtr = &eqnNumbers_[0];
  for(int i=0; i<numIDs; ++i) {
    int ID = msgPtr[i*3];
    int recNumber = msgPtr[i*3+1];
    int numEqns = msgPtr[i*3+2];
    fei::Record<int>* rec = recordCollection_->getRecordWithID(ID);
    if (rec == NULL) {
      ERReturn(-1);
    }

    rec->setNumber(recNumber);
    int* eqnNumbers = eqnNumPtr+rec->getOffsetIntoEqnNumbers();
    for(int eq=0; eq<numEqns; ++eq) {
      eqnNumbers[eq] = msgPtr[offset++];
      ptBlkMap_.setEqn(eqnNumbers[eq], recNumber, numEqns);
    }
  }

  return(0);
}
Exemplo n.º 7
0
int snl_fei::SubdMsgHandler::getSendMessage(int destProc,
					  std::vector<int>& message)
{
  int len = sendPattern_->getRow(destProc)->size();
  message.resize(len);
  int* msgPtr = &message[0];

  fei::comm_map::row_type* ids = sendPattern_->getRow(destProc);
  fei::comm_map::row_type::const_iterator
    id_iter = ids->begin(),
    id_end = ids->end();

  int offset = 0;
  for(; id_iter != id_end; ++id_iter) {
    int ID = *id_iter;
    fei::Record<int>* rec = recordCollection_->getRecordWithID(ID);
    if (rec == NULL) {
      ERReturn(-1);
    }

    if (rec->isInLocalSubdomain_) {
      msgPtr[offset++] = 1;
    }
    else {
      msgPtr[offset++] = 0;
    }
  }

  return(0);
}
Exemplo n.º 8
0
//------------------------------------------------------------------------------
int NodeCommMgr::addSharedNodes( const GlobalID* nodeIDs,
				 int numNodes, 
				 const int* const* procs,
				 const int* numProcs )
{
  //
  //Store the incoming nodeIDs and proc-numbers in the sharedNodeIDs array and
  //sharingProcs_ table.
  //

  try {

  for(int i=0; i<numNodes; i++) {
    int insertPoint = -1;
    int index = fei::binarySearch(nodeIDs[i], sharedNodeIDs, insertPoint);
    if (index < 0) {
      sharingProcs_.insert(sharingProcs_.begin()+insertPoint, new std::vector<int>);

      sharedNodeIDs.insert(sharedNodeIDs.begin()+insertPoint, nodeIDs[i]);

      index = insertPoint;
    }
    
    int err = storeNodeProcs(index, sharingProcs_, procs[i], numProcs[i]);
    if (err != 0) return(err);
  }

  }
  catch(std::runtime_error& exc) {
    fei::console_out() << exc.what() << FEI_ENDL;
    ERReturn(-1);
  }

  return(0);
}
Exemplo n.º 9
0
int test_matrix_unit1()
{
  std::vector<double> data1D;
  std::vector<const double*>data2D;

  int numRows = 2;
  int numCols = 3;
  double** values = new double*[numRows];
  int i, j;
  for(i=0; i<numRows; ++i) {
    values[i] = new double[numCols];
    for(j=0; j<numCols; ++j) {
      values[i][j] = i*1.0;
    }
  }

  fei::Matrix_core::copyTransposeToWorkArrays(numRows, numCols,
					   values, data1D, data2D);

  for(i=0; i<numRows; ++i) {
    for(j=0; j<numCols; ++j) {
      if (std::abs(values[i][j] - (data2D[j])[i]) > 1.e-49) {
	ERReturn(-1);
      }
    }
    delete [] values[i];
  }

  delete [] values;

  return(0);
}
Exemplo n.º 10
0
int test_EqnCommMgr::test2()
{
  FEI_COUT << "testing ProcEqns...";

  ProcEqns procEqns;

  procEqns.addEqn(0, localProc_);
  procEqns.addEqn(1, localProc_);
  procEqns.addEqn(2, localProc_);

  procEqns.addEqn(3, 2, localProc_+1);
  procEqns.addEqn(4, 2, localProc_+1);
  procEqns.addEqn(5, 2, localProc_+1);

  ProcEqns* pCopy = procEqns.deepCopy();

  std::vector<int>& eqnsPerProc = procEqns.eqnsPerProcPtr();
  std::vector<int>& eqnsPerProcCopy = pCopy->eqnsPerProcPtr();

  if (eqnsPerProc != eqnsPerProcCopy) {
    ERReturn(-1);
  }

  delete pCopy;

  FEI_COUT << FEI_ENDL;
  return(0);
}
Exemplo n.º 11
0
int test_Matrix::serialtest2()
{
  testData* testdata = new testData(localProc_, numProcs_);
  std::vector<int>& idTypes = testdata->idTypes;
  std::vector<int>& ids = testdata->ids;

  fei::SharedPtr<fei::VectorSpace> vspc(new fei::VectorSpace(comm_, "sU_Mat"));

  vspc->defineIDTypes(idTypes.size(), &idTypes[0]);

  fei::SharedPtr<fei::MatrixGraph> matgraph(new fei::MatrixGraph_Impl2(vspc, vspc, "sU_Mat"));

  int numIDs = ids.size();
  int idType = idTypes[0];

  int patternID = matgraph->definePattern(numIDs, idType);

  CHK_ERR( matgraph->initConnectivityBlock(0, 1, patternID) );

  CHK_ERR( matgraph->initConnectivity(0, 0, &ids[0]) );

  CHK_ERR( matgraph->initComplete() );

  fei::SharedPtr<fei::FillableMat> ssmat(new fei::FillableMat), ssmatT(new fei::FillableMat);
  int localsize = matgraph->getRowSpace()->getNumIndices_Owned();
  fei::Matrix* matrix = new fei::Matrix_Impl<fei::FillableMat>(ssmat, matgraph, localsize);

  fei::Matrix* matrixT = new fei::Matrix_Impl<fei::FillableMat>(ssmatT, matgraph, localsize);

  std::vector<int> indices(numIDs);
  CHK_ERR( matgraph->getConnectivityIndices(0, 0, numIDs, &indices[0], numIDs) );

  std::vector<double> data1(numIDs*numIDs);
  std::vector<double*> data2d(numIDs);

  int i;
  for(i=0; i<numIDs; ++i) {
    data2d[i] = &(data1[i*numIDs]);
  }

  for(i=0; i<numIDs*numIDs; ++i) {
    data1[i] = 1.0*i;
  }

  CHK_ERR( matrix->sumIn(numIDs, &indices[0],
			 numIDs, &indices[0], &data2d[0], 0) );

  CHK_ERR( matrixT->sumIn(numIDs, &indices[0],
			 numIDs, &indices[0], &data2d[0], 3) );

  if (*ssmat != *ssmatT) {
    ERReturn(-1);
  }

  delete matrix;
  delete matrixT;
  delete testdata;

  return(0);
}
Exemplo n.º 12
0
int test_Factory_helper::dyncastMatrix(fei::Matrix* matrix,
				       const char* libname)
{
  std::string sname(libname);

  if (sname == "TEST_LSC") {

    fei::Matrix_Impl<LinearSystemCore>* smatrix2 =
      dynamic_cast<fei::Matrix_Impl<LinearSystemCore>*>(matrix);
    if (smatrix2 == NULL) {
      FEI_CERR << "dynamic_cast<fei::Matrix_Impl<LinearSystemCore>*> failed"<<FEI_ENDL;
      ERReturn(-1);
    }
  }

  if (sname == "Aztec") {
#ifdef HAVE_FEI_AZTECOO
    fei::Matrix_Impl<LinearSystemCore>* smatrix =
      dynamic_cast<fei::Matrix_Impl<LinearSystemCore>*>(matrix);
    if (smatrix == NULL) {
      FEI_CERR << "dynamic_cast<fei::Matrix_Impl<LinearSystemCore>*> failed"<<FEI_ENDL;
      ERReturn(-1);
    }
#else
    FEI_CERR << "libname==Aztec but HAVE_FEI_AZTECOO not defined."<<FEI_ENDL;
    ERReturn(-1);
#endif
  }

  if (sname == "Trilinos") {
#ifdef HAVE_FEI_EPETRA
    fei::Matrix_Impl<Epetra_CrsMatrix>* smatrix =
      dynamic_cast<fei::Matrix_Impl<Epetra_CrsMatrix>*>(matrix);
    if (smatrix == NULL) {
      FEI_CERR << "dynamic_cast<fei::Matrix_Impl<Epetra_CrsMatrix>*> failed"<<FEI_ENDL;
      ERReturn(-1);
    }
#else
    FEI_CERR << "libname==Trilinos but HAVE_FEI_EPETRA not defined."<<FEI_ENDL;
    ERReturn(-1);
#endif
  }

  return(0);
}
Exemplo n.º 13
0
int test_Factory_helper::dyncastVector(fei::Vector* vector,
				       const char* libname)
{
  std::string sname(libname);
  if (sname == "TEST_LSC") {
    fei::Vector_Impl<LinearSystemCore>* svector =
      dynamic_cast<fei::Vector_Impl<LinearSystemCore>*>(vector);
    if (svector == NULL) {
      FEI_CERR << "dynamic_cast<fei::Vector_Impl<LinearSystemCore>*> failed"<<FEI_ENDL;
      ERReturn(-1);
    }
  }

  if (sname == "Aztec") {
#ifdef HAVE_FEI_AZTECOO
    fei::Vector_Impl<LinearSystemCore>* svector =
      dynamic_cast<fei::Vector_Impl<LinearSystemCore>*>(vector);
    if (svector == NULL) {
      FEI_CERR << "dynamic_cast<fei::Vector_Impl<LinearSystemCore>*> failed"<<FEI_ENDL;
      ERReturn(-1);
    }
#else
    FEI_CERR << "libname==Aztec but HAVE_FEI_AZTECOO not defined."<<FEI_ENDL;
    ERReturn(-1);
#endif
  }

  if (sname == "Trilinos") {
#ifdef HAVE_FEI_EPETRA
    fei::Vector_Impl<Epetra_MultiVector>* svector =
      dynamic_cast<fei::Vector_Impl<Epetra_MultiVector>*>(vector);
    if (svector == NULL) {
      FEI_CERR << "dynamic_cast<fei::Vector_Impl<Epetra_MultiVector>*> failed"<<FEI_ENDL;
      ERReturn(-1);
    }
#else
    FEI_CERR << "libname==Trilinos but HAVE_FEI_EPETRA not defined."<<FEI_ENDL;
    ERReturn(-1);
#endif
  }

  return(0);
}
Exemplo n.º 14
0
int test_Set::test5()
{
  FEI_COUT << "testing fei::binarySearch(...,start,end,...)...";

  std::vector<int> array;
  for(int i=0; i<10; ++i) array.push_back(i);

  int start = 2;
  int end = 6;
  int insertPoint = -1;
  int offset = fei::binarySearch(9, &array[0], array.size(),
				     start, end, insertPoint);
  if (offset >= 0) {
    return(-1);
  }

  offset = fei::binarySearch(4, &array[0], array.size(),
				 start, end, insertPoint);

  if (offset < 0) {
    return(-1);
  }

  fei::ctg_set<int> sset;
  sset.insert2(1);
  sset.insert2(5);
  sset.insert2(9);
  sset.insert2(0);
  sset.insert2(4);
  sset.insert2(8);

  if (sset.size() != 6) {
    ERReturn(-1);
  }

  if (sset.find(0) == sset.end()) {
    ERReturn(-1);
  }

  FEI_COUT << "ok"<<FEI_ENDL;

  return(0);
}
int snl_fei::RecordCollection::getGlobalBlkIndex(int ID, int& globalBlkIndex)
{
  fei::Record<int>* record = getRecordWithID(ID);
  if (record == NULL) {
    globalBlkIndex = -1;
    ERReturn(-1);
  }

  globalBlkIndex = record->getNumber();
  return(0);
}
//----------------------------------------------------------------------------
int snl_fei::LinearSystem_General::parameters(int numParams,
				   const char* const* paramStrings)
{
  if (numParams == 0 || paramStrings == NULL) return(0);

  const char* param = snl_fei::getParam("name", numParams, paramStrings);
  if (param != NULL) {
    if (strlen(param) < 6) ERReturn(-1);

    setName(&(param[5]));
  }

  param = snl_fei::getParam("resolveConflict",numParams,paramStrings);
  if (param != NULL){
    resolveConflictRequested_ = true;
  }

  param = snl_fei::getParam("BCS_TRUMP_SLAVE_CONSTRAINTS",
                            numParams,paramStrings);
  if (param != NULL) {
    bcs_trump_slaves_ = true;
  }

  param = snl_fei::getParam("EXPLICIT_BC_ENFORCEMENT",numParams,paramStrings);
  if (param != NULL){
    explicitBCenforcement_ = true;
  }

  param = snl_fei::getParam("BC_ENFORCEMENT_NO_COLUMN_MOD",numParams,paramStrings);
  if (param != NULL){
    BCenforcement_no_column_mod_ = true;
  }

  param = snl_fei::getParamValue("FEI_OUTPUT_LEVEL",numParams,paramStrings);
  if (param != NULL) {
    setOutputLevel(fei::utils::string_to_output_level(param));
  }

  if (matrix_.get() != NULL) {
    fei::Matrix* matptr = matrix_.get();
    fei::MatrixReducer* matred = dynamic_cast<fei::MatrixReducer*>(matptr);
    if (matred != NULL) {
      matptr = matred->getTargetMatrix().get();
    }
    fei::Matrix_Impl<LinearSystemCore>* lscmatrix =
      dynamic_cast<fei::Matrix_Impl<LinearSystemCore>*>(matptr);
    if (lscmatrix != NULL) {
      lscmatrix->getMatrix()->parameters(numParams, (char**)paramStrings);
    }
  }

  return(0);
}
Exemplo n.º 17
0
int fei::Vector_core::giveToVector(int numValues,
				       const int* indices,
				       const double* values,
				       bool sumInto,
				       int vectorIndex)
{
  int prev_proc = -1;
  fei::CSVec* prev_vec = NULL;
  for(int i=0; i<numValues; ++i) {
    int ind = indices[i];
    double val = values[i];

    if (ind < 0) {
//      throw std::runtime_error("negative index not allowed");
      //preservation of existing behavior: certain Sierra scenarios
      //involve passing negative indices for positions that should be
      //ignored... so we'll continue rather than throwing.
      continue;
    }
    int local = ind - firstLocalOffset_;
    if (local < 0 || local >= numLocal_) {
      int proc = eqnComm_->getOwnerProc(ind);
      if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) {
        FEI_OSTREAM& os = *output_stream_;
        os << dbgprefix_<<"giveToVector remote["<<proc<<"]("
         <<ind<<","<<val<<")"<<FEI_ENDL;
      }
      fei::CSVec* remoteVec = prev_vec;
      if (proc != prev_proc) {
        remoteVec = getRemotelyOwned(proc);
        prev_vec = remoteVec;
        prev_proc = proc;
      }

      if (sumInto) {
        fei::add_entry( *remoteVec, ind, val);
      }
      else {
        fei::put_entry( *remoteVec, ind, val);
      }
    }
    else {
      int err = giveToUnderlyingVector(1, &ind, &val, sumInto, vectorIndex);
      if (err != 0) {
        fei::console_out() << "giveToVector sumIn ERROR, ind: " << ind
          << ", val: " << val << FEI_ENDL;
        ERReturn(-1);
      }
    }
  }

  return(0);
}
Exemplo n.º 18
0
//==============================================================================
int compare_DMSR_contents(fei_trilinos::AztecDMSR_Matrix& matrix, int localOffset,
                          std::vector<std::vector<int> >& colIndices,
                          std::vector<std::vector<double> >& values)
{
    int localSize = colIndices.size();

    for(int i=0; i<localSize; i++) {
        int row = i+localOffset;
        int rowLen = matrix.rowLength(row);
        if (rowLen == 0) ERReturn(-1);
        int* tempInd = new int[rowLen];
        double* tempVal = new double[rowLen];
        std::vector<int> sortedInd;
        std::vector<double> sortedVal;

        int tmpLen = rowLen;
        matrix.getRow(row, tmpLen, tempVal, tempInd);
        if (tmpLen != rowLen) ERReturn(-1);

        for(int j=0; j<tmpLen; j++) {
            int offset = fei::sortedListInsert(tempInd[j], sortedInd);
            if (offset < 0) ERReturn(-1);
            sortedVal.insert(sortedVal.begin()+offset, tempVal[j]);
        }

        delete [] tempInd;
        delete [] tempVal;

        std::vector<int>& colInds = colIndices[i];
        if (sortedInd != colInds) {
            ERReturn(-1);
        }
        std::vector<double>& vals = values[i];
        if (sortedVal != vals) {
            ERReturn(-1);
        }
    }

    return(0);
}
Exemplo n.º 19
0
//------------------------------------------------------------------------------
int NodeCommMgr::getSendMessageLength(int destProc, int& messageLength)
{
  std::vector<int>::iterator
   rs_iter = std::lower_bound(remoteSharingProcs_.begin(),
                              remoteSharingProcs_.end(), destProc);
  if (rs_iter == remoteSharingProcs_.end() || destProc != *rs_iter) {
    ERReturn(-1);
  }

  int idx = rs_iter - remoteSharingProcs_.begin();

  int len = 7+maxFields_*2 + maxBlocks_ + maxSubdomains_;
  messageLength = nodesPerSharingProc_[idx] * (len+1);
  return(0);
}
Exemplo n.º 20
0
//------------------------------------------------------------------------------
int NodeCommMgr::getSendMessage(int destProc, std::vector<int>& message)
{
  std::vector<int>::iterator
   rs_iter = std::lower_bound(remoteSharingProcs_.begin(),
                              remoteSharingProcs_.end(), destProc);
  if (rs_iter == remoteSharingProcs_.end() || destProc != *rs_iter) {
    ERReturn(-1);
  }

  int idx = rs_iter - remoteSharingProcs_.begin();
  int len = 0;
  CHK_ERR( getSendMessageLength(destProc, len) );
  message.resize(len);

  packLocalNodesAndData(&message[0], destProc,
			nodesPerSharingProc_[idx], len);
  return(0);
}
int snl_fei::RecordMsgHandler::getSendMessageLength(int destProc,
						    int& messageLength)
{
  if (sendPattern_ == NULL || recvPattern_ == NULL) ERReturn(-1);

  switch(whichTask_) {
  case _FieldMasks_:
    messageLength = localFieldMaskMessageSize(fieldMasks_);    break;
  case _MaskIDs_:
    messageLength = sendPattern_->getRow(destProc)->size();  break;
  case _EqnNumbers_:
    messageLength = eqnNumbersMsgLength(destProc);  break;
  default:
    std::abort();
  }

  return(0);
}
Exemplo n.º 22
0
int test_MatrixGraph::serialtest1()
{
  int numIDs = 2;
  std::vector<int> idTypes(numIDs, 1);
  std::vector<snl_fei::RecordCollection*> recColls(numIDs, (snl_fei::RecordCollection*)NULL);
  std::vector<int> numFieldsPerID(numIDs, 1);
  std::vector<int> fieldIDs(numIDs, 0);
  std::vector<int> fieldSizes(numIDs, 1);

  fei::Pattern pattern(numIDs, &idTypes[0], &recColls[0],
			   &numFieldsPerID[0], &fieldIDs[0], &fieldSizes[0]);

  fei::Pattern::PatternType pType = pattern.getPatternType();

  if (pType != fei::Pattern::SIMPLE) {
    ERReturn(-1);
  }

  return(0);
}
int snl_fei::RecordMsgHandler::eqnNumbersMsgLength(int destProc)
{
  fei::comm_map::row_type* ids = sendPattern_->getRow(destProc);
  fei::comm_map::row_type::const_iterator
    id_iter = ids->begin(),
    id_end = ids->end();
  int len = ids->size();

  len *= 3;

  for(; id_iter != id_end; ++id_iter) {
    int ID = *id_iter;
    fei::Record<int>* rec = recordCollection_->getRecordWithID(ID);
    if (rec == NULL) {
      ERReturn(-1);
    }

    len += rec->getFieldMask()->getNumIndices();
  }

  return(len);
}
Exemplo n.º 24
0
int fei::Vector_core::assembleFieldData(int fieldID,
					    int idType,
					    int numIDs,
					    const int* IDs,
					    const double* data,
					    bool sumInto,
					    int vectorIndex)
{
  if (vecSpace_.get() == NULL) ERReturn(-1);

  int fieldSize = vecSpace_->getFieldSize(fieldID);

  work_indices_.resize(numIDs*fieldSize);
  int* indicesPtr = &work_indices_[0];

  CHK_ERR( vecSpace_->getGlobalIndices(numIDs, IDs, idType, fieldID,
					indicesPtr) );

  CHK_ERR( giveToVector(numIDs*fieldSize, indicesPtr, data, sumInto, vectorIndex) );

  return(0);
}
Exemplo n.º 25
0
int fei::Vector_core::copyOut(int numValues,
				  const int* indices,
				  double* values,
				  int vectorIndex) const
{
  const std::vector<CSVec*>& remote = remotelyOwned();

  for(int i=0; i<numValues; ++i) {
    int ind = indices[i];

    int local = ind - firstLocalOffset_;
    if (local < 0 || local >= numLocal_) {
      if (ind < 0) {
	continue;
      }

      int proc = eqnComm_->getOwnerProc(ind);

      int insertPoint = -1;
      int idx = fei::binarySearch(ind, remote[proc]->indices(), insertPoint);
      if (idx < 0) {
	FEI_CERR << "fei::Vector_core::copyOut: proc " << fei::localProc(comm_)
	     << ", index " << ind << " not in remotelyOwned_ vec object for proc "
            <<proc<<FEI_ENDL;
	ERReturn(-1);
      }
      else {
	values[i] = remote[proc]->coefs()[idx];
      }
    }
    else {
      CHK_ERR( copyOutOfUnderlyingVector(1, &ind, &(values[i]), vectorIndex) );
    }
  }

  return(0);
}
Exemplo n.º 26
0
int test_LinearSystem::test2()
{
#ifdef HAVE_FEI_AZTECOO
  fei::SharedPtr<testData> testdata(new testData(localProc_, numProcs_));
  std::vector<int>& fieldIDs = testdata->fieldIDs;
  std::vector<int>& idTypes = testdata->idTypes;
  std::vector<int>& ids = testdata->ids;

  fei::SharedPtr<LinearSystemCore> az_lsc(new fei_trilinos::Aztec_LinSysCore(comm_));

  char* param = new char[64];
  sprintf(param,"debugOutput .");

  CHK_ERR( az_lsc->parameters(1, &param) );
  delete [] param;

  fei::SharedPtr<fei::Factory> factory(new snl_fei::Factory(comm_, az_lsc));

  fei::SharedPtr<fei::VectorSpace> vectorSpacePtr =
    test_VectorSpace::create_VectorSpace(comm_,
					 testdata.get(), localProc_, numProcs_,
					 false, false, "U_LS2", factory);

  fei::SharedPtr<fei::MatrixGraph> matrixGraphPtr =
    test_MatrixGraph::create_MatrixGraph(testdata.get(), localProc_, numProcs_,
					 false, false, "U_LS2", vectorSpacePtr,
					 factory, path_);

  std::vector<int> crIDTypes(2);
  std::vector<int> crFieldIDs(2);
  crIDTypes[0] = idTypes[0]; crIDTypes[1] = idTypes[0];
  crFieldIDs[0] = fieldIDs[0]; crFieldIDs[1] = fieldIDs[0];

  CHK_ERR( matrixGraphPtr->initLagrangeConstraint(0, idTypes[1],
						  2, //numIDs
						  &crIDTypes[0],
						  &(ids[1]),
						  &crFieldIDs[0]) );

  CHK_ERR( matrixGraphPtr->initComplete() );

  fei::SharedPtr<fei::Vector> vec_lsc = factory->createVector(vectorSpacePtr);

  fei::SharedPtr<fei::Vector> vec_lsc2 = factory->createVector(vectorSpacePtr, true);

  fei::SharedPtr<fei::Matrix> mat_lsc = factory->createMatrix(matrixGraphPtr);

  fei::SharedPtr<fei::LinearSystem> linsys = factory->createLinearSystem(matrixGraphPtr);
  linsys->setMatrix(mat_lsc);
  linsys->setSolutionVector(vec_lsc2);
  linsys->setRHS(vec_lsc);

  int blockID=0;
  int numIndices = matrixGraphPtr->getConnectivityNumIndices(blockID);

  std::vector<int> indicesArray(numIndices);
  int* indicesPtr = &indicesArray[0];

  int checkNumIndices = 0;
  CHK_ERR( matrixGraphPtr->getConnectivityIndices(blockID, 0,
					     numIndices, indicesPtr,
					     checkNumIndices) );

  std::vector<double> data(ids.size(), 1.0);
  double* dptr = &data[0];
  std::vector<double*> coefPtrs(ids.size());
  std::vector<double> crdata(2);
  crdata[0] = 1.0;
  crdata[1] = -1.0;

  for(unsigned ii=0; ii<ids.size(); ++ii) coefPtrs[ii] = dptr;

  CHK_ERR( mat_lsc->sumIn(numIndices, indicesPtr, numIndices, indicesPtr,
			  &coefPtrs[0]) );

  CHK_ERR( vec_lsc->sumInFieldData(fieldIDs[0], idTypes[0],
				    ids.size(), &ids[0],
				    &data[0]) );

  CHK_ERR( linsys->loadLagrangeConstraint(0, &crdata[0], 0.0) );

  CHK_ERR( mat_lsc->gatherFromOverlap() );

  CHK_ERR( az_lsc->matrixLoadComplete() );

   CHK_ERR( linsys->loadComplete() );

  std::vector<int> crindices;
  linsys->getConstrainedEqns(crindices);
  if (crindices.size() != 2) {
    ERReturn(-7);
  }

  CHK_ERR( az_lsc->writeSystem("U_LS2") );

  MPI_Barrier(comm_);
#endif

  return(0);
}
Exemplo n.º 27
0
int test_Matrix::serialtest3()
{
  testData* testdata = new testData(localProc_, numProcs_);
  std::vector<int>& fieldIDs = testdata->fieldIDs;
  std::vector<int>& fieldSizes = testdata->fieldSizes;
  std::vector<int>& idTypes = testdata->idTypes;
  std::vector<int>& ids = testdata->ids;

  fei::SharedPtr<fei::VectorSpace> vspc(new fei::VectorSpace(comm_, "sU_Mat3"));

  vspc->defineFields(fieldIDs.size(), &fieldIDs[0], &fieldSizes[0]);

  vspc->defineIDTypes(idTypes.size(), &idTypes[0]);

  fei::SharedPtr<fei::MatrixGraph>
    matgraph(new fei::MatrixGraph_Impl2(vspc, vspc, "sU_Mat3"));

  int numIDs = ids.size();
  int fieldID = fieldIDs[0];
  int idType = idTypes[0];

  int patternID = matgraph->definePattern(numIDs, idType, fieldID);

  CHK_ERR( matgraph->initConnectivityBlock(0, 1, patternID) );

  CHK_ERR( matgraph->initConnectivity(0, 0, &ids[0]) );

  //set up a slave constraint that defines id 2, field 0 to be equal to
  //id 1, field 0.
  int offsetOfSlave = 1;
  int offsetIntoSlaveField = 0;
  std::vector<double> weights(2);
  weights[0] = 1.0;
  weights[1] = -1.0;
  double rhsValue = 0.0;
  std::vector<int> cr_idtypes(2, idTypes[0]);
  std::vector<int> cr_fieldIDs(2, fieldIDs[0]);

  CHK_ERR( matgraph->initSlaveConstraint(2, //numIDs
					&cr_idtypes[0],
					&ids[1],
					&cr_fieldIDs[0],
					offsetOfSlave,
					offsetIntoSlaveField,
					&weights[0],
					rhsValue) );

  CHK_ERR( matgraph->initComplete() );

  fei::SharedPtr<fei::FillableMat> ssmat(new fei::FillableMat);
  int localsize = matgraph->getRowSpace()->getNumIndices_Owned();
  localsize -= 1;//subtract the slave
  fei::Matrix* matrix = new fei::Matrix_Impl<fei::FillableMat>(ssmat, matgraph, localsize);

  if (matrix == NULL) {
    ERReturn(-1);
  }

  std::vector<int> indices(numIDs);
  CHK_ERR( matgraph->getConnectivityIndices(0, 0, numIDs,
					   &indices[0], numIDs) );

  std::vector<double> data1(numIDs*numIDs);
  std::vector<double*> data2d(numIDs);

  int i;
  for(i=0; i<numIDs; ++i) {
    data2d[i] = &(data1[i*numIDs]);
  }

  for(i=0; i<numIDs*numIDs; ++i) {
    data1[i] = 1.0*i;
  }

  CHK_ERR( matrix->sumIn(numIDs, &indices[0],
			 numIDs, &indices[0], &data2d[0], 0) );

  CHK_ERR( matrix->sumIn(0, 0, &data2d[0], 0) );

  delete matrix;
  delete testdata;

  return(0);
}
Exemplo n.º 28
0
    int setStructure()
    {
      if (matrixGraph_.get() == NULL) ERReturn(-1);
      if (setStructure_ == true) return(0);

      lookup_ = new fei::Lookup_Impl(matrixGraph_, nodeIDType_);

      CHK_ERR( feData_->setLookup(*lookup_) );

      fei::SharedPtr<fei::VectorSpace> vspace = matrixGraph_->getRowSpace();

      int numLocalNodes = vspace->getNumOwnedAndSharedIDs(nodeIDType_);

      int numElemBlocks = matrixGraph_->getNumConnectivityBlocks();

      int* intData = new int[numElemBlocks*3];
      int* numElemsPerBlock =       intData;
      int* numNodesPerElem =        intData+numElemBlocks;
      int* elemMatrixSizePerBlock = intData+2*numElemBlocks;
      int i;

      std::vector<int> elemBlockIDs;
      CHK_ERR( matrixGraph_->getConnectivityBlockIDs( elemBlockIDs) );

      for(i=0; i<numElemBlocks; ++i) {
        const fei::ConnectivityBlock* cblock =
          matrixGraph_->getConnectivityBlock(elemBlockIDs[i]);
        if (cblock==NULL) return(-1);
        numElemsPerBlock[i] = cblock->getConnectivityIDs().size();
        numNodesPerElem[i] = cblock->getRowPattern()->getNumIDs();
        elemMatrixSizePerBlock[i] = cblock->getRowPattern()->getNumIndices();
      }

      int numSharedNodes = 0;
      CHK_ERR( vspace->getNumSharedIDs(nodeIDType_, numSharedNodes) );

      int numLagrangeConstraints = matrixGraph_->getLocalNumLagrangeConstraints();

      CHK_ERR( feData_->describeStructure(numElemBlocks,
            numElemsPerBlock,
            numNodesPerElem,
            elemMatrixSizePerBlock,
            numLocalNodes,
            numSharedNodes,
            numLagrangeConstraints) );

      std::map<int,fei::ConnectivityBlock*>::const_iterator
        cdb_iter = matrixGraph_->getConnectivityBlocks().begin();

      std::vector<int> nodeNumbers, numDofPerNode, dof_ids;
      int total_num_dof = 0;
      for(i=0; i<numElemBlocks; ++i, ++cdb_iter) {
        fei::ConnectivityBlock* cblock = (*cdb_iter).second;
        fei::Pattern* pattern = cblock->getRowPattern();

        int numConnectedNodes = pattern->getNumIDs();
        nodeNumbers.resize(numConnectedNodes);
        numDofPerNode.resize(numConnectedNodes);
        int* nodeNumPtr = &nodeNumbers[0];
        int* numDofPtr = &numDofPerNode[0];

        //For the calls to FiniteElementData::setConnectivity, we're going to
        //need a list of num-dof-per-node. So construct that now.
        const int* numFieldsPerID = pattern->getNumFieldsPerID();
        const int* fieldIDs = pattern->getFieldIDs();

        int foffset = 0;
        for(int ii=0; ii<numConnectedNodes; ++ii) {
          int dof = 0;
          for(int f=0; f<numFieldsPerID[ii]; ++f) {
            dof += vspace->getFieldSize(fieldIDs[foffset++]);
          }
          numDofPtr[ii] = dof;
          total_num_dof += dof;
        }

        dof_ids.resize(total_num_dof, 0);
        int* dof_ids_ptr = &dof_ids[0];

        ////
        //Next we'll loop over the connectivity-lists in this block,
        //making a call to FiniteElementData::setConnectivity for each one.

        std::map<int,int>& elemIDs = cblock->getConnectivityIDs();
        int numElems = elemIDs.size();
        fei::Record<int>** nodes = &(cblock->getRowConnectivities()[0]);

        int offset = 0;
        for(int elem=0; elem<numElems; ++elem) {
          for(int n=0; n<numConnectedNodes; ++n) {
            fei::Record<int>* node = nodes[offset++];
            nodeNumPtr[n] = node->getNumber();
          }

          CHK_ERR( feData_->setConnectivity(elemBlockIDs[i], elem,
                numConnectedNodes,
                nodeNumPtr, numDofPtr, dof_ids_ptr));
        }//end for(...numElems...)
      }//end for(...numElemBlocks...)

      delete [] intData;

      setStructure_ = true;
      return(0);
    }
Exemplo n.º 29
0
int test_Matrix::test3()
{
#ifdef HAVE_FEI_FETI
  testData* testdata = new testData(localProc_, numProcs_);
  std::vector<int>& idTypes = testdata->idTypes;
  std::vector<int>& ids = testdata->ids;

  fei::SharedPtr<FiniteElementData> fedata(new FETI_DP_FiniteElementData(comm_));

  std::string paramstr("debugOutput .");
  char* param = const_cast<char*>(paramstr.c_str());

  CHK_ERR( fedata->parameters(1, &param) );

  fei::SharedPtr<fei::Factory> factory(new snl_fei::Factory(fedata, idTypes[0]));

  fei::SharedPtr<fei::VectorSpace> vectorSpacePtr =
    test_VectorSpace::create_VectorSpace(comm_,
					 testdata, localProc_, numProcs_,
					 false, false, "U_FEMat", factory);

  fei::SharedPtr<fei::MatrixGraph> matrixGraphPtr =
    test_MatrixGraph::create_MatrixGraph(testdata, localProc_, numProcs_,
					 false, false, "U_FEMat", vectorSpacePtr,
					 factory);

  CHK_ERR( matrixGraphPtr->initComplete() );

  fei::SharedPtr<fei::Vector> vec_fed = factory->createVector(vectorSpacePtr);

  fei::SharedPtr<fei::Matrix> mat_fed = factory->createMatrix(matrixGraphPtr);

  fei::Matrix_Impl<FiniteElementData>* smat2 = 
    dynamic_cast<fei::Matrix_Impl<FiniteElementData>*>(mat_fed.get());
  if (smat2 == NULL) {
    ERReturn(-1);
  }

  int blockID=0;
  int numIndices = matrixGraphPtr->getConnectivityNumIndices(blockID);

  std::vector<int> indicesArray(numIndices);
  int* indicesPtr = &indicesArray[0];

  int checkNumIndices = 0;
  CHK_ERR( matrixGraphPtr->getConnectivityIndices(blockID, 0,
					     numIndices, indicesPtr,
					     checkNumIndices) );

  std::vector<double> data(ids.size(), 1.0);
  double* dptr = &data[0];
  std::vector<double*> coefPtrs(ids.size(), dptr);

  CHK_ERR( mat_fed->sumIn(blockID, 0, &coefPtrs[0]) );

  CHK_ERR( vec_fed->sumIn(blockID, 0, &data[0]) );

  CHK_ERR( mat_fed->gatherFromOverlap() );

  CHK_ERR( fedata->loadComplete() );


  delete testdata;

  MPI_Barrier(comm_);

#endif  //HAVE_FEI_FETI

  return(0);
}
Exemplo n.º 30
0
//==============================================================================
//Here's the main...
//==============================================================================
int main(int argc, char** argv)
{
  MPI_Comm comm;
  int numProcs, localProc;
  CHK_ERR( fei_test_utils::initialize_mpi(argc, argv, localProc, numProcs) );
  comm = MPI_COMM_WORLD;

  std::vector<std::string> stdstrings;
  CHK_ERR( fei_test_utils::get_filename_and_read_input(argc, argv,
						comm, localProc,
						stdstrings) );

  const char** params = NULL;
  int numParams = 0;
  fei::utils::strings_to_char_ptrs(stdstrings, numParams, params);
  
  fei::ParameterSet paramset;
  fei::utils::parse_strings(stdstrings, " ", paramset);

  std::string whichFEI;
  std::string solverName;
  std::string datasource;
  int W = 0;
  int D = 0;
  int DofPerNode = 0;

  int errcode = 0;
  errcode += paramset.getStringParamValue("SOLVER_LIBRARY", solverName);
  errcode += paramset.getStringParamValue("DATA_SOURCE", datasource);
  errcode += paramset.getStringParamValue("WHICH_FEI", whichFEI);
  errcode += paramset.getIntParamValue("W", W);
  errcode += paramset.getIntParamValue("D", D);
  errcode += paramset.getIntParamValue("DofPerNode", DofPerNode);

  if (errcode != 0) {
    fei::console_out() << "Failed to find one or more required parameters in input-file."
	     << std::endl << "Required parameters:"<<std::endl
	     << "SOLVER_LIBRARY" << std::endl
	     << "DATA_SOURCE" << std::endl
	     << "WHICH_FEI" << std::endl
	     << "W" << std::endl << "D" << std::endl << "DofPerNode" << std::endl;
    return(-1);
  }

  HexBeam* hexcubeptr = NULL;
  if (datasource == "HexBeam") {
    hexcubeptr = new HexBeam(W, D, DofPerNode,
			     HexBeam::OneD, numProcs, localProc);
  }
  else {
    hexcubeptr = new HexBeamCR(W, D, DofPerNode,
			       HexBeam::OneD, numProcs, localProc);
  }

  HexBeam& hexcube = *hexcubeptr;

  if (localProc == 0) {
    int numCRs = (W+1)*(W+1)*(numProcs*2)-1;
    if (hexcube.getNumCRs() < 1) numCRs = 0;
    std::cout << std::endl;
    std::cout << "========================================================" 
	 << std::endl;
    std::cout << "Size W: " << W << " (num-elements-along-side-of-cube)"<<std::endl;
    std::cout << "Size D: " << D << " (num-elements-along-depth-of-cube)"<<std::endl;
    std::cout << "DOF per node: " << DofPerNode <<std::endl;
    std::cout << "Num local  elements: " << hexcube.localNumElems_ << std::endl;
    std::cout << "Num global elements: " << hexcube.totalNumElems_ << std::endl;
    std::cout << "Num local  DOF: " << hexcube.numLocalDOF_ << std::endl;
    std::cout << "Num global DOF: " << hexcube.numGlobalDOF_ << std::endl;
    std::cout << "Num global CRs: " << numCRs << std::endl;
    std::cout << "========================================================" 
	 << std::endl;
  }

  double start_init_time = fei::utils::cpu_time();

  //CHK_ERR( print_cube_data(hexcube, numProcs, localProc) );

  fei::SharedPtr<fei::Factory> factory;
  fei::SharedPtr<LibraryWrapper> wrapper;
  fei::SharedPtr<FEI> fei;

  if (whichFEI == "OLDFEI") {
    try {
      wrapper = fei::create_LibraryWrapper(comm, solverName.c_str());
    }
    catch (std::runtime_error& exc) {
      fei::console_out() << exc.what() << std::endl;
      ERReturn(-1);
    }
    fei.reset(new FEI_Implementation(wrapper, comm));
  }
  else if (whichFEI == "fei::FEI_Impl") {
    try {
      factory = fei::create_fei_Factory(comm, solverName.c_str());
    }
    catch (std::runtime_error& exc) {
      fei::console_out() << exc.what() << std::endl;
      ERReturn(-1);
    }
    fei = factory->createFEI(comm);
  }
  else {
    fei::console_out() << "beam ERROR, value of 'WHICH_FEI' must be 'OLDFEI' or 'fei::FEI_Impl'"<< std::endl;
    ERReturn(-1);
  }

  //load some control parameters.
  CHK_ERR( fei->parameters(numParams, params) );

  delete [] params;

  CHK_ERR( fei->setSolveType(FEI_SINGLE_SYSTEM) );

  int fieldID = 0;
  int fieldSize = hexcube.numDofPerNode();

  CHK_ERR( fei->initFields( 1, &fieldSize, &fieldID ) );

  CHK_ERR( HexBeam_Functions::init_elem_connectivities( fei.get(), hexcube ) );

  CHK_ERR( HexBeam_Functions::init_shared_nodes( fei.get(), hexcube ) );

  int firstLocalCRID;
  CHK_ERR( HexBeam_Functions::
	   init_constraints( fei.get(), hexcube, firstLocalCRID) );

  CHK_ERR( fei->initComplete() );

  double fei_init_time = fei::utils::cpu_time() - start_init_time;

  if (localProc == 0) {
    std::cout.setf(IOS_FIXED, IOS_FLOATFIELD);
    std::cout << "Initialization time:   " << fei_init_time << std::endl;
  }

  //Now the initialization phase is complete. Next we'll do the load phase,
  //which for this problem just consists of loading the element data
  //(element-wise stiffness arrays and load vectors) and the boundary
  //condition data.

  double start_load_time = fei::utils::cpu_time();

  CHK_ERR( HexBeam_Functions::load_elem_data(fei.get(), hexcube) );

  CHK_ERR( HexBeam_Functions::load_constraints(fei.get(), hexcube, firstLocalCRID) );

  //std::cout << "calling load_BC_data"<<std::endl;
  //CHK_ERR( load_BC_data(fei, hexcube) );

  fei->loadComplete();

  double fei_load_time = fei::utils::cpu_time() - start_load_time;

  delete hexcubeptr;

  if (localProc == 0) {
    //IOS macros are defined in fei_macros.h
    std::cout.setf(IOS_FIXED, IOS_FLOATFIELD);
    std::cout << "Coef. loading  time:    " << fei_load_time << std::endl;
    std::cout << "Total assembly time:    " << fei_init_time + fei_load_time << std::endl;
  }

  //
  //now the load phase is complete, so we're ready to launch the underlying
  //solver and solve Ax=b
  //

  int err;
  int status;
  double start_solve_time = fei::utils::cpu_time();

  err = fei->solve(status);

  if (err || status) {
    if (localProc==0) std::cout << "solve returned status: " << status << std::endl;
  }

  double solve_time = fei::utils::cpu_time() - start_solve_time;

  if (localProc == 0) {
    std::cout << "Solver time:          " << solve_time << std::endl;
  }

  int returnValue = 0;
  if (localProc == 0) {
#if defined(FEI_PLATFORM) && defined(FEI_OPT_LEVEL)
    double benchmark = fei_init_time;

    FEI_OSTRINGSTREAM testname_init;
    testname_init << "cube_"<<whichFEI<<"_init_"<<W<<"_"<<D<<"_"<<DofPerNode<<"_"
		  <<solverName<<"_np"<<numProcs<<"_"
		  <<FEI_PLATFORM<<"_"<<FEI_OPT_LEVEL;

    FEI_OSTRINGSTREAM testname_load;
    testname_load << "cube_"<<whichFEI<<"_load_"<<W<<"_"<<D<<"_"<<DofPerNode<<"_"
		  <<solverName<<"_np"<<numProcs<<"_"
		  <<FEI_PLATFORM<<"_"<<FEI_OPT_LEVEL;

    double file_init, file_load;
    bool file_benchmarks_available = true;
    try {
      file_init = fei_test_utils::get_file_benchmark("./cube_timings.txt",
					      testname_init.str().c_str());
      file_load = fei_test_utils::get_file_benchmark("./cube_timings.txt",
					      testname_load.str().c_str());
    }
    catch (std::runtime_error& exc) {
      file_benchmarks_available = false;
    }

    if (file_benchmarks_available) {

      bool init_test_passed =
	fei_test_utils::check_and_cout_test_result(testname_init.str(), benchmark,
					    file_init, 10);

      benchmark = fei_load_time;
      bool load_test_passed =
	fei_test_utils::check_and_cout_test_result(testname_load.str(), benchmark,
					    file_load, 10);

      returnValue = init_test_passed&&load_test_passed ? 0 : 1;
    }
#endif
  }

  bool testPassed = returnValue==0;
  if (testPassed && localProc == 0) {
    //A string for the SIERRA runtest tool to search for in test output...
    std::cout << "beam execution successful" << std::endl;
  }

  fei.reset();

#ifndef FEI_SER
  MPI_Finalize();
#endif

  return(0);
}