43 #ifndef __Panzer_STK_SetupLOWSFactory_impl_hpp__
44 #define __Panzer_STK_SetupLOWSFactory_impl_hpp__
46 #include "PanzerAdaptersSTK_config.hpp"
50 #include "Teuchos_AbstractFactoryStd.hpp"
52 #include "Stratimikos_DefaultLinearSolverBuilder.hpp"
54 #include "Epetra_MpiComm.h"
55 #include "Epetra_Vector.h"
60 #include "Tpetra_Map.hpp"
61 #include "Tpetra_MultiVector.hpp"
63 #ifdef PANZER_HAVE_TEKO
64 #include "Teko_StratimikosFactory.hpp"
67 #ifdef PANZER_HAVE_MUELU
68 #include <Thyra_MueLuPreconditionerFactory.hpp>
69 #include <Thyra_MueLuRefMaxwellPreconditionerFactory.hpp>
70 #include "Stratimikos_MueLuHelpers.hpp"
71 #include "MatrixMarket_Tpetra.hpp"
72 #include "Xpetra_MapFactory.hpp"
73 #include "Xpetra_MultiVectorFactory.hpp"
76 #ifdef PANZER_HAVE_IFPACK2
77 #include <Thyra_Ifpack2PreconditionerFactory.hpp>
87 std::vector<std::string> elementBlocks;
91 std::set<int> runningFields;
94 runningFields.insert(fields.begin(),fields.end());
98 for(std::size_t i=1;i<elementBlocks.size();i++) {
101 std::set<int> currentFields(runningFields);
102 runningFields.clear();
103 std::set_intersection(fields.begin(),fields.end(),
104 currentFields.begin(),currentFields.end(),
105 std::inserter(runningFields,runningFields.begin()));
108 if(runningFields.size()<1)
115 template<
typename GO>
118 const std::string & fieldName,
121 std::vector<std::string> elementBlocks;
124 for(std::size_t e=0;e<elementBlocks.size();e++) {
125 std::string blockId = elementBlocks[e];
128 fieldPatterns[blockId] =
129 Teuchos::rcp_dynamic_cast<const panzer::Intrepid2FieldPattern>(globalIndexer.
getFieldPattern(blockId,fieldName),
true);
135 const std::string & fieldName,
139 using Teuchos::ptrFromRef;
140 using Teuchos::ptr_dynamic_cast;
145 Ptr<const DOFManager<int,int> > dofManager = ptr_dynamic_cast<
const DOFManager<int,int> >(ptrFromRef(globalIndexer));
147 if(dofManager!=Teuchos::null) {
148 fillFieldPatternMap(*dofManager,fieldName,fieldPatterns);
153 Ptr<const DOFManager<int,panzer::Ordinal64> > dofManager = ptr_dynamic_cast<
const DOFManager<int,panzer::Ordinal64> >(ptrFromRef(globalIndexer));
155 if(dofManager!=Teuchos::null) {
156 fillFieldPatternMap(*dofManager,fieldName,fieldPatterns);
163 template<
typename GO>
171 #ifdef PANZER_HAVE_TEKO
174 bool writeCoordinates,
182 using Teuchos::rcp_dynamic_cast;
184 Stratimikos::DefaultLinearSolverBuilder linearSolverBuilder;
190 #ifdef PANZER_HAVE_MUELU
193 Stratimikos::enableMueLu(linearSolverBuilder,
"MueLu");
194 Stratimikos::enableMueLuRefMaxwell(linearSolverBuilder,
"MueLuRefMaxwell");
195 Stratimikos::enableMueLu<int,panzer::Ordinal64,panzer::TpetraNodeType>(linearSolverBuilder,
"MueLu-Tpetra");
196 Stratimikos::enableMueLuRefMaxwell<int,panzer::Ordinal64,panzer::TpetraNodeType>(linearSolverBuilder,
"MueLuRefMaxwell-Tpetra");
199 #ifdef PANZER_HAVE_IFPACK2
202 typedef Thyra::Ifpack2PreconditionerFactory<Tpetra::CrsMatrix<double, int, panzer::Ordinal64,panzer::TpetraNodeType> > Impl;
204 linearSolverBuilder.setPreconditioningStrategyFactory(Teuchos::abstractFactoryStd<Base, Impl>(),
"Ifpack2");
209 #ifdef PANZER_HAVE_TEKO
212 if(!blockedAssembly) {
214 std::string fieldName;
219 if(reqHandler_local==Teuchos::null)
220 reqHandler_local =
rcp(
new Teko::RequestHandler);
223 if(determineCoordinateField(*globalIndexer,fieldName)) {
224 std::map<std::string,RCP<const panzer::Intrepid2FieldPattern> > fieldPatterns;
225 fillFieldPatternMap(*globalIndexer,fieldName,fieldPatterns);
228 panzer_stk::ParameterListCallback<int,GO>(fieldName,fieldPatterns,stkConn_manager,
230 reqHandler_local->addRequestCallback(callback);
287 if(writeCoordinates) {
292 const std::vector<double> & xcoords = callback->getXCoordsVector();
293 const std::vector<double> & ycoords = callback->getYCoordsVector();
294 const std::vector<double> & zcoords = callback->getZCoordsVector();
320 #ifdef PANZER_HAVE_MUELU
323 if(!writeCoordinates)
326 typedef Tpetra::Map<int,panzer::Ordinal64,panzer::TpetraNodeType> Map;
327 typedef Tpetra::MultiVector<double,int,panzer::Ordinal64,panzer::TpetraNodeType> MV;
330 unsigned dim = Teuchos::as<unsigned>(spatialDim);
332 for(
unsigned d=0;d<dim;d++) {
333 const std::vector<double> & coord = callback->getCoordsVector(d);
336 if(coords==Teuchos::null) {
340 std::vector<panzer::Ordinal64> ownedIndices;
341 ugi->getOwnedIndices(ownedIndices);
343 coords =
rcp(
new MV(coords_map,dim));
347 coords =
rcp(
new MV(coords_map,dim));
356 for(std::size_t i=0;i<coord.size();i++)
362 muelu_params.
set<
RCP<MV> >(
"Coordinates",coords);
368 Teko::addTekoToStratimikosBuilder(linearSolverBuilder,reqHandler_local);
372 if(reqHandler_local==Teuchos::null)
373 reqHandler_local =
rcp(
new Teko::RequestHandler);
375 std::string fieldName;
376 if(determineCoordinateField(*globalIndexer,fieldName)) {
382 rcp(
new panzer_stk::ParameterListCallbackBlocked<int,GO>(stkConn_manager,blkDofs,auxBlkDofs));
383 reqHandler_local->addRequestCallback(callback);
386 Teko::addTekoToStratimikosBuilder(linearSolverBuilder,reqHandler_local);
388 if(writeCoordinates) {
393 const std::vector<RCP<panzer::UniqueGlobalIndexer<int,GO> > > & dofVec
394 = blkDofs->getFieldDOFManagers();
395 for(std::size_t i=0;i<dofVec.size();i++) {
396 std::string fieldName;
401 std::map<std::string,RCP<const panzer::Intrepid2FieldPattern> > fieldPatterns;
402 fillFieldPatternMap(*dofVec[i],fieldName,fieldPatterns);
403 panzer_stk::ParameterListCallback<int,GO> plCall(fieldName,fieldPatterns,stkConn_manager,dofVec[i]);
404 plCall.buildArrayToVector();
405 plCall.buildCoordinates();
408 const std::vector<double> & xcoords = plCall.getXCoordsVector();
409 const std::vector<double> & ycoords = plCall.getYCoordsVector();
410 const std::vector<double> & zcoords = plCall.getZCoordsVector();
436 #ifdef PANZER_HAVE_MUELU
439 typedef Xpetra::Map<int,GO> Map;
440 typedef Xpetra::MultiVector<double,int,GO> MV;
443 RCP<const Map> coords_map = Xpetra::MapFactory<int,GO>::Build(Xpetra::UseEpetra,
451 unsigned dim = Teuchos::as<unsigned>(spatialDim);
453 RCP<MV> coords = Xpetra::MultiVectorFactory<double,int,GO>::Build(coords_map,spatialDim);
455 for(
unsigned d=0;d<dim;d++) {
461 for(std::size_t i=0;i<coords->getLocalLength();i++) {
462 if (d == 0) dest[i] = xcoords[i];
463 if (d == 1) dest[i] = ycoords[i];
464 if (d == 2) dest[i] = zcoords[i];
471 muelu_params.
set<
RCP<MV> >(
"Coordinates",coords);
487 "Topology writing is no longer implemented. It needs to be reimplemented for the "
488 "default DOFManager (estimate 2 days with testing)");
493 linearSolverBuilder.setParameterList(strat_params);