50 #ifdef HAVE_MUELU_EPETRAEXT 57 typedef double Scalar;
58 typedef int LocalOrdinal;
59 typedef int GlobalOrdinal;
60 typedef KokkosClassic::DefaultNode::DefaultNodeType Node;
62 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_EPETRAEXT) 63 std::string TorE =
"epetra";
65 std::string TorE =
"tpetra";
68 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_EPETRAEXT) 77 #ifdef HAVE_MUELU_TPETRA 78 if (TorE ==
"tpetra") {
83 RCP<Tpetra::CrsMatrix<Scalar, LocalOrdinal, GlobalOrdinal, Node> > A;
84 Tpetra::RowMatrixTransposer<Scalar, LocalOrdinal, GlobalOrdinal, Node> transposer(rcpFromRef(tpetraOp),label);
85 A = transposer.createTranspose();
86 RCP<Xpetra::TpetraCrsMatrix<SC> > AA = rcp(
new Xpetra::TpetraCrsMatrix<SC>(A));
87 RCP<Xpetra::CrsMatrix<SC> > AAA = rcp_implicit_cast<Xpetra::CrsMatrix<SC> >(AA);
88 RCP<Xpetra::CrsMatrixWrap<SC> > AAAA = rcp(
new Xpetra::CrsMatrixWrap<SC> (AAA));
92 catch (std::exception& e) {
93 std::cout <<
"threw exception '" << e.what() <<
"'" << std::endl;
99 if (TorE ==
"tpetra") {
100 #ifdef HAVE_MUELU_TPETRA 103 #endif // HAVE_MUELU_TPETRA 106 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_EPETRAEXT) 107 Teuchos::TimeMonitor tm(*Teuchos::TimeMonitor::getNewTimer(
"ZZ Entire Transpose"));
111 Epetra_CrsMatrix * A =
dynamic_cast<Epetra_CrsMatrix*
>(&transposer(epetraOp));
114 RCP<Epetra_CrsMatrix> rcpA(A);
115 RCP<EpetraCrsMatrix> AA = rcp(
new EpetraCrsMatrix(rcpA));
116 RCP<Xpetra::CrsMatrix<SC> > AAA = rcp_implicit_cast<Xpetra::CrsMatrix<SC> >(AA);
117 RCP<Xpetra::CrsMatrixWrap<SC> > AAAA = rcp(
new Xpetra::CrsMatrixWrap<SC>(AAA));
118 AAAA->fillComplete(Op.getRangeMap(), Op.getDomainMap());
125 return Teuchos::null;
132 bool doOptimizeStorage) {
133 #ifdef HAVE_MUELU_EPETRA 137 Epetra_Map
const &rowMap = epOp.RowMap();
142 for (
int i = 0; i < rowMap.NumMyElements(); ++i) {
143 epOp.ExtractMyRowView(i, nnz, vals, cols);
144 for (
int j = 0; j < nnz; ++j)
145 vals[j] *= scalingVector[i];
153 #endif // HAVE_MUELU_EPETRA 159 Xpetra::UnderlyingLib lib = map->lib();
161 if (lib == Xpetra::UseEpetra) {
162 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_EPETRAEXT) 163 Epetra_MultiVector * MV;
165 return Xpetra::toXpetra<int>(rcp(MV));
169 }
else if (lib == Xpetra::UseTpetra) {
170 #ifdef HAVE_MUELU_TPETRA 171 typedef Tpetra::CrsMatrix<SC,LO,GO,NO> sparse_matrix_type;
172 typedef Tpetra::MatrixMarket::Reader<sparse_matrix_type> reader_type;
173 typedef Tpetra::Map<LO,GO,NO> map_type;
174 typedef Tpetra::MultiVector<SC,LO,GO,NO> multivector_type;
176 RCP<const map_type> temp = toTpetra(map);
177 RCP<multivector_type> TMV = reader_type::readDenseFile(fileName,map->getComm(),map->getNode(),temp);
178 RCP<MultiVector> rmv = Xpetra::toXpetra(TMV);
187 return Teuchos::null;
191 if (lib == Xpetra::UseEpetra) {
192 #if defined(HAVE_MUELU_EPETRA) && defined(HAVE_MUELU_EPETRAEXT) 198 RCP<Epetra_Map> eMap1 = rcp(
new Epetra_Map(*eMap));
199 return Xpetra::toXpetra<int>(*eMap1);
203 }
else if (lib == Xpetra::UseTpetra) {
204 #ifdef HAVE_MUELU_TPETRA 205 typedef Tpetra::CrsMatrix<double,int,int,NO> sparse_matrix_type;
206 typedef Tpetra::MatrixMarket::Reader<sparse_matrix_type> reader_type;
208 RCP<NO> node = rcp(
new NO());
210 RCP<const Tpetra::Map<int,int,NO> > tMap = reader_type::readMapFile(fileName, comm, node);
214 return Xpetra::toXpetra(tMap);
230 long ExtractNonSerializableData(
const Teuchos::ParameterList& inList, Teuchos::ParameterList& serialList, Teuchos::ParameterList& nonSerialList) {
231 using Teuchos::ParameterList;
236 for (ParameterList::ConstIterator it = inList.begin(); it != inList.end(); it++) {
237 const std::string& levelName = it->first;
240 if (inList.isSublist(levelName) && levelName.find(
"level ") == 0 && levelName.size() > 6) {
241 int levelID = strtol(levelName.substr(6).c_str(), 0, 0);
242 if (maxLevel < levelID)
246 const ParameterList& levelList = inList.sublist(levelName);
247 for (ParameterList::ConstIterator it2 = levelList.begin(); it2 != levelList.end(); it2++) {
248 const std::string& name = it2->first;
249 if (name ==
"A" || name ==
"P" || name ==
"R" || name ==
"Nullspace" || name ==
"Coordinates")
250 nonSerialList.sublist(levelName).setEntry(name, it2->second);
251 #ifdef HAVE_MUELU_MATLAB 254 nonSerialList.sublist(levelName).setEntry(name, it2->second);
258 serialList.sublist(levelName).setEntry(name, it2->second);
262 serialList.setEntry(it->first, it->second);
273 char* buf = (
char*) malloc(stream.size() + 1);
274 strcpy(buf, stream.c_str());
275 char* token = strtok(buf, delimChars);
285 char* tokStart = token;
286 char* tokEnd = token + strlen(token) - 1;
287 while(*tokStart ==
' ' && tokStart < tokEnd)
289 while(*tokEnd ==
' ' && tokStart < tokEnd)
292 if(tokStart < tokEnd)
294 std::string finishedToken(tokStart, tokEnd - tokStart);
295 tokenList.push_back(finishedToken);
297 token = strtok(NULL, delimChars);
305 char* str = (
char*) malloc(name.length() + 1);
306 strcpy(str, name.c_str());
308 char* firstWord = strtok(str,
" ");
311 char* secondWord = strtok(NULL,
" ");
314 char* thirdWord = strtok(NULL,
" ");
318 char* tolowerIt = firstWord;
321 *tolowerIt = (char) tolower(*tolowerIt);
325 if(strstr(firstWord,
"matrix") ||
326 strstr(firstWord,
"multivector") ||
327 strstr(firstWord,
"map") ||
328 strstr(firstWord,
"ordinalvector") ||
329 strstr(firstWord,
"int") ||
330 strstr(firstWord,
"scalar") ||
331 strstr(firstWord,
"double") ||
332 strstr(firstWord,
"complex") ||
333 strstr(firstWord,
"string"))
std::string toString(const T &what)
Little helper function to convert non-string types to strings.
int MatrixMarketFileToMultiVector(const char *filename, const Epetra_BlockMap &map, Epetra_MultiVector *&A)
static RCP< Matrix > Transpose(Matrix &Op, bool optimizeTranspose=false, const std::string &label=std::string())
Transpose a Xpetra::Matrix.
KokkosClassic::DefaultNode::DefaultNodeType NO
Namespace for MueLu classes and methods.
bool IsParamMuemexVariable(const std::string &name)
static void MyOldScaleMatrix_Epetra(Matrix &Op, const Teuchos::ArrayRCP< SC > &scalingVector, bool doFillComplete, bool doOptimizeStorage)
Scale an Epetra matrix.
int MatrixMarketFileToMap(const char *filename, const Epetra_Comm &comm, Epetra_Map *&map)
static RCP< const Epetra_CrsMatrix > Op2EpetraCrs(RCP< const Matrix > Op)
static RCP< const Tpetra::CrsMatrix< SC, LO, GO, NO > > Op2TpetraCrs(RCP< const Matrix > Op)
Xpetra::Matrix< double, int, int, NO > Matrix
static RCP< const Map > ReadMap(const std::string &fileName, Xpetra::UnderlyingLib lib, const RCP< const Teuchos::Comm< int > > &comm)
static RCP< MultiVector > ReadMultiVector(const std::string &fileName, const RCP< const Map > &map)
Exception throws to report errors in the internal logical of the program.
static RCP< Epetra_CrsMatrix > Op2NonConstEpetraCrs(RCP< Matrix > Op)
void TokenizeStringAndStripWhiteSpace(const std::string &stream, std::vector< std::string > &tokenList, const char *delimChars)
long ExtractNonSerializableData(const Teuchos::ParameterList &inList, Teuchos::ParameterList &serialList, Teuchos::ParameterList &nonSerialList)