bool tEpetraThyraConverter::test_blockThyraToEpetra(int verbosity,std::ostream & os)
{
   bool status;
   bool allPassed = true;

   const Epetra_Comm & Comm = *GetComm();
   const RCP<const Teuchos::Comm<Teuchos::Ordinal> > tComm = Thyra::create_Comm(rcpFromRef(Comm));

   // get process information
   int numProc = Comm.NumProc();
   // int myPID   = Comm.MyPID();

   // how big is this vector
   int myElmts = 1000;
   int glElmts = myElmts*numProc;

   // build vector space
   const RCP<const Thyra::VectorSpaceBase<double> > vs
         = Thyra::defaultSpmdVectorSpace<double>(tComm,myElmts,glElmts); 
   const RCP<const Thyra::VectorSpaceBase<double> > prodVS = Thyra::productVectorSpace(vs,2); 

   // from the vector space build an epetra map
   TEST_MSG("\n   1. creating Map");
   const RCP<const Epetra_Map> map = Teko::Epetra::thyraVSToEpetraMap(*prodVS,rcpFromRef(Comm));

   // create a vector
   const RCP<Thyra::MultiVectorBase<double> > tX = Thyra::createMembers<double>(prodVS,5);
   Thyra::randomize<double>(-10.0,10.0,tX.ptr()); 

   TEST_MSG("   2. creating MultiVector");

   const RCP<Epetra_MultiVector> eX = rcp(new Epetra_MultiVector(*map,5));
   TEST_MSG("   3. calling blockThyraToEpetra");
   Teko::Epetra::blockThyraToEpetra(tX,*eX);

   TEST_ASSERT(eX!=Teuchos::null,
            "\n   tEpetraThyraConverter::test_blockThyraToEpetra " << toString(status) 
         << ": blockThyraToEpetra returns not null");

   TEST_MSG("   4. comparing Epetra to Thyra");
   double result = compareEpetraMVToThyra(*eX,tX,verbosity,os);
   TEST_ASSERT(result==0.0,
            "\n   tEpetraThyraConverter::test_blockThyraToEpetra: " << toString(status) 
         << ": Epetra MV is compared to Thyra MV (maxdiff = " << result << ")");

   return allPassed;
}
bool tEpetraThyraConverter::test_single_blockEpetraToThyra(int verbosity, std::ostream & os)
{
   bool status;
   bool allPassed = true;

   const Epetra_Comm & Comm = *GetComm();
   const RCP<const Teuchos::Comm<Teuchos::Ordinal> > tComm = Thyra::create_Comm(rcpFromRef(Comm));
 
   // get process information
   int numProc = Comm.NumProc();
   // int myPID   = Comm.MyPID();

   // how big is this vector
   int myElmts = 1000;
   int glElmts = myElmts*numProc;

   // build vector space
   const RCP<const Thyra::VectorSpaceBase<double> > vs
         = Thyra::defaultSpmdVectorSpace<double>(tComm,myElmts,glElmts); 
   const RCP<const Thyra::VectorSpaceBase<double> > prodVS = vs;
 
   // from the vector space build an epetra map
   const RCP<const Epetra_Map> map = Teko::Epetra::thyraVSToEpetraMap(*prodVS,rcpFromRef(Comm));
   
   // build an epetra multivector 
   int vecs = 10;
   Epetra_MultiVector eX(*map,vecs);
   eX.Random();

   // build a Thyra copy of this Epetra_MultiVector
   const RCP<Thyra::MultiVectorBase<double> >  tX = Thyra::createMembers(prodVS,eX.NumVectors());
   Teko::Epetra::blockEpetraToThyra(eX,tX.ptr());

   TEST_ASSERT(tX!=Teuchos::null,
            "\n   tEpetraThyraConverter::test_single_blockEpetraToThyra: " << toString(status) 
         << ": blockEpetraToThyra returns not null");

   double result = compareEpetraMVToThyra(eX,tX,verbosity,os);
   TEST_ASSERT(result==0.0,
            "\n   tEpetraThyraConverter::test_single_blockEpetraToThyra: " << toString(status) 
         << ": Epetra MV is compared to Thyra MV (maxdiff = " << result << ")");

   return allPassed;
}
Example #3
0
static void SendData(char *file)
{
    DataFile = fopen(file, "r");
    bool error = mfalse;

    done = mfalse;
    everError = mfalse;
    
    if (DataFile == NULL)
    {
	LogMsg(0,LogLevel,LogFile,"Could not Open %s for reading",file);
	done = mtrue;
	error = mtrue;
    }
    
    int recordCounts[dataClass_last_tag];
    for (int i=0;i<dataClass_last_tag;i++)
	recordCounts[i] = 0;

    long rt;
    long count;
    while (done == mfalse) {
	count = ScanPastMagicNumber(&rt);
	if (count > 0) {
	    LogMsg(0,LogLevel,LogFile,
		   "Out of sync with data file: %d words skipped to next sync point",
		   count);
	    everError = mtrue;
	    LogErrorPoint(recordCounts);
	} else if (count < 0) {
	    LogMsg(0,LogLevel,LogFile,"End of data file");
	    LogErrorPoint(recordCounts);
	}
	switch(rt) {
	case -1:
	    done = mtrue;
	    break;
	case SESSION_TAG:
	    GetSession(&error);
	    recordCounts[SESSION]++;
	    break;    
	case COMM_TAG:
	    GetComm(&error);
	    recordCounts[COMM]++;
	    break;
	case CLNTCALL_TAG:
	    GetClientCall(&error);
	    recordCounts[CLNTCALL]++;
	    break;
	case CLNTMCALL_TAG:
	    GetClientMCall(&error);
	    recordCounts[CLNTMCALL]++;
	    break;
	case CLNTRVM_TAG:
	    GetClientRVM(&error);
	    recordCounts[CLNTRVM]++;
	    break;
	case VCB_TAG:
	    GetVCB(&error);
	    recordCounts[VCB]++;
	    break;
	case ADVICE_TAG:
	    GetAdvice(&error);
	    recordCounts[ADVICE]++;
	    break;
	case MINICACHE_TAG:
	    GetMiniCache(&error);
	    recordCounts[MINICACHE]++;
	    break;
	case OVERFLOW_TAG:
	    GetOverflow(&error);
	    recordCounts[OVERFLOW]++;
	    break;
	case SRVCALL_TAG:
	    GetSrvCall(&error);
	    recordCounts[SRVCALL]++;
	    break;
	case SRVRES_TAG:
	    GetResEvent(&error);
	    recordCounts[SRVRES]++;
	    break;
	case SRVRVMRES_TAG:
	    GetRvmResEvent(&error);
	    recordCounts[SRVRVMRES]++;
	    break;
	case SRVOVRFLW_TAG:
	    GetSrvOverflow(&error);
	    recordCounts[SRVOVRFLW]++;
	    break;
	case IOTINFO_TAG:
	    GetIotInfo(&error);
	    recordCounts[IOTINFO]++;
	    break;
	case IOTSTAT_TAG:
	    GetIotStats(&error);
	    recordCounts[IOTSTAT]++;
	    break;
	case SUBTREE_TAG:
	    GetSubtree(&error);
	    recordCounts[SUBTREE]++;
	    break;
	case REPAIR_TAG:
	    GetRepair(&error);
	    recordCounts[REPAIR]++;
	    break;
	case RWSSTAT_TAG:
	    GetRwsStats(&error);
	    recordCounts[RWSSTAT]++;
	    break;
	default:
	    LogMsg(1,LogLevel,LogFile,"main: bogus rt (%d)", rt);
	    error = mtrue;
	}
	if (error == mtrue) {
	    everError = mtrue;
	    LogErrorPoint(recordCounts);
	    error = mfalse;
	}
    }
    fclose(DataFile);
    if (everError == mfalse) 
    {
	if (removeOnDone == mtrue)
	{
	    if (unlink(file))
		LogMsg(0,LogLevel,LogFile,"Could not unlink %s, but spooled it with no errors",
		       file);
	}
    } else
	LogMsg(0,LogLevel,LogFile,"Error spooling file %s",file);
}