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"
84 template <
typename Traits,
typename LocalOrdinalT>
88 bool useDiscreteAdjoint)
89 : useColGidProviders_(false), eComm_(Teuchos::null)
90 , rawMpiComm_(comm->getRawMpiComm())
91 , useDiscreteAdjoint_(useDiscreteAdjoint)
107 template <
typename Traits,
typename LocalOrdinalT>
112 bool useDiscreteAdjoint)
113 : eComm_(Teuchos::null)
114 , rawMpiComm_(comm->getRawMpiComm())
115 , useDiscreteAdjoint_(useDiscreteAdjoint)
133 template <
typename Traits,
typename LocalOrdinalT>
140 template <
typename Traits,
typename LocalOrdinalT>
146 using Teuchos::rcp_dynamic_cast;
169 int blockRows = this->getBlockRowCount();
173 for(
int i=0;i<blockRows;i++) {
178 std::stringstream ss;
179 ss << identifier <<
"-" << i <<
".mm";
190 template <
typename Traits,
typename LocalOrdinalT>
196 using Teuchos::rcp_dynamic_cast;
219 int blockRows = this->getBlockRowCount();
223 for(
int i=0;i<blockRows;i++) {
228 std::stringstream ss;
229 ss << identifier <<
"-" << i <<
".mm";
236 template <
typename Traits,
typename LocalOrdinalT>
240 if(!rowDOFManagerContainer_->containsBlockedDOFManager() && !colDOFManagerContainer_->containsBlockedDOFManager()) {
246 std::vector<Teuchos::RCP<const Epetra_Map> > blockMaps;
247 std::size_t blockDim = getBlockRowCount();
248 for(std::size_t i=0;i<blockDim;i++)
249 blockMaps.push_back(getMap(i));
257 template <
typename Traits,
typename LocalOrdinalT>
261 if(!rowDOFManagerContainer_->containsBlockedDOFManager() && !colDOFManagerContainer_->containsBlockedDOFManager()) {
267 std::vector<Teuchos::RCP<const Epetra_Map> > blockMaps;
268 std::size_t blockDim = getBlockRowCount();
269 for(std::size_t i=0;i<blockDim;i++)
270 blockMaps.push_back(getGhostedMap(i));
278 template <
typename Traits,
typename LocalOrdinalT>
287 if( !rowDOFManagerContainer_->containsBlockedDOFManager()
288 && !colDOFManagerContainer_->containsBlockedDOFManager()) {
295 globalToGhostEpetraVector(0,*e_in.
get_x(),*e_out.get_x(),
true);
298 globalToGhostEpetraVector(0,*e_in.
get_dxdt(),*e_out.get_dxdt(),
true);
301 globalToGhostEpetraVector(0,*e_in.
get_f(),*e_out.get_f(),
false);
309 if ( !
is_null(b_in.get_x()) && !
is_null(b_out.get_x()) && ((mem & LOC::X)==LOC::X))
310 globalToGhostThyraVector(b_in.get_x(),b_out.get_x(),
true);
312 if ( !
is_null(b_in.get_dxdt()) && !
is_null(b_out.get_dxdt()) && ((mem & LOC::DxDt)==LOC::DxDt))
313 globalToGhostThyraVector(b_in.get_dxdt(),b_out.get_dxdt(),
true);
315 if ( !
is_null(b_in.get_f()) && !
is_null(b_out.get_f()) && ((mem & LOC::F)==LOC::F))
316 globalToGhostThyraVector(b_in.get_f(),b_out.get_f(),
false);
320 template <
typename Traits,
typename LocalOrdinalT>
329 if( !rowDOFManagerContainer_->containsBlockedDOFManager()
330 && !colDOFManagerContainer_->containsBlockedDOFManager()) {
337 ghostToGlobalEpetraVector(0,*e_in.
get_x(),*e_out.get_x(),
true);
340 ghostToGlobalEpetraVector(0,*e_in.
get_f(),*e_out.get_f(),
false);
343 ghostToGlobalEpetraMatrix(0,*e_in.
get_A(),*e_out.get_A());
351 if ( !
is_null(b_in.get_x()) && !
is_null(b_out.get_x()) && ((mem & LOC::X)==LOC::X))
352 ghostToGlobalThyraVector(b_in.get_x(),b_out.get_x(),
true);
354 if ( !
is_null(b_in.get_f()) && !
is_null(b_out.get_f()) && ((mem & LOC::F)==LOC::F))
355 ghostToGlobalThyraVector(b_in.get_f(),b_out.get_f(),
false);
357 if ( !
is_null(b_in.get_A()) && !
is_null(b_out.get_A()) && ((mem & LOC::Mat)==LOC::Mat))
358 ghostToGlobalThyraMatrix(*b_in.get_A(),*b_out.get_A());
362 template <
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;
380 int rBlockDim = getBlockRowCount();
381 int cBlockDim = getBlockColCount();
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()));
400 : Thyra::castOrCreateNonconstProductVectorBase(b_ghosted.get_f_th());
403 : Thyra::castOrCreateNonconstProductVectorBase(b_localBCRows.get_f_th());
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++) {
425 if(th_f==Teuchos::null)
428 e_f = get_Epetra_Vector(*getGhostedMap(i),th_f);
430 for(
int j=0;j<cBlockDim;j++) {
437 if(th_A==Teuchos::null)
443 adjustForDirichletConditions(*e_local_bcs,*e_global_bcs,e_f.
ptr(),e_A.
ptr(),zeroVectorRows);
450 template <
typename Traits,
typename LocalOrdinalT>
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) {
478 for(
int c=0;c<numEntries;c++)
485 double scaleFactor = global_bcs[i];
489 (*f)[i] /= scaleFactor;
492 for(
int c=0;c<numEntries;c++)
493 values[c] /= scaleFactor;
499 template <
typename Traits,
typename LocalOrdinalT>
505 using Teuchos::rcp_dynamic_cast;
515 RCP<PVector> f_out = Thyra::castOrCreateNonconstProductVectorBase(th_result.get_f_th());
517 int rBlockDim = getBlockRowCount();
518 for(
int i=0;i<rBlockDim;i++) {
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));
531 if(count_array[j]!=0.0)
532 f_out_array[j] = f_in_array[j];
542 template<
typename Traits,
typename LocalOrdinalT>
556 if (not colDOFManagerContainer_->containsBlockedDOFManager())
558 auto ged =
rcp(
new EVROGED);
559 ged->initialize(getGhostedColImport2(0), getGhostedColMap2(0),
565 vector<RCP<ROVGED>> gedBlocks;
566 for (
int i(0); i < getBlockColCount(); ++i)
568 auto vecGed =
rcp(
new EVROGED);
569 vecGed->initialize(getGhostedColImport2(i), getGhostedColMap2(i),
571 gedBlocks.push_back(vecGed);
573 auto ged =
rcp(
new BVROGED);
574 ged->initialize(getGhostedThyraDomainSpace2(), getThyraDomainSpace(),
584 template<
typename Traits,
typename LocalOrdinalT>
598 if (not colDOFManagerContainer_->containsBlockedDOFManager())
600 auto ged =
rcp(
new EVWGED);
601 ged->initialize(getGhostedColExport2(0), getGhostedColMap2(0),
607 vector<RCP<WVGED>> gedBlocks;
608 for (
int i(0); i < getBlockColCount(); ++i)
610 auto vecGed =
rcp(
new EVWGED);
611 vecGed->initialize(getGhostedColExport2(i), getGhostedColMap2(i),
613 gedBlocks.push_back(vecGed);
615 auto ged =
rcp(
new BVWGED);
616 ged->initialize(getGhostedThyraDomainSpace2(), getThyraDomainSpace(),
621 template <
typename Traits,
typename LocalOrdinalT>
628 template <
typename Traits,
typename LocalOrdinalT>
635 initializeContainer_internal(mem,toc);
638 template <
typename Traits,
typename LocalOrdinalT>
646 initializeGhostedContainer_internal(mem,toc);
648 if(rowDOFManagerContainer_->containsBlockedDOFManager()) {
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)
673 template <
typename Traits,
typename LocalOrdinalT>
681 if((mem & LOC::X) == LOC::X)
682 loc.
set_x_th(getThyraDomainVector());
684 if((mem & LOC::DxDt) == LOC::DxDt)
687 if((mem & LOC::F) == LOC::F)
688 loc.
set_f_th(getThyraRangeVector());
690 if((mem & LOC::Mat) == LOC::Mat)
694 template <
typename Traits,
typename LocalOrdinalT>
702 if((mem & LOC::X) == LOC::X)
703 loc.
set_x_th(getGhostedThyraDomainVector());
705 if((mem & LOC::DxDt) == LOC::DxDt)
708 if((mem & LOC::F) == LOC::F)
709 loc.
set_f_th(getGhostedThyraRangeVector());
711 if((mem & LOC::Mat) == LOC::Mat)
712 loc.
set_A_th(getGhostedThyraMatrix());
715 template <
typename Traits,
typename LocalOrdinalT>
719 excludedPairs_.insert(std::make_pair(rowBlock,colBlock));
722 template <
typename Traits,
typename LocalOrdinalT>
726 for(std::size_t i=0;i<exPairs.size();i++)
727 excludedPairs_.insert(exPairs[i]);
730 template <
typename Traits,
typename LocalOrdinalT>
737 template <
typename Traits,
typename LocalOrdinalT>
741 return colDOFManagerContainer_->getFieldDOFManagers()[i];
749 template<
typename Traits,
typename LocalOrdinalT>
753 std::size_t blockCnt,
754 std::size_t colBlockCnt)
756 maps_.resize(blockCnt);
757 ghostedMaps_.resize(blockCnt);
758 ghostedMaps2_.resize(blockCnt);
759 importers_.resize(blockCnt);
760 importers2_.resize(blockCnt);
761 exporters_.resize(blockCnt);
764 colMaps_.resize(colBlockCnt);
765 colGhostedMaps_.resize(colBlockCnt);
766 colGhostedMaps2_.resize(colBlockCnt);
767 colImporters_.resize(colBlockCnt);
768 colImporters2_.resize(colBlockCnt);
769 colExporters_.resize(colBlockCnt);
776 template <
typename Traits,
typename LocalOrdinalT>
780 if(domainSpace_==Teuchos::null) {
781 if(colDOFManagerContainer_->containsBlockedDOFManager()) {
783 std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > > vsArray;
784 for(
int i=0;i<getBlockColCount();i++)
785 vsArray.push_back(Thyra::create_VectorSpace(getColMap(i)));
787 domainSpace_ = Thyra::productVectorSpace<double>(vsArray);
792 domainSpace_ = Thyra::create_VectorSpace(getColMap(0));
799 template <
typename Traits,
typename LocalOrdinalT>
803 if(rangeSpace_==Teuchos::null) {
804 if(rowDOFManagerContainer_->containsBlockedDOFManager()) {
806 std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > > vsArray;
807 for(
int i=0;i<getBlockRowCount();i++)
808 vsArray.push_back(Thyra::create_VectorSpace(getMap(i)));
810 rangeSpace_ = Thyra::productVectorSpace<double>(vsArray);
815 rangeSpace_ = Thyra::create_VectorSpace(getMap(0));
822 template <
typename Traits,
typename LocalOrdinalT>
827 Thyra::createMember<double>(*getThyraDomainSpace());
828 Thyra::assign(vec.
ptr(),0.0);
833 template <
typename Traits,
typename LocalOrdinalT>
838 Thyra::createMember<double>(*getThyraRangeSpace());
839 Thyra::assign(vec.
ptr(),0.0);
844 template <
typename Traits,
typename LocalOrdinalT>
849 if(!rowDOFManagerContainer_->containsBlockedDOFManager() &&
850 !colDOFManagerContainer_->containsBlockedDOFManager()) {
851 return Thyra::nonconstEpetraLinearOp(getEpetraMatrix(0,0));
857 std::size_t rBlockDim = getBlockRowCount();
858 std::size_t cBlockDim = getBlockColCount();
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++) {
866 if(excludedPairs_.find(std::make_pair(i,j))==excludedPairs_.end()) {
869 blockedOp->setNonconstBlock(i,j,block);
875 blockedOp->endBlockFill();
885 template<
typename Traits,
typename LocalOrdinalT>
892 using Thyra::create_VectorSpace;
893 using Thyra::productVectorSpace;
895 if (ghostedDomainSpace_.is_null())
897 if (colDOFManagerContainer_->containsBlockedDOFManager())
900 vector<RCP<const VectorSpaceBase<double>>> vsArray;
901 for (
int i(0); i < getBlockColCount(); ++i)
902 vsArray.push_back(create_VectorSpace(getGhostedColMap(i)));
903 ghostedDomainSpace_ = productVectorSpace<double>(vsArray);
909 ghostedDomainSpace_ = create_VectorSpace(getGhostedColMap(0));
912 return ghostedDomainSpace_;
920 template<
typename Traits,
typename LocalOrdinalT>
927 using Thyra::create_VectorSpace;
928 using Thyra::productVectorSpace;
930 if (ghostedDomainSpace_.is_null())
932 if (colDOFManagerContainer_->containsBlockedDOFManager())
935 vector<RCP<const VectorSpaceBase<double>>> vsArray;
936 for (
int i(0); i < getBlockColCount(); ++i)
937 vsArray.push_back(create_VectorSpace(getGhostedColMap2(i)));
938 ghostedDomainSpace_ = productVectorSpace<double>(vsArray);
944 ghostedDomainSpace_ = create_VectorSpace(getGhostedColMap2(0));
947 return ghostedDomainSpace_;
950 template <
typename Traits,
typename LocalOrdinalT>
954 if(ghostedRangeSpace_==Teuchos::null) {
955 if(rowDOFManagerContainer_->containsBlockedDOFManager()) {
957 std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > > vsArray;
958 for(
int i=0;i<getBlockRowCount();i++)
959 vsArray.push_back(Thyra::create_VectorSpace(getGhostedMap(i)));
961 ghostedRangeSpace_ = Thyra::productVectorSpace<double>(vsArray);
966 ghostedRangeSpace_ = Thyra::create_VectorSpace(getGhostedMap(0));
970 return ghostedRangeSpace_;
973 template <
typename Traits,
typename LocalOrdinalT>
978 Thyra::createMember<double>(*getGhostedThyraDomainSpace());
979 Thyra::assign(vec.
ptr(),0.0);
984 template <
typename Traits,
typename LocalOrdinalT>
989 Thyra::createMember<double>(*getGhostedThyraRangeSpace());
990 Thyra::assign(vec.
ptr(),0.0);
995 template <
typename Traits,
typename LocalOrdinalT>
1000 if(!rowDOFManagerContainer_->containsBlockedDOFManager() &&
1001 !colDOFManagerContainer_->containsBlockedDOFManager()) {
1002 return Thyra::nonconstEpetraLinearOp(getGhostedEpetraMatrix(0,0));
1008 std::size_t rBlockDim = getBlockRowCount();
1009 std::size_t cBlockDim = getBlockColCount();
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++) {
1017 if(excludedPairs_.find(std::make_pair(i,j))==excludedPairs_.end()) {
1020 blockedOp->setNonconstBlock(i,j,block);
1026 blockedOp->endBlockFill();
1031 template <
typename Traits,
typename LocalOrdinalT>
1037 using Teuchos::rcp_dynamic_cast;
1039 using Thyra::get_Epetra_Vector;
1041 std::size_t blockDim = col ? getBlockColCount() : getBlockRowCount();
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++) {
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));
1064 ghostToGlobalEpetraVector(i,*ep_in,*ep_out,col);
1068 template <
typename Traits,
typename LocalOrdinalT>
1073 using Teuchos::rcp_dynamic_cast;
1076 using Thyra::PhysicallyBlockedLinearOpBase;
1077 using Thyra::get_Epetra_Operator;
1080 std::size_t rBlockDim = getBlockRowCount();
1081 std::size_t cBlockDim = getBlockColCount();
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++) {
1094 if(excludedPairs_.find(std::make_pair(i,j))==excludedPairs_.end()) {
1108 ghostToGlobalEpetraMatrix(i,*ep_in,*ep_out);
1114 template <
typename Traits,
typename LocalOrdinalT>
1120 using Teuchos::rcp_dynamic_cast;
1122 using Thyra::get_Epetra_Vector;
1124 std::size_t blockDim = col ? getBlockColCount() : getBlockRowCount();
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++) {
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));
1148 globalToGhostEpetraVector(i,*ep_in,*ep_out,col);
1155 template <
typename Traits,
typename LocalOrdinalT>
1164 int err = out.Export(in,*exporter,
Add);
1168 template <
typename Traits,
typename LocalOrdinalT>
1177 int err = out.Export(in,*exporter,
Add);
1181 template <
typename Traits,
typename LocalOrdinalT>
1190 int err = out.Import(in,*importer,
Insert);
1195 template <
typename Traits,
typename LocalOrdinalT>
1199 if(maps_[i]==Teuchos::null)
1200 maps_[i] = buildMap(i);
1206 template <
typename Traits,
typename LocalOrdinalT>
1210 if(not useColGidProviders_)
1213 if(colMaps_[i]==Teuchos::null)
1214 colMaps_[i] = buildColMap(i);
1224 template<
typename Traits,
typename LocalOrdinalT>
1230 if (ghostedMaps_[i].
is_null())
1231 ghostedMaps_[i] = buildGhostedMap(i);
1232 return ghostedMaps_[i];
1240 template<
typename Traits,
typename LocalOrdinalT>
1246 if (ghostedMaps2_[i].
is_null())
1247 ghostedMaps2_[i] = buildGhostedMap2(i);
1248 return ghostedMaps2_[i];
1256 template<
typename Traits,
typename LocalOrdinalT>
1262 if (not useColGidProviders_)
1263 return getGhostedMap(i);
1264 if (colGhostedMaps_[i].
is_null())
1265 colGhostedMaps_[i] = buildColGhostedMap(i);
1266 return colGhostedMaps_[i];
1274 template<
typename Traits,
typename LocalOrdinalT>
1280 if (not useColGidProviders_)
1281 return getGhostedMap2(i);
1282 if (colGhostedMaps2_[i].
is_null())
1283 colGhostedMaps2_[i] = buildColGhostedMap2(i);
1284 return colGhostedMaps2_[i];
1288 template <
typename Traits,
typename LocalOrdinalT>
1294 GraphMap::const_iterator itr = graphs_.find(std::make_pair(i,j));
1295 Teuchos::RCP<Epetra_CrsGraph> graph;
1296 if(itr==graphs_.end()) {
1297 graph = buildGraph(i,j);
1298 graphs_[std::make_pair(i,j)] = graph;
1301 graph = itr->second;
1307 template <
typename Traits,
typename LocalOrdinalT>
1313 GraphMap::const_iterator itr = ghostedGraphs_.find(std::make_pair(i,j));
1314 Teuchos::RCP<Epetra_CrsGraph> ghostedGraph;
1315 if(itr==ghostedGraphs_.end()) {
1316 ghostedGraph = buildGhostedGraph(i,j,
true);
1317 ghostedGraphs_[std::make_pair(i,j)] = ghostedGraph;
1320 ghostedGraph = itr->second;
1323 return ghostedGraph;
1331 template<
typename Traits,
typename LocalOrdinalT>
1340 return importers_[i];
1348 template<
typename Traits,
typename LocalOrdinalT>
1357 return importers2_[i];
1365 template<
typename Traits,
typename LocalOrdinalT>
1372 if (not useColGidProviders_)
1373 return getGhostedImport(i);
1374 if (colImporters_[i].
is_null())
1377 return colImporters_[i];
1385 template<
typename Traits,
typename LocalOrdinalT>
1392 if (not useColGidProviders_)
1393 return getGhostedImport2(i);
1394 if (colImporters2_[i].
is_null())
1397 return colImporters2_[i];
1405 template<
typename Traits,
typename LocalOrdinalT>
1414 return exporters_[i];
1422 template<
typename Traits,
typename LocalOrdinalT>
1431 return exporters_[i];
1439 template<
typename Traits,
typename LocalOrdinalT>
1446 if (not useColGidProviders_)
1447 return getGhostedExport(i);
1448 if (colExporters_[i].
is_null())
1451 return colExporters_[i];
1459 template<
typename Traits,
typename LocalOrdinalT>
1466 if (not useColGidProviders_)
1467 return getGhostedExport2(i);
1468 if (colExporters_[i].
is_null())
1471 return colExporters_[i];
1474 template <
typename Traits,
typename LocalOrdinalT>
1478 std::vector<int> indices;
1481 getGlobalIndexer(i)->getOwnedIndicesAsInt(indices);
1486 template <
typename Traits,
typename LocalOrdinalT>
1490 if(not useColGidProviders_)
1493 std::vector<int> indices;
1496 getColGlobalIndexer(i)->getOwnedIndicesAsInt(indices);
1506 template<
typename Traits,
typename LocalOrdinalT>
1514 vector<int> indices;
1515 getGlobalIndexer(i)->getOwnedAndGhostedIndicesAsInt(indices);
1516 return rcp(
new Epetra_Map(-1, indices.size(), &indices[0], 0, *eComm_));
1524 template<
typename Traits,
typename LocalOrdinalT>
1532 vector<int> indices;
1533 getGlobalIndexer(i)->getGhostedIndicesAsInt(indices);
1534 return rcp(
new Epetra_Map(-1, indices.size(), &indices[0], 0, *eComm_));
1542 template<
typename Traits,
typename LocalOrdinalT>
1550 if (not useColGidProviders_)
1551 return buildGhostedMap(i);
1552 vector<int> indices;
1553 getColGlobalIndexer(i)->getOwnedAndGhostedIndicesAsInt(indices);
1554 return rcp(
new Epetra_Map(-1, indices.size(), &indices[0], 0, *eComm_));
1562 template<
typename Traits,
typename LocalOrdinalT>
1570 if (not useColGidProviders_)
1571 return buildGhostedMap2(i);
1572 vector<int> indices;
1573 getColGlobalIndexer(i)->getGhostedIndicesAsInt(indices);
1574 return rcp(
new Epetra_Map(-1, indices.size(), &indices[0], 0, *eComm_));
1578 template <
typename Traits,
typename LocalOrdinalT>
1608 template <
typename Traits,
typename LocalOrdinalT>
1617 std::vector<std::string> elementBlockIds;
1621 rowProvider = getGlobalIndexer(i);
1622 colProvider = getColGlobalIndexer(j);
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++) {
1650 for (
typename std::vector<LocalOrdinalT>::const_iterator eit = aes.begin();
1651 eit != aes.end(); ++eit) {
1652 std::vector<int> 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++)
1672 template <
typename Traits,
typename LocalOrdinalT>
1678 using Teuchos::rcp_dynamic_cast;
1685 if(filtered_ugi==Teuchos::null)
1686 return buildGhostedGraph(i,j,
true);
1689 std::vector<int> ghostedActive;
1697 for(
int k=0;k<filteredGraph->
NumMyRows();++k) {
1698 std::vector<int> removedIndices;
1703 for(
int m=0;m<numIndices;++m) {
1704 if(ghostedActive[indices[m]]==0)
1705 removedIndices.push_back(indices[m]);
1718 return filteredGraph;
1721 template <
typename Traits,
typename LocalOrdinalT>
1731 template <
typename Traits,
typename LocalOrdinalT>
1741 template <
typename Traits,
typename LocalOrdinalT>
1748 template <
typename Traits,
typename LocalOrdinalT>
1752 return rowDOFManagerContainer_->getFieldBlocks();
1755 template <
typename Traits,
typename LocalOrdinalT>
1759 return colDOFManagerContainer_->getFieldBlocks();
1764 #endif // __Panzer_BlockedEpetraLinearObjFactory_impl_hpp__
Teuchos::RCP< VectorType > get_x() const
RCP< const T > getConst() const
void getOwnedAndGhostedNotFilteredIndicator(std::vector< int > &indicator) const
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...
Teuchos::RCP< Epetra_CrsMatrix > getEpetraMatrix(int i, int j) const
Teuchos::RCP< Thyra::VectorBase< double > > getGhostedThyraDomainVector() const
Get a domain vector.
bool is_null(const boost::shared_ptr< T > &p)
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 > getGhostedColMap(int i) const
get the ghosted map from the matrix
virtual void adjustForDirichletConditions(const LinearObjContainer &localBCRows, const LinearObjContainer &globalBCRows, LinearObjContainer &ghostedObjs, bool zeroVectorRows=false, bool adjustX=false) const
const Teuchos::RCP< Epetra_Vector > get_x() const
virtual Teuchos::MpiComm< int > getComm() const
virtual void writeVector(const std::string &identifier, const LinearObjContainer &loc, int id) const
void initializeContainer_internal(int mem, ThyraObjContainer< double > &loc) const
Teuchos::RCP< const Epetra_Comm > eComm_
bool is_null(const std::shared_ptr< T > &p)
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...
virtual void set_x_th(const Teuchos::RCP< Thyra::VectorBase< ScalarT > > &in)=0
const std::vector< Teuchos::RCP< GlobalIndexer > > & getFieldDOFManagers() const
T_To & dyn_cast(T_From &from)
int getBlockColCount() const
how many block columns
Teuchos::RCP< Thyra::VectorBase< double > > getThyraDomainVector() const
Get a domain vector.
void ghostToGlobalThyraVector(const Teuchos::RCP< const Thyra::VectorBase< double > > &in, const Teuchos::RCP< Thyra::VectorBase< double > > &out, bool col) const
void initializeContainer(int, LinearObjContainer &loc) const
virtual const std::vector< panzer::LocalOrdinal > & getElementBlock(const std::string &blockId) const =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
Teuchos::RCP< const GlobalIndexer > getColGlobalIndexer(int i) 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.
virtual void getElementBlockIds(std::vector< std::string > &elementBlockIds) const =0
const Teuchos::RCP< Epetra_CrsMatrix > get_A() const
This class encapsulates the needs of a gather operation to do a // halo exchange for blocked vectors...
virtual const Teuchos::RCP< const Epetra_Comm > getEpetraComm() const
get exporter for converting an overalapped object to a "normal" object
Teuchos::RCP< Thyra::LinearOpBase< double > > getThyraMatrix() const
Get a Thyra operator.
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getThyraRangeSpace() const
Get the range vector space (f)
Teuchos::RCP< Thyra::LinearOpBase< double > > getGhostedThyraMatrix() const
Get a Thyra operator.
virtual void getElementGIDsAsInt(panzer::LocalOrdinal localElmtId, std::vector< int > &gids, const std::string &blockIdHint="") const =0
Get the global IDs for a particular element. This function overwrites the gids variable.
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_CrsGraph > buildGraph(int i, int j) const
int ExtractMyRowView(int MyRow, int &NumEntries, double *&Values, int *&Indices) const
Teuchos::RCP< Thyra::VectorBase< double > > getGhostedThyraRangeVector() const
Get a range vector.
int PutScalar(double ScalarConstant)
virtual const std::vector< LocalOrdinal > & getAssociatedNeighbors(const LocalOrdinal &el) const =0
Teuchos::RCP< Epetra_CrsMatrix > getGhostedEpetraMatrix(int i, int j) const
PHX::MDField< ScalarT, panzer::Cell, panzer::IP > result
A field that will be used to build up the result of the integral we're performing.
virtual ~BlockedEpetraLinearObjFactory()
virtual const Teuchos::RCP< Epetra_CrsGraph > buildFilteredGhostedGraph(int i, int j) const
virtual void globalToGhostContainer(const LinearObjContainer &container, LinearObjContainer &ghostContainer, int) const
int Export(const Epetra_SrcDistObject &A, const Epetra_Import &Importer, Epetra_CombineMode CombineMode, const Epetra_OffsetIndex *Indexor=0)
virtual const Teuchos::RCP< Epetra_Map > getMap(int i) const
get the map from the matrix
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.
This class encapsulates the needs of a gather operation to do a halo exchange for blocked vectors...
Teuchos::RCP< const panzer::BlockedDOFManager > getGlobalIndexer() const
Teuchos::RCP< const DOFManagerContainer > colDOFManagerContainer_
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual const Teuchos::RCP< Epetra_Map > getGhostedMap2(int i) const
Get or create the i-th ghosted map.
void initializeGhostedContainer_internal(int mem, ThyraObjContainer< double > &loc) const
Teuchos::RCP< const Teuchos::OpaqueWrapper< MPI_Comm > > rawMpiComm_
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 const Teuchos::RCP< Epetra_CrsGraph > buildGhostedGraph(int i, int j, bool optimizeStorage) const
BlockedEpetraLinearObjFactory(const Teuchos::RCP< const Teuchos::MpiComm< int > > &comm, const Teuchos::RCP< const GlobalIndexer > &gidProvider, bool useDiscreteAdjoint=false)
void addExcludedPairs(const std::vector< std::pair< int, int > > &exPairs)
exclude a vector of pairs from the matrix
virtual void set_f_th(const Teuchos::RCP< Thyra::VectorBase< ScalarT > > &in)=0
void setRequiresDirichletAdjustment(bool b)
This class provides a boundary exchange communication mechanism for vectors.
virtual const Teuchos::RCP< Epetra_Import > getGhostedImport(int i) const
get importer for converting an overalapped object to a "normal" object
void ghostToGlobalEpetraMatrix(int blockRow, const Epetra_CrsMatrix &in, Epetra_CrsMatrix &out) const
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 Teuchos::RCP< const ConnManager > getConnManager() const =0
Returns the connection manager currently being used.
virtual const Teuchos::RCP< Epetra_Import > getGhostedColImport(int i) const
get importer for converting an overalapped object to a "normal" object
void addExcludedPair(int rowBlock, int colBlock)
exclude a block pair from the matrix
const Teuchos::RCP< Epetra_Vector > get_f() const
void ghostToGlobalEpetraVector(int i, const Epetra_Vector &in, Epetra_Vector &out, bool col) const
virtual const Teuchos::RCP< Epetra_Map > getColMap(int i) const
get the map from the matrix
This class provides a boundary exchange communication mechanism for vectors.
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...
int InsertGlobalIndices(int GlobalRow, int NumIndices, int *Indices)
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.
int ExtractMyRowView(int LocalRow, int &NumIndices, int *&Indices) const
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getThyraDomainSpace() const
Get the domain vector space (x and dxdt)
virtual const Teuchos::RCP< Epetra_CrsGraph > getGraph(int i, int j) const
get the graph of the crs matrix
void initializeGhostedContainer(int, LinearObjContainer &loc) const
void ghostToGlobalThyraMatrix(const Thyra::LinearOpBase< double > &in, Thyra::LinearOpBase< double > &out) const
virtual const Teuchos::RCP< Epetra_Export > getGhostedExport(int j) const
get exporter for converting an overalapped object to a "normal" object
virtual const Teuchos::RCP< Epetra_Map > getGhostedColMap2(int i) const
Get or create the i-th ghosted column map.
void setMapsForBlocks(const std::vector< Teuchos::RCP< const Epetra_Map > > &blockMaps)
int VectorToMatrixMarketFile(const char *filename, const Epetra_Vector &A, const char *matrixName=0, const char *matrixDescription=0, bool writeHeader=true)
int getBlockRowCount() const
how many block rows
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...
int RemoveMyIndices(int LocalRow, int NumIndices, int *Indices)
Teuchos::RCP< Thyra::VectorBase< double > > getThyraRangeVector() const
Get a range vector.
virtual void set_A_th(const Teuchos::RCP< Thyra::LinearOpBase< ScalarT > > &in)=0
Teuchos::RCP< VectorType > get_f() const
virtual const Teuchos::RCP< Epetra_Map > getGhostedMap(int i) const
get the ghosted map from the matrix
int MatrixMarketFileToVector(const char *filename, const Epetra_BlockMap &map, Epetra_Vector *&A)
virtual void readVector(const std::string &identifier, LinearObjContainer &loc, int id) const
virtual Teuchos::RCP< ReadOnlyVector_GlobalEvaluationData > buildReadOnlyDomainContainer() const
virtual Teuchos::RCP< LinearObjContainer > buildGhostedLinearObjContainer() const
virtual bool hasAssociatedNeighbors() const =0
void buildGatherScatterEvaluators(const BuilderT &builder)
virtual void applyDirichletBCs(const LinearObjContainer &counter, LinearObjContainer &result) const
#define TEUCHOS_ASSERT(assertion_test)
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
void globalToGhostEpetraVector(int i, const Epetra_Vector &in, Epetra_Vector &out, bool col) const
virtual Teuchos::RCP< WriteVector_GlobalEvaluationData > buildWriteDomainContainer() const
Teuchos::RCP< Teuchos::MpiComm< int > > tComm_
const Teuchos::RCP< Epetra_Vector > get_dxdt() const
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 Teuchos::RCP< LinearObjContainer > buildLinearObjContainer() const
void globalToGhostThyraVector(const Teuchos::RCP< const Thyra::VectorBase< double > > &in, const Teuchos::RCP< Thyra::VectorBase< double > > &out, bool col) const
Teuchos::RCP< VectorType > get_dxdt() const
virtual void ghostToGlobalContainer(const LinearObjContainer &ghostContainer, LinearObjContainer &container, int) const
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getGhostedThyraRangeSpace() const
Get the range vector space (f)
Teuchos::RCP< const DOFManagerContainer > rowDOFManagerContainer_
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getGhostedThyraDomainSpace() const
Get the domain vector space (x and dxdt)
Teuchos::RCP< const Thyra::VectorSpaceBase< double > > getGhostedThyraDomainSpace2() const
Get or create the ghosted Thyra domain space.
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.