43#ifndef __Panzer_BlockedEpetraLinearObjFactory_impl_hpp__
44#define __Panzer_BlockedEpetraLinearObjFactory_impl_hpp__
48#include "Epetra_CrsMatrix.h"
49#include "Epetra_MpiComm.h"
50#include "Epetra_MultiVector.h"
51#include "Epetra_Vector.h"
67#include "Thyra_DefaultBlockedLinearOp.hpp"
68#include "Thyra_DefaultProductVector.hpp"
69#include "Thyra_DefaultProductVectorSpace.hpp"
70#include "Thyra_EpetraLinearOp.hpp"
71#include "Thyra_EpetraThyraWrappers.hpp"
72#include "Thyra_get_Epetra_Operator.hpp"
73#include "Thyra_SpmdVectorBase.hpp"
74#include "Thyra_VectorStdOps.hpp"
84template <
typename Traits,
typename LocalOrdinalT>
87 const Teuchos::RCP<const GlobalIndexer> & gidProvider,
88 bool useDiscreteAdjoint)
107template <
typename Traits,
typename LocalOrdinalT>
110 const Teuchos::RCP<const GlobalIndexer> & gidProvider,
111 const Teuchos::RCP<const GlobalIndexer> & colGidProvider,
112 bool useDiscreteAdjoint)
133template <
typename Traits,
typename LocalOrdinalT>
140template <
typename Traits,
typename LocalOrdinalT>
146 using Teuchos::rcp_dynamic_cast;
147 using Teuchos::dyn_cast;
153 RCP<Thyra::VectorBase<double> > vec;
165 TEUCHOS_ASSERT(
false);
170 RCP<ProductVectorBase<double> > b_vec = Thyra::nonconstProductVectorBase(vec);
173 for(
int i=0;i<blockRows;i++) {
174 RCP<Thyra::VectorBase<double> > x = b_vec->getNonconstVectorBlock(i);
175 RCP<Epetra_Vector> ex = Thyra::get_Epetra_Vector(*
getMap(i),x);
178 std::stringstream ss;
179 ss << identifier <<
"-" << i <<
".mm";
190template <
typename Traits,
typename LocalOrdinalT>
196 using Teuchos::rcp_dynamic_cast;
197 using Teuchos::dyn_cast;
203 RCP<const Thyra::VectorBase<double> > vec;
215 TEUCHOS_ASSERT(
false);
220 RCP<const ProductVectorBase<double> > b_vec = Thyra::productVectorBase(vec);
223 for(
int i=0;i<blockRows;i++) {
224 RCP<const Thyra::VectorBase<double> > x = b_vec->getVectorBlock(i);
225 RCP<const Epetra_Vector> ex = Thyra::get_Epetra_Vector(*
getMap(i),x);
228 std::stringstream ss;
229 ss << identifier <<
"-" << i <<
".mm";
236template <
typename Traits,
typename LocalOrdinalT>
246 std::vector<Teuchos::RCP<const Epetra_Map> > blockMaps;
248 for(std::size_t i=0;i<blockDim;i++)
249 blockMaps.push_back(
getMap(i));
252 container->setMapsForBlocks(blockMaps);
257template <
typename Traits,
typename LocalOrdinalT>
267 std::vector<Teuchos::RCP<const Epetra_Map> > blockMaps;
269 for(std::size_t i=0;i<blockDim;i++)
273 container->setMapsForBlocks(blockMaps);
278template <
typename Traits,
typename LocalOrdinalT>
282 using Teuchos::is_null;
294 if ( !is_null(e_in.
get_x()) && !is_null(e_out.
get_x()) && ((mem & LOC::X)==LOC::X))
297 if ( !is_null(e_in.
get_dxdt()) && !is_null(e_out.
get_dxdt()) && ((mem & LOC::DxDt)==LOC::DxDt))
300 if ( !is_null(e_in.
get_f()) && !is_null(e_out.
get_f()) && ((mem & LOC::F)==LOC::F))
304 const BLOC & b_in = Teuchos::dyn_cast<const BLOC>(in);
305 BLOC & b_out = Teuchos::dyn_cast<BLOC>(out);
309 if ( !is_null(b_in.get_x()) && !is_null(b_out.get_x()) && ((mem & LOC::X)==LOC::X))
312 if ( !is_null(b_in.get_dxdt()) && !is_null(b_out.get_dxdt()) && ((mem & LOC::DxDt)==LOC::DxDt))
315 if ( !is_null(b_in.get_f()) && !is_null(b_out.get_f()) && ((mem & LOC::F)==LOC::F))
320template <
typename Traits,
typename LocalOrdinalT>
324 using Teuchos::is_null;
336 if ( !is_null(e_in.
get_x()) && !is_null(e_out.
get_x()) && ((mem & LOC::X)==LOC::X))
339 if ( !is_null(e_in.
get_f()) && !is_null(e_out.
get_f()) && ((mem & LOC::F)==LOC::F))
342 if ( !is_null(e_in.
get_A()) && !is_null(e_out.
get_A()) && ((mem & LOC::Mat)==LOC::Mat))
346 const BLOC & b_in = Teuchos::dyn_cast<const BLOC>(in);
347 BLOC & b_out = Teuchos::dyn_cast<BLOC>(out);
351 if ( !is_null(b_in.get_x()) && !is_null(b_out.get_x()) && ((mem & LOC::X)==LOC::X))
354 if ( !is_null(b_in.get_f()) && !is_null(b_out.get_f()) && ((mem & LOC::F)==LOC::F))
357 if ( !is_null(b_in.get_A()) && !is_null(b_out.get_A()) && ((mem & LOC::Mat)==LOC::Mat))
362template <
typename Traits,
typename LocalOrdinalT>
367 bool zeroVectorRows,
bool adjustX)
const
372 using Teuchos::rcp_dynamic_cast;
374 using Thyra::PhysicallyBlockedLinearOpBase;
377 using Thyra::get_Epetra_Vector;
378 using Thyra::get_Epetra_Operator;
384 const TOC & b_localBCRows = Teuchos::dyn_cast<const TOC>(localBCRows);
385 const TOC & b_globalBCRows = Teuchos::dyn_cast<const TOC>(globalBCRows);
386 TOC & b_ghosted = Teuchos::dyn_cast<TOC>(ghostedObjs);
388 TEUCHOS_ASSERT(b_localBCRows.get_f_th()!=Teuchos::null);
389 TEUCHOS_ASSERT(b_globalBCRows.get_f_th()!=Teuchos::null);
392 RCP<PhysicallyBlockedLinearOpBase<double> > A = rcp_dynamic_cast<PhysicallyBlockedLinearOpBase<double> >(b_ghosted.get_A_th());
393 if(A==Teuchos::null && b_ghosted.get_A_th()!=Teuchos::null) {
395 A = rcp_dynamic_cast<PhysicallyBlockedLinearOpBase<double> >(Thyra::nonconstBlock1x1(b_ghosted.get_A_th()));
398 RCP<ProductVectorBase<double> > f = b_ghosted.get_f_th()==Teuchos::null
400 : Thyra::castOrCreateNonconstProductVectorBase(b_ghosted.get_f_th());
401 RCP<ProductVectorBase<double> > local_bcs = b_localBCRows.get_f_th()==Teuchos::null
403 : Thyra::castOrCreateNonconstProductVectorBase(b_localBCRows.get_f_th());
404 RCP<ProductVectorBase<double> > global_bcs = b_globalBCRows.get_f_th()==Teuchos::null
406 : Thyra::castOrCreateNonconstProductVectorBase(b_globalBCRows.get_f_th());
408 if(adjustX) f = Thyra::castOrCreateNonconstProductVectorBase(b_ghosted.get_x_th());
411 if(A!=Teuchos::null) TEUCHOS_ASSERT(A->productRange()->numBlocks()==rBlockDim);
412 if(A!=Teuchos::null) TEUCHOS_ASSERT(A->productDomain()->numBlocks()==cBlockDim);
413 if(f!=Teuchos::null) TEUCHOS_ASSERT(f->productSpace()->numBlocks()==rBlockDim);
414 TEUCHOS_ASSERT(local_bcs->productSpace()->numBlocks()==rBlockDim);
415 TEUCHOS_ASSERT(global_bcs->productSpace()->numBlocks()==rBlockDim);
417 for(
int i=0;i<rBlockDim;i++) {
419 RCP<const Epetra_Vector> e_local_bcs = get_Epetra_Vector(*
getGhostedMap(i),local_bcs->getVectorBlock(i));
420 RCP<const Epetra_Vector> e_global_bcs = get_Epetra_Vector(*
getGhostedMap(i),global_bcs->getVectorBlock(i));
423 RCP<VectorBase<double> > th_f = (f==Teuchos::null) ? Teuchos::null : f->getNonconstVectorBlock(i);
424 RCP<Epetra_Vector> e_f;
425 if(th_f==Teuchos::null)
430 for(
int j=0;j<cBlockDim;j++) {
433 RCP<LinearOpBase<double> > th_A = (A== Teuchos::null)? Teuchos::null : A->getNonconstBlock(i,j);
436 RCP<Epetra_CrsMatrix> e_A;
437 if(th_A==Teuchos::null)
440 e_A = rcp_dynamic_cast<Epetra_CrsMatrix>(get_Epetra_Operator(*th_A),
true);
450template <
typename Traits,
typename LocalOrdinalT>
454 const Teuchos::Ptr<Epetra_Vector> & f,
455 const Teuchos::Ptr<Epetra_CrsMatrix> & A,
456 bool zeroVectorRows)
const
458 if(f==Teuchos::null && A==Teuchos::null)
462 for(
int i=0;i<local_bcs.
MyLength();i++) {
463 if(global_bcs[i]==0.0)
470 if(local_bcs[i]==0.0 || zeroVectorRows) {
474 if(!Teuchos::is_null(f))
476 if(!Teuchos::is_null(A)) {
477 A->ExtractMyRowView(i,numEntries,values,indices);
478 for(
int c=0;c<numEntries;c++)
485 double scaleFactor = global_bcs[i];
488 if(!Teuchos::is_null(f))
489 (*f)[i] /= scaleFactor;
490 if(!Teuchos::is_null(A)) {
491 A->ExtractMyRowView(i,numEntries,values,indices);
492 for(
int c=0;c<numEntries;c++)
493 values[c] /= scaleFactor;
499template <
typename Traits,
typename LocalOrdinalT>
505 using Teuchos::rcp_dynamic_cast;
506 using Teuchos::dyn_cast;
513 RCP<const PVector> count = Thyra::castOrCreateProductVectorBase(th_counter.
get_f_th().getConst());
514 RCP<const PVector> f_in = Thyra::castOrCreateProductVectorBase(th_counter.
get_f_th().getConst());
515 RCP<PVector> f_out = Thyra::castOrCreateNonconstProductVectorBase(th_result.get_f_th());
518 for(
int i=0;i<rBlockDim;i++) {
520 Teuchos::ArrayRCP<const double> count_array,f_in_array;
521 Teuchos::ArrayRCP<double> f_out_array;
523 rcp_dynamic_cast<const Thyra::SpmdVectorBase<double> >(count->getVectorBlock(i),
true)->getLocalData(Teuchos::ptrFromRef(count_array));
524 rcp_dynamic_cast<const Thyra::SpmdVectorBase<double> >(f_in->getVectorBlock(i),
true)->getLocalData(Teuchos::ptrFromRef(f_in_array));
525 rcp_dynamic_cast<Thyra::SpmdVectorBase<double> >(f_out->getNonconstVectorBlock(i),
true)->getNonconstLocalData(Teuchos::ptrFromRef(f_out_array));
527 TEUCHOS_ASSERT(count_array.size()==f_in_array.size());
528 TEUCHOS_ASSERT(count_array.size()==f_out_array.size());
530 for(Teuchos::ArrayRCP<double>::size_type j=0;j<count_array.size();++j) {
531 if(count_array[j]!=0.0)
532 f_out_array[j] = f_in_array[j];
542template<
typename Traits,
typename LocalOrdinalT>
543Teuchos::RCP<ReadOnlyVector_GlobalEvaluationData>
558 auto ged = rcp(
new EVROGED);
565 vector<RCP<ROVGED>> gedBlocks;
568 auto vecGed = rcp(
new EVROGED);
571 gedBlocks.push_back(vecGed);
573 auto ged = rcp(
new BVROGED);
584template<
typename Traits,
typename LocalOrdinalT>
585Teuchos::RCP<WriteVector_GlobalEvaluationData>
600 auto ged = rcp(
new EVWGED);
607 vector<RCP<WVGED>> gedBlocks;
610 auto vecGed = rcp(
new EVWGED);
613 gedBlocks.push_back(vecGed);
615 auto ged = rcp(
new BVWGED);
621template <
typename Traits,
typename LocalOrdinalT>
628template <
typename Traits,
typename LocalOrdinalT>
634 TOC & toc = Teuchos::dyn_cast<TOC>(loc);
638template <
typename Traits,
typename LocalOrdinalT>
645 TOC & toc = Teuchos::dyn_cast<TOC>(loc);
651 BLOC & bloc = Teuchos::dyn_cast<BLOC>(loc);
653 if((mem & LOC::F) == LOC::F)
654 bloc.setRequiresDirichletAdjustment(
true);
656 if((mem & LOC::Mat) == LOC::Mat)
657 bloc.setRequiresDirichletAdjustment(
true);
662 if((mem & LOC::F) == LOC::F)
665 if((mem & LOC::Mat) == LOC::Mat)
673template <
typename Traits,
typename LocalOrdinalT>
681 if((mem & LOC::X) == LOC::X)
684 if((mem & LOC::DxDt) == LOC::DxDt)
687 if((mem & LOC::F) == LOC::F)
690 if((mem & LOC::Mat) == LOC::Mat)
694template <
typename Traits,
typename LocalOrdinalT>
702 if((mem & LOC::X) == LOC::X)
705 if((mem & LOC::DxDt) == LOC::DxDt)
708 if((mem & LOC::F) == LOC::F)
711 if((mem & LOC::Mat) == LOC::Mat)
715template <
typename Traits,
typename LocalOrdinalT>
722template <
typename Traits,
typename LocalOrdinalT>
726 for(std::size_t i=0;i<exPairs.size();i++)
730template <
typename Traits,
typename LocalOrdinalT>
737template <
typename Traits,
typename LocalOrdinalT>
749template<
typename Traits,
typename LocalOrdinalT>
753 std::size_t blockCnt,
754 std::size_t colBlockCnt)
756 maps_.resize(blockCnt);
776template <
typename Traits,
typename LocalOrdinalT>
783 std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > > vsArray;
785 vsArray.push_back(Thyra::create_VectorSpace(
getColMap(i)));
787 domainSpace_ = Thyra::productVectorSpace<double>(vsArray);
799template <
typename Traits,
typename LocalOrdinalT>
806 std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > > vsArray;
808 vsArray.push_back(Thyra::create_VectorSpace(
getMap(i)));
810 rangeSpace_ = Thyra::productVectorSpace<double>(vsArray);
822template <
typename Traits,
typename LocalOrdinalT>
826 Teuchos::RCP<Thyra::VectorBase<double> > vec =
828 Thyra::assign(vec.ptr(),0.0);
833template <
typename Traits,
typename LocalOrdinalT>
837 Teuchos::RCP<Thyra::VectorBase<double> > vec =
839 Thyra::assign(vec.ptr(),0.0);
844template <
typename Traits,
typename LocalOrdinalT>
854 Teuchos::RCP<Thyra::PhysicallyBlockedLinearOpBase<double> > blockedOp = Thyra::defaultBlockedLinearOp<double>();
861 blockedOp->beginBlockFill(rBlockDim,cBlockDim);
864 for(std::size_t i=0;i<rBlockDim;i++) {
865 for(std::size_t j=0;j<cBlockDim;j++) {
868 Teuchos::RCP<Thyra::LinearOpBase<double> > block = Thyra::nonconstEpetraLinearOp(
getEpetraMatrix(i,j));
869 blockedOp->setNonconstBlock(i,j,block);
875 blockedOp->endBlockFill();
885template<
typename Traits,
typename LocalOrdinalT>
886Teuchos::RCP<const Thyra::VectorSpaceBase<double>>
892 using Thyra::create_VectorSpace;
893 using Thyra::productVectorSpace;
900 vector<RCP<const VectorSpaceBase<double>>> vsArray;
920template<
typename Traits,
typename LocalOrdinalT>
921Teuchos::RCP<const Thyra::VectorSpaceBase<double>>
927 using Thyra::create_VectorSpace;
928 using Thyra::productVectorSpace;
935 vector<RCP<const VectorSpaceBase<double>>> vsArray;
950template <
typename Traits,
typename LocalOrdinalT>
957 std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > > vsArray;
959 vsArray.push_back(Thyra::create_VectorSpace(
getGhostedMap(i)));
973template <
typename Traits,
typename LocalOrdinalT>
977 Teuchos::RCP<Thyra::VectorBase<double> > vec =
979 Thyra::assign(vec.ptr(),0.0);
984template <
typename Traits,
typename LocalOrdinalT>
988 Teuchos::RCP<Thyra::VectorBase<double> > vec =
990 Thyra::assign(vec.ptr(),0.0);
995template <
typename Traits,
typename LocalOrdinalT>
1005 Teuchos::RCP<Thyra::PhysicallyBlockedLinearOpBase<double> > blockedOp = Thyra::defaultBlockedLinearOp<double>();
1012 blockedOp->beginBlockFill(rBlockDim,cBlockDim);
1015 for(std::size_t i=0;i<rBlockDim;i++) {
1016 for(std::size_t j=0;j<cBlockDim;j++) {
1019 Teuchos::RCP<Thyra::LinearOpBase<double> > block = Thyra::nonconstEpetraLinearOp(
getGhostedEpetraMatrix(i,j));
1020 blockedOp->setNonconstBlock(i,j,block);
1026 blockedOp->endBlockFill();
1031template <
typename Traits,
typename LocalOrdinalT>
1037 using Teuchos::rcp_dynamic_cast;
1039 using Thyra::get_Epetra_Vector;
1044 RCP<const ProductVectorBase<double> > prod_in = Thyra::castOrCreateProductVectorBase(in);
1045 RCP<ProductVectorBase<double> > prod_out = Thyra::castOrCreateNonconstProductVectorBase(out);
1047 TEUCHOS_ASSERT(prod_in->productSpace()->numBlocks()==(
int) blockDim);
1048 TEUCHOS_ASSERT(prod_out->productSpace()->numBlocks()==(
int) blockDim);
1050 for(std::size_t i=0;i<blockDim;i++) {
1052 RCP<const Epetra_Vector> ep_in;
1053 RCP<Epetra_Vector> ep_out;
1056 ep_in = get_Epetra_Vector(*
getGhostedMap(i),prod_in->getVectorBlock(i));
1057 ep_out = get_Epetra_Vector(*
getMap(i),prod_out->getNonconstVectorBlock(i));
1059 ep_in = get_Epetra_Vector(*
getGhostedColMap(i),prod_in->getVectorBlock(i));
1060 ep_out = get_Epetra_Vector(*
getColMap(i),prod_out->getNonconstVectorBlock(i));
1068template <
typename Traits,
typename LocalOrdinalT>
1073 using Teuchos::rcp_dynamic_cast;
1074 using Teuchos::dyn_cast;
1076 using Thyra::PhysicallyBlockedLinearOpBase;
1077 using Thyra::get_Epetra_Operator;
1084 const PhysicallyBlockedLinearOpBase<double> & prod_in = dyn_cast<const PhysicallyBlockedLinearOpBase<double> >(in);
1085 PhysicallyBlockedLinearOpBase<double> & prod_out = dyn_cast<PhysicallyBlockedLinearOpBase<double> >(out);
1087 TEUCHOS_ASSERT(prod_in.productRange()->numBlocks()==(
int) rBlockDim);
1088 TEUCHOS_ASSERT(prod_in.productDomain()->numBlocks()==(
int) cBlockDim);
1089 TEUCHOS_ASSERT(prod_out.productRange()->numBlocks()==(
int) rBlockDim);
1090 TEUCHOS_ASSERT(prod_out.productDomain()->numBlocks()==(
int) cBlockDim);
1092 for(std::size_t i=0;i<rBlockDim;i++) {
1093 for(std::size_t j=0;j<cBlockDim;j++) {
1096 RCP<const LinearOpBase<double> > th_in = prod_in.getBlock(i,j);
1097 RCP<LinearOpBase<double> > th_out = prod_out.getNonconstBlock(i,j);
1100 TEUCHOS_ASSERT(th_in!=Teuchos::null);
1101 TEUCHOS_ASSERT(th_out!=Teuchos::null);
1104 RCP<const Epetra_CrsMatrix> ep_in = rcp_dynamic_cast<const Epetra_CrsMatrix>(get_Epetra_Operator(*th_in),
true);
1105 RCP<Epetra_CrsMatrix> ep_out = rcp_dynamic_cast<Epetra_CrsMatrix>(get_Epetra_Operator(*th_out),
true);
1114template <
typename Traits,
typename LocalOrdinalT>
1120 using Teuchos::rcp_dynamic_cast;
1122 using Thyra::get_Epetra_Vector;
1127 RCP<const ProductVectorBase<double> > prod_in = Thyra::castOrCreateProductVectorBase(in);
1128 RCP<ProductVectorBase<double> > prod_out = Thyra::castOrCreateNonconstProductVectorBase(out);
1130 TEUCHOS_ASSERT(prod_in->productSpace()->numBlocks()==(
int) blockDim);
1131 TEUCHOS_ASSERT(prod_out->productSpace()->numBlocks()==(
int) blockDim);
1133 for(std::size_t i=0;i<blockDim;i++) {
1135 RCP<const Epetra_Vector> ep_in;
1136 RCP<Epetra_Vector> ep_out;
1139 ep_in = get_Epetra_Vector(*
getMap(i),prod_in->getVectorBlock(i));
1140 ep_out = get_Epetra_Vector(*
getGhostedMap(i),prod_out->getNonconstVectorBlock(i));
1143 ep_in = get_Epetra_Vector(*
getColMap(i),prod_in->getVectorBlock(i));
1144 ep_out = get_Epetra_Vector(*
getGhostedColMap(i),prod_out->getNonconstVectorBlock(i));
1155template <
typename Traits,
typename LocalOrdinalT>
1165 TEUCHOS_ASSERT_EQUALITY(err,0);
1168template <
typename Traits,
typename LocalOrdinalT>
1178 TEUCHOS_ASSERT_EQUALITY(err,0);
1181template <
typename Traits,
typename LocalOrdinalT>
1191 TEUCHOS_ASSERT_EQUALITY(err,0);
1195template <
typename Traits,
typename LocalOrdinalT>
1199 if(
maps_[i]==Teuchos::null)
1206template <
typename Traits,
typename LocalOrdinalT>
1224template<
typename Traits,
typename LocalOrdinalT>
1225const Teuchos::RCP<Epetra_Map>
1240template<
typename Traits,
typename LocalOrdinalT>
1241const Teuchos::RCP<Epetra_Map>
1256template<
typename Traits,
typename LocalOrdinalT>
1257const Teuchos::RCP<Epetra_Map>
1274template<
typename Traits,
typename LocalOrdinalT>
1275const Teuchos::RCP<Epetra_Map>
1288template <
typename Traits,
typename LocalOrdinalT>
1292 typedef std::unordered_map<std::pair<int,int>,Teuchos::RCP<Epetra_CrsGraph>,
panzer::pair_hash> GraphMap;
1294 GraphMap::const_iterator itr =
graphs_.find(std::make_pair(i,j));
1295 Teuchos::RCP<Epetra_CrsGraph> graph;
1298 graphs_[std::make_pair(i,j)] = graph;
1301 graph = itr->second;
1303 TEUCHOS_ASSERT(graph!=Teuchos::null);
1307template <
typename Traits,
typename LocalOrdinalT>
1311 typedef std::unordered_map<std::pair<int,int>,Teuchos::RCP<Epetra_CrsGraph>,
panzer::pair_hash> GraphMap;
1313 GraphMap::const_iterator itr =
ghostedGraphs_.find(std::make_pair(i,j));
1314 Teuchos::RCP<Epetra_CrsGraph> ghostedGraph;
1320 ghostedGraph = itr->second;
1322 TEUCHOS_ASSERT(ghostedGraph!=Teuchos::null);
1323 return ghostedGraph;
1331template<
typename Traits,
typename LocalOrdinalT>
1332const Teuchos::RCP<Epetra_Import>
1348template<
typename Traits,
typename LocalOrdinalT>
1349const Teuchos::RCP<Epetra_Import>
1365template<
typename Traits,
typename LocalOrdinalT>
1366const Teuchos::RCP<Epetra_Import>
1385template<
typename Traits,
typename LocalOrdinalT>
1386const Teuchos::RCP<Epetra_Import>
1405template<
typename Traits,
typename LocalOrdinalT>
1406const Teuchos::RCP<Epetra_Export>
1422template<
typename Traits,
typename LocalOrdinalT>
1423const Teuchos::RCP<Epetra_Export>
1439template<
typename Traits,
typename LocalOrdinalT>
1440const Teuchos::RCP<Epetra_Export>
1459template<
typename Traits,
typename LocalOrdinalT>
1460const Teuchos::RCP<Epetra_Export>
1474template <
typename Traits,
typename LocalOrdinalT>
1478 std::vector<int> indices;
1483 return Teuchos::rcp(
new Epetra_Map(-1,indices.size(),&indices[0],0,*
eComm_));
1486template <
typename Traits,
typename LocalOrdinalT>
1493 std::vector<int> indices;
1498 return Teuchos::rcp(
new Epetra_Map(-1,indices.size(),&indices[0],0,*
eComm_));
1506template<
typename Traits,
typename LocalOrdinalT>
1507const Teuchos::RCP<Epetra_Map>
1514 vector<int> indices;
1524template<
typename Traits,
typename LocalOrdinalT>
1525const Teuchos::RCP<Epetra_Map>
1532 vector<int> indices;
1542template<
typename Traits,
typename LocalOrdinalT>
1543const Teuchos::RCP<Epetra_Map>
1552 vector<int> indices;
1562template<
typename Traits,
typename LocalOrdinalT>
1563const Teuchos::RCP<Epetra_Map>
1572 vector<int> indices;
1578template <
typename Traits,
typename LocalOrdinalT>
1587 RCP<Epetra_Map> map_i =
getMap(i);
1590 TEUCHOS_ASSERT(map_i!=Teuchos::null);
1591 TEUCHOS_ASSERT(map_j!=Teuchos::null);
1600 int err = graph->Export( *oGraph, *exporter,
Insert );
1601 TEUCHOS_ASSERT_EQUALITY(err,0);
1602 graph->FillComplete(*map_j,*map_i);
1603 graph->OptimizeStorage();
1608template <
typename Traits,
typename LocalOrdinalT>
1615 Teuchos::RCP<Epetra_CrsGraph> graph = Teuchos::rcp(
new Epetra_CrsGraph(
Copy,*rowMap,*colMap,0));
1617 std::vector<std::string> elementBlockIds;
1619 Teuchos::RCP<const GlobalIndexer> rowProvider, colProvider;
1624 rowProvider->getElementBlockIds(elementBlockIds);
1627 const Teuchos::RCP<const ConnManager> conn_mgr = colProvider->getConnManager();
1628 const bool han = conn_mgr.is_null() ? false : conn_mgr->hasAssociatedNeighbors();
1631 std::vector<std::string>::const_iterator blockItr;
1632 for(blockItr=elementBlockIds.begin();blockItr!=elementBlockIds.end();++blockItr) {
1633 std::string blockId = *blockItr;
1636 const std::vector<LocalOrdinalT> & elements = rowProvider->getElementBlock(blockId);
1640 std::vector<int> row_gids;
1641 std::vector<int> col_gids;
1644 for(std::size_t elmt=0;elmt<elements.size();elmt++) {
1645 rowProvider->getElementGIDsAsInt(elements[elmt],row_gids);
1646 colProvider->getElementGIDsAsInt(elements[elmt],col_gids);
1649 const std::vector<LocalOrdinalT>& aes = conn_mgr->getAssociatedNeighbors(elements[elmt]);
1650 for (
typename std::vector<LocalOrdinalT>::const_iterator eit = aes.begin();
1651 eit != aes.end(); ++eit) {
1652 std::vector<int> other_col_gids;
1653 colProvider->getElementGIDsAsInt(*eit, other_col_gids);
1654 col_gids.insert(col_gids.end(), other_col_gids.begin(), other_col_gids.end());
1658 for(std::size_t row=0;row<row_gids.size();row++)
1659 graph->InsertGlobalIndices(row_gids[row],col_gids.size(),&col_gids[0]);
1665 graph->FillComplete(*colMap,*rowMap);
1667 graph->OptimizeStorage();
1672template <
typename Traits,
typename LocalOrdinalT>
1678 using Teuchos::rcp_dynamic_cast;
1681 RCP<const Filtered_GlobalIndexer> filtered_ugi
1685 if(filtered_ugi==Teuchos::null)
1689 std::vector<int> ghostedActive;
1690 filtered_ugi->getOwnedAndGhostedNotFilteredIndicator(ghostedActive);
1697 for(
int k=0;k<filteredGraph->NumMyRows();++k) {
1698 std::vector<int> removedIndices;
1701 TEUCHOS_ASSERT(filteredGraph->ExtractMyRowView(k,numIndices,indices)==0);
1703 for(
int m=0;m<numIndices;++m) {
1704 if(ghostedActive[indices[m]]==0)
1705 removedIndices.push_back(indices[m]);
1708 TEUCHOS_ASSERT(filteredGraph->RemoveMyIndices(k,Teuchos::as<int>(removedIndices.size()),&removedIndices[0])==0);
1715 TEUCHOS_ASSERT(filteredGraph->FillComplete(*colMap,*rowMap)==0);
1716 TEUCHOS_ASSERT(filteredGraph->OptimizeStorage()==0);
1718 return filteredGraph;
1721template <
typename Traits,
typename LocalOrdinalT>
1725 Teuchos::RCP<Epetra_CrsGraph> eGraph =
getGraph(i,j);
1727 TEUCHOS_ASSERT(mat->Filled());
1731template <
typename Traits,
typename LocalOrdinalT>
1737 TEUCHOS_ASSERT(mat->Filled());
1741template <
typename Traits,
typename LocalOrdinalT>
1748template <
typename Traits,
typename LocalOrdinalT>
1755template <
typename Traits,
typename LocalOrdinalT>
int PutScalar(double ScalarConstant)
int Import(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
int Export(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
int PutScalar(double ScalarConstant)
Teuchos::RCP< VectorType > get_f() const
Teuchos::RCP< VectorType > get_dxdt() const
Teuchos::RCP< VectorType > get_x() const
virtual const Teuchos::RCP< Epetra_Map > buildGhostedMap2(int i) const
Build the i-th ghosted map from the ghosted indices of the i-th global indexer.
void ghostToGlobalEpetraMatrix(int blockRow, const Epetra_CrsMatrix &in, Epetra_CrsMatrix &out) const
virtual Teuchos::MpiComm< int > getComm() const
void globalToGhostEpetraVector(int i, const Epetra_Vector &in, Epetra_Vector &out, bool col) const
void initializeGhostedContainer(int, LinearObjContainer &loc) const
Teuchos::RCP< const Epetra_Comm > eComm_
Teuchos::RCP< Thyra::LinearOpBase< double > > getThyraMatrix() const
Get a Thyra operator.
virtual const Teuchos::RCP< Epetra_Export > getGhostedColExport(int j) const
get exporter for converting an overalapped object to a "normal" object
virtual const Teuchos::RCP< Epetra_Map > buildMap(int i) const
Build the i-th owned map from the owned indices of the i-th global indexer.
virtual const Teuchos::RCP< Epetra_Map > getGhostedColMap(int i) const
get the ghosted map from the matrix
Teuchos::RCP< const panzer::BlockedDOFManager > getGlobalIndexer() const
virtual const Teuchos::RCP< Epetra_CrsGraph > buildFilteredGhostedGraph(int i, int j) const
std::vector< Teuchos::RCP< Epetra_Export > > colExporters_
void ghostToGlobalThyraVector(const Teuchos::RCP< const Thyra::VectorBase< double > > &in, const Teuchos::RCP< Thyra::VectorBase< double > > &out, bool col) const
void addExcludedPair(int rowBlock, int colBlock)
exclude a block pair from the matrix
virtual const Teuchos::RCP< const Epetra_Comm > getEpetraComm() const
get exporter for converting an overalapped object to a "normal" object
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getGhostedThyraDomainSpace2() const
Get or create the ghosted Thyra domain space.
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getGhostedThyraRangeSpace() const
Get the range vector space (f)
virtual const Teuchos::RCP< Epetra_Map > buildColGhostedMap2(int i) const
Build the i-th ghosted column map from the ghosted indices of the i-th (column) global indexer.
void makeRoomForBlocks(std::size_t blockCnt, std::size_t colBlockCnt=0)
Allocate the space in the std::vector objects so we can fill with appropriate Epetra data.
virtual void readVector(const std::string &identifier, LinearObjContainer &loc, int id) const
std::vector< Teuchos::RCP< Epetra_Map > > maps_
The list of owned maps corresponding to the owned indices of the global indexers.
virtual const Teuchos::RCP< Epetra_Map > getGhostedMap(int i) const
get the ghosted map from the matrix
virtual const Teuchos::RCP< Epetra_Import > getGhostedColImport2(int i) const
Get or create the i-th ghosted column importer corresponding to the i-th ghosted column map.
std::vector< Teuchos::RCP< Epetra_Import > > importers2_
The list of ghosted importers corresponding to ghostedMaps2_.
void addExcludedPairs(const std::vector< std::pair< int, int > > &exPairs)
exclude a vector of pairs from the matrix
Teuchos::RCP< const DOFManagerContainer > colDOFManagerContainer_
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > rangeSpace_
Teuchos::RCP< const DOFManagerContainer > rowDOFManagerContainer_
std::vector< Teuchos::RCP< Epetra_Map > > colGhostedMaps2_
The list of ghosted column maps corresponding to the ghosted indices of the (column) global indexers.
int getBlockColCount() const
how many block columns
Teuchos::RCP< Thyra::VectorBase< double > > getThyraRangeVector() const
Get a range vector.
std::unordered_set< std::pair< int, int >, panzer::pair_hash > excludedPairs_
virtual const Teuchos::RCP< Epetra_CrsGraph > getGraph(int i, int j) const
get the graph of the crs matrix
virtual Teuchos::RCP< LinearObjContainer > buildGhostedLinearObjContainer() const
virtual const Teuchos::RCP< Epetra_Map > buildGhostedMap(int i) const
Build the i-th ghosted map from the owned and ghosted indices of the i-th global indexer.
void initializeContainer(int, LinearObjContainer &loc) const
void ghostToGlobalEpetraVector(int i, const Epetra_Vector &in, Epetra_Vector &out, bool col) const
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getThyraRangeSpace() const
Get the range vector space (f)
virtual void ghostToGlobalContainer(const LinearObjContainer &ghostContainer, LinearObjContainer &container, int) const
void ghostToGlobalThyraMatrix(const Thyra::LinearOpBase< double > &in, Thyra::LinearOpBase< double > &out) const
Teuchos::RCP< const Teuchos::OpaqueWrapper< MPI_Comm > > rawMpiComm_
virtual const Teuchos::RCP< Epetra_Import > getGhostedImport2(int i) const
Get or create the i-th ghosted importer corresponding to the i-th ghosted map.
std::vector< Teuchos::RCP< Epetra_Map > > ghostedMaps_
The list of ghosted maps corresponding to the owned and ghosted indices of the global indexers.
void initializeContainer_internal(int mem, ThyraObjContainer< double > &loc) const
virtual const Teuchos::RCP< Epetra_Map > getMap(int i) const
get the map from the matrix
Teuchos::RCP< Thyra::VectorBase< double > > getGhostedThyraDomainVector() const
Get a domain vector.
virtual const Teuchos::RCP< Epetra_Map > buildColMap(int i) const
Build the i-th owned column map from the owned indices of the i-th (column) global indexer.
std::vector< Teuchos::RCP< Epetra_Map > > colMaps_
The list of owned column maps corresponding to the owned indices of the (column) global indexers.
virtual ~BlockedEpetraLinearObjFactory()
virtual const Teuchos::RCP< Epetra_Export > getGhostedExport2(int i) const
Get or create the i-th ghosted exporter corresponding to the i-th ghosted map.
int getBlockRowCount() const
how many block rows
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > ghostedRangeSpace_
virtual const Teuchos::RCP< Epetra_Import > getGhostedImport(int i) const
get importer for converting an overalapped object to a "normal" object
Teuchos::RCP< Thyra::VectorBase< double > > getThyraDomainVector() const
Get a domain vector.
virtual const Teuchos::RCP< Epetra_CrsGraph > buildGhostedGraph(int i, int j, bool optimizeStorage) const
virtual const Teuchos::RCP< Epetra_Map > buildColGhostedMap(int i) const
Build the i-th ghosted column map from the owned and ghosted indices of the i-th (column) global inde...
virtual void adjustForDirichletConditions(const LinearObjContainer &localBCRows, const LinearObjContainer &globalBCRows, LinearObjContainer &ghostedObjs, bool zeroVectorRows=false, bool adjustX=false) const
std::vector< Teuchos::RCP< Epetra_Import > > importers_
The list of ghosted importers corresponding to ghostedMaps_.
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > ghostedDomainSpace_
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > domainSpace_
BlockedEpetraLinearObjFactory(const Teuchos::RCP< const Teuchos::MpiComm< int > > &comm, const Teuchos::RCP< const GlobalIndexer > &gidProvider, bool useDiscreteAdjoint=false)
Teuchos::RCP< Thyra::VectorBase< double > > getGhostedThyraRangeVector() const
Get a range vector.
virtual void applyDirichletBCs(const LinearObjContainer &counter, LinearObjContainer &result) const
std::unordered_map< std::pair< int, int >, Teuchos::RCP< Epetra_CrsGraph >, panzer::pair_hash > graphs_
std::vector< Teuchos::RCP< Epetra_Map > > ghostedMaps2_
The list of ghosted maps corresponding to the ghosted indices of the global indexers.
void initializeGhostedContainer_internal(int mem, ThyraObjContainer< double > &loc) const
virtual Teuchos::RCP< ReadOnlyVector_GlobalEvaluationData > buildReadOnlyDomainContainer() const
virtual void globalToGhostContainer(const LinearObjContainer &container, LinearObjContainer &ghostContainer, int) const
Teuchos::RCP< Epetra_CrsMatrix > getGhostedEpetraMatrix(int i, int j) const
std::vector< Teuchos::RCP< Epetra_Export > > exporters_
virtual const Teuchos::RCP< Epetra_Import > getGhostedColImport(int i) const
get importer for converting an overalapped object to a "normal" object
virtual const Teuchos::RCP< Epetra_CrsGraph > getGhostedGraph(int i, int j) const
get the ghosted graph of the crs matrix
virtual const Teuchos::RCP< Epetra_Export > getGhostedColExport2(int i) const
Get or create the i-th ghosted column exporter corresponding to the i-th ghosted column map.
Teuchos::RCP< Teuchos::MpiComm< int > > tComm_
std::vector< Teuchos::RCP< Epetra_Import > > colImporters2_
The list of ghosted importers corresponding to colGhostedMaps2_.
virtual const Teuchos::RCP< Epetra_CrsGraph > buildGraph(int i, int j) const
Teuchos::RCP< Thyra::LinearOpBase< double > > getGhostedThyraMatrix() const
Get a Thyra operator.
virtual const Teuchos::RCP< Epetra_Map > getColMap(int i) const
get the map from the matrix
void globalToGhostThyraVector(const Teuchos::RCP< const Thyra::VectorBase< double > > &in, const Teuchos::RCP< Thyra::VectorBase< double > > &out, bool col) const
virtual const Teuchos::RCP< Epetra_Map > getGhostedMap2(int i) const
Get or create the i-th ghosted map.
std::vector< Teuchos::RCP< Epetra_Map > > colGhostedMaps_
The list of ghosted column maps corresponding to the owned and ghosted indices of the (column) global...
virtual Teuchos::RCP< LinearObjContainer > buildLinearObjContainer() const
std::vector< Teuchos::RCP< Epetra_Import > > colImporters_
The list of ghosted importers corresponding to colGhostedMaps_.
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getThyraDomainSpace() const
Get the domain vector space (x and dxdt)
virtual const Teuchos::RCP< Epetra_Map > getGhostedColMap2(int i) const
Get or create the i-th ghosted column map.
virtual Teuchos::RCP< WriteVector_GlobalEvaluationData > buildWriteDomainContainer() const
Teuchos::RCP< const GlobalIndexer > getColGlobalIndexer(int i) const
virtual const Teuchos::RCP< Epetra_Export > getGhostedExport(int j) const
get exporter for converting an overalapped object to a "normal" object
Teuchos::RCP< Epetra_CrsMatrix > getEpetraMatrix(int i, int j) const
virtual void writeVector(const std::string &identifier, const LinearObjContainer &loc, int id) const
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getGhostedThyraDomainSpace() const
Get the domain vector space (x and dxdt)
std::unordered_map< std::pair< int, int >, Teuchos::RCP< Epetra_CrsGraph >, panzer::pair_hash > ghostedGraphs_
This class encapsulates the needs of a gather operation to do a halo exchange for blocked vectors.
This class encapsulates the needs of a gather operation to do a // halo exchange for blocked vectors....
const Teuchos::RCP< Epetra_CrsMatrix > get_A() const
const Teuchos::RCP< Epetra_Vector > get_dxdt() const
const Teuchos::RCP< Epetra_Vector > get_f() const
const Teuchos::RCP< Epetra_Vector > get_x() const
This class provides a boundary exchange communication mechanism for vectors.
This class provides a boundary exchange communication mechanism for vectors.
void setRequiresDirichletAdjustment(bool b)
void buildGatherScatterEvaluators(const BuilderT &builder)
virtual void set_f_th(const Teuchos::RCP< Thyra::VectorBase< ScalarT > > &in)=0
virtual void set_A_th(const Teuchos::RCP< Thyra::LinearOpBase< ScalarT > > &in)=0
virtual Teuchos::RCP< Thyra::VectorBase< ScalarT > > get_f_th() const =0
virtual void set_dxdt_th(const Teuchos::RCP< Thyra::VectorBase< ScalarT > > &in)=0
virtual void set_x_th(const Teuchos::RCP< Thyra::VectorBase< ScalarT > > &in)=0
int MatrixMarketFileToVector(const char *filename, const Epetra_BlockMap &map, Epetra_Vector *&A)
int VectorToMatrixMarketFile(const char *filename, const Epetra_Vector &A, const char *matrixName=0, const char *matrixDescription=0, bool writeHeader=true)