• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

MOR_EpetraMVDenseMatrixView.cpp

Go to the documentation of this file.
00001 //*****************************************************************//
00002 //    Albany 2.0:  Copyright 2012 Sandia Corporation               //
00003 //    This Software is released under the BSD license detailed     //
00004 //    in the file "license.txt" in the top-level Albany directory  //
00005 //*****************************************************************//
00006 
00007 #include "MOR_EpetraMVDenseMatrixView.hpp"
00008 
00009 #include "Epetra_MultiVector.h"
00010 
00011 #include "Epetra_SerialDenseMatrix.h"
00012 #include "Epetra_SerialSymDenseMatrix.h"
00013 
00014 #include "Epetra_Comm.h"
00015 
00016 #include "Teuchos_TestForException.hpp"
00017 
00018 namespace MOR {
00019 
00020 namespace { // anonymous
00021 
00022 bool any(const Epetra_Comm &comm, bool localCondition) {
00023   int localValue = static_cast<int>(localCondition);
00024   int result;
00025   comm.MaxAll(&localValue, &result, 1);
00026   return result;
00027 }
00028 
00029 bool all(const Epetra_Comm &comm, bool localCondition) {
00030   int localValue = static_cast<int>(localCondition);
00031   int result;
00032   comm.MinAll(&localValue, &result, 1);
00033   return result;
00034 }
00035 
00036 } // end anonymous namespace
00037 
00038 Epetra_SerialDenseMatrix localDenseMatrixView(Epetra_MultiVector &mv) {
00039   double *values;
00040   int localLeadDim;
00041   mv.ExtractView(&values, &localLeadDim);
00042   return Epetra_SerialDenseMatrix(View, values, localLeadDim, mv.MyLength(), mv.NumVectors());
00043 }
00044 
00045 Epetra_SerialSymDenseMatrix localSymDenseMatrixView(Epetra_MultiVector &mv) {
00046   const int matrixSize = mv.NumVectors();
00047   TEUCHOS_TEST_FOR_EXCEPT(any(mv.Comm(), matrixSize != mv.MyLength()));
00048   double *values;
00049   int localLeadDim;
00050   mv.ExtractView(&values, &localLeadDim);
00051   return Epetra_SerialSymDenseMatrix(View, values, localLeadDim, matrixSize);
00052 }
00053 
00054 } // namespace MOR

Generated on Wed Mar 26 2014 18:36:40 for Albany: a Trilinos-based PDE code by  doxygen 1.7.1