11 #ifndef __Panzer_BlockedEpetraLinearObjFactory_impl_hpp__
12 #define __Panzer_BlockedEpetraLinearObjFactory_impl_hpp__
16 #include "Epetra_CrsMatrix.h"
17 #include "Epetra_MpiComm.h"
18 #include "Epetra_MultiVector.h"
19 #include "Epetra_Vector.h"
35 #include "Thyra_DefaultBlockedLinearOp.hpp"
36 #include "Thyra_DefaultProductVector.hpp"
37 #include "Thyra_DefaultProductVectorSpace.hpp"
38 #include "Thyra_EpetraLinearOp.hpp"
39 #include "Thyra_EpetraThyraWrappers.hpp"
40 #include "Thyra_get_Epetra_Operator.hpp"
41 #include "Thyra_SpmdVectorBase.hpp"
42 #include "Thyra_VectorStdOps.hpp"
52 template <
typename Traits,
typename LocalOrdinalT>
56 bool useDiscreteAdjoint)
57 : useColGidProviders_(false), eComm_(Teuchos::null)
58 , rawMpiComm_(comm->getRawMpiComm())
59 , useDiscreteAdjoint_(useDiscreteAdjoint)
75 template <
typename Traits,
typename LocalOrdinalT>
80 bool useDiscreteAdjoint)
81 : eComm_(Teuchos::null)
82 , rawMpiComm_(comm->getRawMpiComm())
83 , useDiscreteAdjoint_(useDiscreteAdjoint)
101 template <
typename Traits,
typename LocalOrdinalT>
108 template <
typename Traits,
typename LocalOrdinalT>
114 using Teuchos::rcp_dynamic_cast;
137 int blockRows = this->getBlockRowCount();
141 for(
int i=0;i<blockRows;i++) {
146 std::stringstream ss;
147 ss << identifier <<
"-" << i <<
".mm";
158 template <
typename Traits,
typename LocalOrdinalT>
164 using Teuchos::rcp_dynamic_cast;
187 int blockRows = this->getBlockRowCount();
191 for(
int i=0;i<blockRows;i++) {
196 std::stringstream ss;
197 ss << identifier <<
"-" << i <<
".mm";
204 template <
typename Traits,
typename LocalOrdinalT>
208 if(!rowDOFManagerContainer_->containsBlockedDOFManager() && !colDOFManagerContainer_->containsBlockedDOFManager()) {
214 std::vector<Teuchos::RCP<const Epetra_Map> > blockMaps;
215 std::size_t blockDim = getBlockRowCount();
216 for(std::size_t i=0;i<blockDim;i++)
217 blockMaps.push_back(getMap(i));
225 template <
typename Traits,
typename LocalOrdinalT>
229 if(!rowDOFManagerContainer_->containsBlockedDOFManager() && !colDOFManagerContainer_->containsBlockedDOFManager()) {
235 std::vector<Teuchos::RCP<const Epetra_Map> > blockMaps;
236 std::size_t blockDim = getBlockRowCount();
237 for(std::size_t i=0;i<blockDim;i++)
238 blockMaps.push_back(getGhostedMap(i));
246 template <
typename Traits,
typename LocalOrdinalT>
255 if( !rowDOFManagerContainer_->containsBlockedDOFManager()
256 && !colDOFManagerContainer_->containsBlockedDOFManager()) {
263 globalToGhostEpetraVector(0,*e_in.
get_x(),*e_out.get_x(),
true);
266 globalToGhostEpetraVector(0,*e_in.
get_dxdt(),*e_out.get_dxdt(),
true);
269 globalToGhostEpetraVector(0,*e_in.
get_f(),*e_out.get_f(),
false);
277 if ( !
is_null(b_in.get_x()) && !
is_null(b_out.get_x()) && ((mem & LOC::X)==LOC::X))
278 globalToGhostThyraVector(b_in.get_x(),b_out.get_x(),
true);
280 if ( !
is_null(b_in.get_dxdt()) && !
is_null(b_out.get_dxdt()) && ((mem & LOC::DxDt)==LOC::DxDt))
281 globalToGhostThyraVector(b_in.get_dxdt(),b_out.get_dxdt(),
true);
283 if ( !
is_null(b_in.get_f()) && !
is_null(b_out.get_f()) && ((mem & LOC::F)==LOC::F))
284 globalToGhostThyraVector(b_in.get_f(),b_out.get_f(),
false);
288 template <
typename Traits,
typename LocalOrdinalT>
297 if( !rowDOFManagerContainer_->containsBlockedDOFManager()
298 && !colDOFManagerContainer_->containsBlockedDOFManager()) {
305 ghostToGlobalEpetraVector(0,*e_in.
get_x(),*e_out.get_x(),
true);
308 ghostToGlobalEpetraVector(0,*e_in.
get_f(),*e_out.get_f(),
false);
311 ghostToGlobalEpetraMatrix(0,*e_in.
get_A(),*e_out.get_A());
319 if ( !
is_null(b_in.get_x()) && !
is_null(b_out.get_x()) && ((mem & LOC::X)==LOC::X))
320 ghostToGlobalThyraVector(b_in.get_x(),b_out.get_x(),
true);
322 if ( !
is_null(b_in.get_f()) && !
is_null(b_out.get_f()) && ((mem & LOC::F)==LOC::F))
323 ghostToGlobalThyraVector(b_in.get_f(),b_out.get_f(),
false);
325 if ( !
is_null(b_in.get_A()) && !
is_null(b_out.get_A()) && ((mem & LOC::Mat)==LOC::Mat))
326 ghostToGlobalThyraMatrix(*b_in.get_A(),*b_out.get_A());
330 template <
typename Traits,
typename LocalOrdinalT>
335 bool zeroVectorRows,
bool adjustX)
const
340 using Teuchos::rcp_dynamic_cast;
342 using Thyra::PhysicallyBlockedLinearOpBase;
345 using Thyra::get_Epetra_Vector;
346 using Thyra::get_Epetra_Operator;
348 int rBlockDim = getBlockRowCount();
349 int cBlockDim = getBlockColCount();
361 if(A==Teuchos::null && b_ghosted.get_A_th()!=Teuchos::null) {
363 A = rcp_dynamic_cast<PhysicallyBlockedLinearOpBase<double> >(Thyra::nonconstBlock1x1(b_ghosted.get_A_th()));
368 : Thyra::castOrCreateNonconstProductVectorBase(b_ghosted.get_f_th());
371 : Thyra::castOrCreateNonconstProductVectorBase(b_localBCRows.get_f_th());
374 : Thyra::castOrCreateNonconstProductVectorBase(b_globalBCRows.get_f_th());
376 if(adjustX) f = Thyra::castOrCreateNonconstProductVectorBase(b_ghosted.get_x_th());
379 if(A!=Teuchos::null)
TEUCHOS_ASSERT(A->productRange()->numBlocks()==rBlockDim);
380 if(A!=Teuchos::null)
TEUCHOS_ASSERT(A->productDomain()->numBlocks()==cBlockDim);
381 if(f!=Teuchos::null)
TEUCHOS_ASSERT(f->productSpace()->numBlocks()==rBlockDim);
382 TEUCHOS_ASSERT(local_bcs->productSpace()->numBlocks()==rBlockDim);
383 TEUCHOS_ASSERT(global_bcs->productSpace()->numBlocks()==rBlockDim);
385 for(
int i=0;i<rBlockDim;i++) {
393 if(th_f==Teuchos::null)
396 e_f = get_Epetra_Vector(*getGhostedMap(i),th_f);
398 for(
int j=0;j<cBlockDim;j++) {
405 if(th_A==Teuchos::null)
411 adjustForDirichletConditions(*e_local_bcs,*e_global_bcs,e_f.
ptr(),e_A.
ptr(),zeroVectorRows);
418 template <
typename Traits,
typename LocalOrdinalT>
424 bool zeroVectorRows)
const
426 if(f==Teuchos::null && A==Teuchos::null)
430 for(
int i=0;i<local_bcs.MyLength();i++) {
431 if(global_bcs[i]==0.0)
438 if(local_bcs[i]==0.0 || zeroVectorRows) {
446 for(
int c=0;c<numEntries;c++)
453 double scaleFactor = global_bcs[i];
457 (*f)[i] /= scaleFactor;
460 for(
int c=0;c<numEntries;c++)
461 values[c] /= scaleFactor;
467 template <
typename Traits,
typename LocalOrdinalT>
473 using Teuchos::rcp_dynamic_cast;
483 RCP<PVector> f_out = Thyra::castOrCreateNonconstProductVectorBase(th_result.get_f_th());
485 int rBlockDim = getBlockRowCount();
486 for(
int i=0;i<rBlockDim;i++) {
491 rcp_dynamic_cast<
const Thyra::SpmdVectorBase<double> >(count->getVectorBlock(i),
true)->getLocalData(Teuchos::ptrFromRef(count_array));
492 rcp_dynamic_cast<
const Thyra::SpmdVectorBase<double> >(f_in->getVectorBlock(i),
true)->getLocalData(Teuchos::ptrFromRef(f_in_array));
493 rcp_dynamic_cast<Thyra::SpmdVectorBase<double> >(f_out->getNonconstVectorBlock(i),
true)->getNonconstLocalData(Teuchos::ptrFromRef(f_out_array));
499 if(count_array[j]!=0.0)
500 f_out_array[j] = f_in_array[j];
510 template<
typename Traits,
typename LocalOrdinalT>
524 if (not colDOFManagerContainer_->containsBlockedDOFManager())
526 auto ged =
rcp(
new EVROGED);
527 ged->initialize(getGhostedColImport2(0), getGhostedColMap2(0),
533 vector<RCP<ROVGED>> gedBlocks;
534 for (
int i(0); i < getBlockColCount(); ++i)
536 auto vecGed =
rcp(
new EVROGED);
537 vecGed->initialize(getGhostedColImport2(i), getGhostedColMap2(i),
539 gedBlocks.push_back(vecGed);
541 auto ged =
rcp(
new BVROGED);
542 ged->initialize(getGhostedThyraDomainSpace2(), getThyraDomainSpace(),
552 template<
typename Traits,
typename LocalOrdinalT>
566 if (not colDOFManagerContainer_->containsBlockedDOFManager())
568 auto ged =
rcp(
new EVWGED);
569 ged->initialize(getGhostedColExport2(0), getGhostedColMap2(0),
575 vector<RCP<WVGED>> gedBlocks;
576 for (
int i(0); i < getBlockColCount(); ++i)
578 auto vecGed =
rcp(
new EVWGED);
579 vecGed->initialize(getGhostedColExport2(i), getGhostedColMap2(i),
581 gedBlocks.push_back(vecGed);
583 auto ged =
rcp(
new BVWGED);
584 ged->initialize(getGhostedThyraDomainSpace2(), getThyraDomainSpace(),
589 template <
typename Traits,
typename LocalOrdinalT>
596 template <
typename Traits,
typename LocalOrdinalT>
603 initializeContainer_internal(mem,toc);
606 template <
typename Traits,
typename LocalOrdinalT>
614 initializeGhostedContainer_internal(mem,toc);
616 if(rowDOFManagerContainer_->containsBlockedDOFManager()) {
621 if((mem & LOC::F) == LOC::F)
622 bloc.setRequiresDirichletAdjustment(
true);
624 if((mem & LOC::Mat) == LOC::Mat)
625 bloc.setRequiresDirichletAdjustment(
true);
630 if((mem & LOC::F) == LOC::F)
633 if((mem & LOC::Mat) == LOC::Mat)
641 template <
typename Traits,
typename LocalOrdinalT>
649 if((mem & LOC::X) == LOC::X)
650 loc.
set_x_th(getThyraDomainVector());
652 if((mem & LOC::DxDt) == LOC::DxDt)
655 if((mem & LOC::F) == LOC::F)
656 loc.
set_f_th(getThyraRangeVector());
658 if((mem & LOC::Mat) == LOC::Mat)
662 template <
typename Traits,
typename LocalOrdinalT>
670 if((mem & LOC::X) == LOC::X)
671 loc.
set_x_th(getGhostedThyraDomainVector());
673 if((mem & LOC::DxDt) == LOC::DxDt)
676 if((mem & LOC::F) == LOC::F)
677 loc.
set_f_th(getGhostedThyraRangeVector());
679 if((mem & LOC::Mat) == LOC::Mat)
680 loc.
set_A_th(getGhostedThyraMatrix());
683 template <
typename Traits,
typename LocalOrdinalT>
687 excludedPairs_.insert(std::make_pair(rowBlock,colBlock));
690 template <
typename Traits,
typename LocalOrdinalT>
694 for(std::size_t i=0;i<exPairs.size();i++)
695 excludedPairs_.insert(exPairs[i]);
698 template <
typename Traits,
typename LocalOrdinalT>
705 template <
typename Traits,
typename LocalOrdinalT>
709 return colDOFManagerContainer_->getFieldDOFManagers()[i];
717 template<
typename Traits,
typename LocalOrdinalT>
721 std::size_t blockCnt,
722 std::size_t colBlockCnt)
724 maps_.resize(blockCnt);
725 ghostedMaps_.resize(blockCnt);
726 ghostedMaps2_.resize(blockCnt);
727 importers_.resize(blockCnt);
728 importers2_.resize(blockCnt);
729 exporters_.resize(blockCnt);
732 colMaps_.resize(colBlockCnt);
733 colGhostedMaps_.resize(colBlockCnt);
734 colGhostedMaps2_.resize(colBlockCnt);
735 colImporters_.resize(colBlockCnt);
736 colImporters2_.resize(colBlockCnt);
737 colExporters_.resize(colBlockCnt);
744 template <
typename Traits,
typename LocalOrdinalT>
748 if(domainSpace_==Teuchos::null) {
749 if(colDOFManagerContainer_->containsBlockedDOFManager()) {
751 std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > > vsArray;
752 for(
int i=0;i<getBlockColCount();i++)
753 vsArray.push_back(Thyra::create_VectorSpace(getColMap(i)));
755 domainSpace_ = Thyra::productVectorSpace<double>(vsArray);
760 domainSpace_ = Thyra::create_VectorSpace(getColMap(0));
767 template <
typename Traits,
typename LocalOrdinalT>
771 if(rangeSpace_==Teuchos::null) {
772 if(rowDOFManagerContainer_->containsBlockedDOFManager()) {
774 std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > > vsArray;
775 for(
int i=0;i<getBlockRowCount();i++)
776 vsArray.push_back(Thyra::create_VectorSpace(getMap(i)));
778 rangeSpace_ = Thyra::productVectorSpace<double>(vsArray);
783 rangeSpace_ = Thyra::create_VectorSpace(getMap(0));
790 template <
typename Traits,
typename LocalOrdinalT>
795 Thyra::createMember<double>(*getThyraDomainSpace());
796 Thyra::assign(vec.
ptr(),0.0);
801 template <
typename Traits,
typename LocalOrdinalT>
806 Thyra::createMember<double>(*getThyraRangeSpace());
807 Thyra::assign(vec.
ptr(),0.0);
812 template <
typename Traits,
typename LocalOrdinalT>
817 if(!rowDOFManagerContainer_->containsBlockedDOFManager() &&
818 !colDOFManagerContainer_->containsBlockedDOFManager()) {
819 return Thyra::nonconstEpetraLinearOp(getEpetraMatrix(0,0));
825 std::size_t rBlockDim = getBlockRowCount();
826 std::size_t cBlockDim = getBlockColCount();
829 blockedOp->beginBlockFill(rBlockDim,cBlockDim);
832 for(std::size_t i=0;i<rBlockDim;i++) {
833 for(std::size_t j=0;j<cBlockDim;j++) {
834 if(excludedPairs_.find(std::make_pair(i,j))==excludedPairs_.end()) {
837 blockedOp->setNonconstBlock(i,j,block);
843 blockedOp->endBlockFill();
853 template<
typename Traits,
typename LocalOrdinalT>
860 using Thyra::create_VectorSpace;
861 using Thyra::productVectorSpace;
863 if (ghostedDomainSpace_.is_null())
865 if (colDOFManagerContainer_->containsBlockedDOFManager())
868 vector<RCP<const VectorSpaceBase<double>>> vsArray;
869 for (
int i(0); i < getBlockColCount(); ++i)
870 vsArray.push_back(create_VectorSpace(getGhostedColMap(i)));
871 ghostedDomainSpace_ = productVectorSpace<double>(vsArray);
877 ghostedDomainSpace_ = create_VectorSpace(getGhostedColMap(0));
880 return ghostedDomainSpace_;
888 template<
typename Traits,
typename LocalOrdinalT>
895 using Thyra::create_VectorSpace;
896 using Thyra::productVectorSpace;
898 if (ghostedDomainSpace_.is_null())
900 if (colDOFManagerContainer_->containsBlockedDOFManager())
903 vector<RCP<const VectorSpaceBase<double>>> vsArray;
904 for (
int i(0); i < getBlockColCount(); ++i)
905 vsArray.push_back(create_VectorSpace(getGhostedColMap2(i)));
906 ghostedDomainSpace_ = productVectorSpace<double>(vsArray);
912 ghostedDomainSpace_ = create_VectorSpace(getGhostedColMap2(0));
915 return ghostedDomainSpace_;
918 template <
typename Traits,
typename LocalOrdinalT>
922 if(ghostedRangeSpace_==Teuchos::null) {
923 if(rowDOFManagerContainer_->containsBlockedDOFManager()) {
925 std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > > vsArray;
926 for(
int i=0;i<getBlockRowCount();i++)
927 vsArray.push_back(Thyra::create_VectorSpace(getGhostedMap(i)));
929 ghostedRangeSpace_ = Thyra::productVectorSpace<double>(vsArray);
934 ghostedRangeSpace_ = Thyra::create_VectorSpace(getGhostedMap(0));
938 return ghostedRangeSpace_;
941 template <
typename Traits,
typename LocalOrdinalT>
946 Thyra::createMember<double>(*getGhostedThyraDomainSpace());
947 Thyra::assign(vec.
ptr(),0.0);
952 template <
typename Traits,
typename LocalOrdinalT>
957 Thyra::createMember<double>(*getGhostedThyraRangeSpace());
958 Thyra::assign(vec.
ptr(),0.0);
963 template <
typename Traits,
typename LocalOrdinalT>
968 if(!rowDOFManagerContainer_->containsBlockedDOFManager() &&
969 !colDOFManagerContainer_->containsBlockedDOFManager()) {
970 return Thyra::nonconstEpetraLinearOp(getGhostedEpetraMatrix(0,0));
976 std::size_t rBlockDim = getBlockRowCount();
977 std::size_t cBlockDim = getBlockColCount();
980 blockedOp->beginBlockFill(rBlockDim,cBlockDim);
983 for(std::size_t i=0;i<rBlockDim;i++) {
984 for(std::size_t j=0;j<cBlockDim;j++) {
985 if(excludedPairs_.find(std::make_pair(i,j))==excludedPairs_.end()) {
988 blockedOp->setNonconstBlock(i,j,block);
994 blockedOp->endBlockFill();
999 template <
typename Traits,
typename LocalOrdinalT>
1005 using Teuchos::rcp_dynamic_cast;
1007 using Thyra::get_Epetra_Vector;
1009 std::size_t blockDim = col ? getBlockColCount() : getBlockRowCount();
1015 TEUCHOS_ASSERT(prod_in->productSpace()->numBlocks()==(int) blockDim);
1016 TEUCHOS_ASSERT(prod_out->productSpace()->numBlocks()==(int) blockDim);
1018 for(std::size_t i=0;i<blockDim;i++) {
1024 ep_in = get_Epetra_Vector(*getGhostedMap(i),prod_in->getVectorBlock(i));
1025 ep_out = get_Epetra_Vector(*getMap(i),prod_out->getNonconstVectorBlock(i));
1027 ep_in = get_Epetra_Vector(*getGhostedColMap(i),prod_in->getVectorBlock(i));
1028 ep_out = get_Epetra_Vector(*getColMap(i),prod_out->getNonconstVectorBlock(i));
1032 ghostToGlobalEpetraVector(i,*ep_in,*ep_out,col);
1036 template <
typename Traits,
typename LocalOrdinalT>
1041 using Teuchos::rcp_dynamic_cast;
1044 using Thyra::PhysicallyBlockedLinearOpBase;
1045 using Thyra::get_Epetra_Operator;
1048 std::size_t rBlockDim = getBlockRowCount();
1049 std::size_t cBlockDim = getBlockColCount();
1052 const PhysicallyBlockedLinearOpBase<double> & prod_in =
dyn_cast<
const PhysicallyBlockedLinearOpBase<double> >(in);
1053 PhysicallyBlockedLinearOpBase<double> & prod_out =
dyn_cast<PhysicallyBlockedLinearOpBase<double> >(out);
1055 TEUCHOS_ASSERT(prod_in.productRange()->numBlocks()==(int) rBlockDim);
1056 TEUCHOS_ASSERT(prod_in.productDomain()->numBlocks()==(int) cBlockDim);
1057 TEUCHOS_ASSERT(prod_out.productRange()->numBlocks()==(int) rBlockDim);
1058 TEUCHOS_ASSERT(prod_out.productDomain()->numBlocks()==(int) cBlockDim);
1060 for(std::size_t i=0;i<rBlockDim;i++) {
1061 for(std::size_t j=0;j<cBlockDim;j++) {
1062 if(excludedPairs_.find(std::make_pair(i,j))==excludedPairs_.end()) {
1076 ghostToGlobalEpetraMatrix(i,*ep_in,*ep_out);
1082 template <
typename Traits,
typename LocalOrdinalT>
1088 using Teuchos::rcp_dynamic_cast;
1090 using Thyra::get_Epetra_Vector;
1092 std::size_t blockDim = col ? getBlockColCount() : getBlockRowCount();
1098 TEUCHOS_ASSERT(prod_in->productSpace()->numBlocks()==(int) blockDim);
1099 TEUCHOS_ASSERT(prod_out->productSpace()->numBlocks()==(int) blockDim);
1101 for(std::size_t i=0;i<blockDim;i++) {
1107 ep_in = get_Epetra_Vector(*getMap(i),prod_in->getVectorBlock(i));
1108 ep_out = get_Epetra_Vector(*getGhostedMap(i),prod_out->getNonconstVectorBlock(i));
1111 ep_in = get_Epetra_Vector(*getColMap(i),prod_in->getVectorBlock(i));
1112 ep_out = get_Epetra_Vector(*getGhostedColMap(i),prod_out->getNonconstVectorBlock(i));
1116 globalToGhostEpetraVector(i,*ep_in,*ep_out,col);
1123 template <
typename Traits,
typename LocalOrdinalT>
1132 int err = out.Export(in,*exporter,
Add);
1136 template <
typename Traits,
typename LocalOrdinalT>
1145 int err = out.Export(in,*exporter,
Add);
1149 template <
typename Traits,
typename LocalOrdinalT>
1158 int err = out.Import(in,*importer,
Insert);
1163 template <
typename Traits,
typename LocalOrdinalT>
1167 if(maps_[i]==Teuchos::null)
1168 maps_[i] = buildMap(i);
1174 template <
typename Traits,
typename LocalOrdinalT>
1178 if(not useColGidProviders_)
1181 if(colMaps_[i]==Teuchos::null)
1182 colMaps_[i] = buildColMap(i);
1192 template<
typename Traits,
typename LocalOrdinalT>
1198 if (ghostedMaps_[i].
is_null())
1199 ghostedMaps_[i] = buildGhostedMap(i);
1200 return ghostedMaps_[i];
1208 template<
typename Traits,
typename LocalOrdinalT>
1214 if (ghostedMaps2_[i].
is_null())
1215 ghostedMaps2_[i] = buildGhostedMap2(i);
1216 return ghostedMaps2_[i];
1224 template<
typename Traits,
typename LocalOrdinalT>
1230 if (not useColGidProviders_)
1231 return getGhostedMap(i);
1232 if (colGhostedMaps_[i].
is_null())
1233 colGhostedMaps_[i] = buildColGhostedMap(i);
1234 return colGhostedMaps_[i];
1242 template<
typename Traits,
typename LocalOrdinalT>
1248 if (not useColGidProviders_)
1249 return getGhostedMap2(i);
1250 if (colGhostedMaps2_[i].
is_null())
1251 colGhostedMaps2_[i] = buildColGhostedMap2(i);
1252 return colGhostedMaps2_[i];
1256 template <
typename Traits,
typename LocalOrdinalT>
1262 GraphMap::const_iterator itr = graphs_.find(std::make_pair(i,j));
1263 Teuchos::RCP<Epetra_CrsGraph> graph;
1264 if(itr==graphs_.end()) {
1265 graph = buildGraph(i,j);
1266 graphs_[std::make_pair(i,j)] = graph;
1269 graph = itr->second;
1275 template <
typename Traits,
typename LocalOrdinalT>
1281 GraphMap::const_iterator itr = ghostedGraphs_.find(std::make_pair(i,j));
1282 Teuchos::RCP<Epetra_CrsGraph> ghostedGraph;
1283 if(itr==ghostedGraphs_.end()) {
1284 ghostedGraph = buildGhostedGraph(i,j,
true);
1285 ghostedGraphs_[std::make_pair(i,j)] = ghostedGraph;
1288 ghostedGraph = itr->second;
1291 return ghostedGraph;
1299 template<
typename Traits,
typename LocalOrdinalT>
1308 return importers_[i];
1316 template<
typename Traits,
typename LocalOrdinalT>
1325 return importers2_[i];
1333 template<
typename Traits,
typename LocalOrdinalT>
1340 if (not useColGidProviders_)
1341 return getGhostedImport(i);
1342 if (colImporters_[i].
is_null())
1345 return colImporters_[i];
1353 template<
typename Traits,
typename LocalOrdinalT>
1360 if (not useColGidProviders_)
1361 return getGhostedImport2(i);
1362 if (colImporters2_[i].
is_null())
1365 return colImporters2_[i];
1373 template<
typename Traits,
typename LocalOrdinalT>
1382 return exporters_[i];
1390 template<
typename Traits,
typename LocalOrdinalT>
1399 return exporters_[i];
1407 template<
typename Traits,
typename LocalOrdinalT>
1414 if (not useColGidProviders_)
1415 return getGhostedExport(i);
1416 if (colExporters_[i].
is_null())
1419 return colExporters_[i];
1427 template<
typename Traits,
typename LocalOrdinalT>
1434 if (not useColGidProviders_)
1435 return getGhostedExport2(i);
1436 if (colExporters_[i].
is_null())
1439 return colExporters_[i];
1442 template <
typename Traits,
typename LocalOrdinalT>
1446 std::vector<int> indices;
1449 getGlobalIndexer(i)->getOwnedIndicesAsInt(indices);
1454 template <
typename Traits,
typename LocalOrdinalT>
1458 if(not useColGidProviders_)
1461 std::vector<int> indices;
1464 getColGlobalIndexer(i)->getOwnedIndicesAsInt(indices);
1474 template<
typename Traits,
typename LocalOrdinalT>
1482 vector<int> indices;
1483 getGlobalIndexer(i)->getOwnedAndGhostedIndicesAsInt(indices);
1484 return rcp(
new Epetra_Map(-1, indices.size(), &indices[0], 0, *eComm_));
1492 template<
typename Traits,
typename LocalOrdinalT>
1500 vector<int> indices;
1501 getGlobalIndexer(i)->getGhostedIndicesAsInt(indices);
1502 return rcp(
new Epetra_Map(-1, indices.size(), &indices[0], 0, *eComm_));
1510 template<
typename Traits,
typename LocalOrdinalT>
1518 if (not useColGidProviders_)
1519 return buildGhostedMap(i);
1520 vector<int> indices;
1521 getColGlobalIndexer(i)->getOwnedAndGhostedIndicesAsInt(indices);
1522 return rcp(
new Epetra_Map(-1, indices.size(), &indices[0], 0, *eComm_));
1530 template<
typename Traits,
typename LocalOrdinalT>
1538 if (not useColGidProviders_)
1539 return buildGhostedMap2(i);
1540 vector<int> indices;
1541 getColGlobalIndexer(i)->getGhostedIndicesAsInt(indices);
1542 return rcp(
new Epetra_Map(-1, indices.size(), &indices[0], 0, *eComm_));
1546 template <
typename Traits,
typename LocalOrdinalT>
1576 template <
typename Traits,
typename LocalOrdinalT>
1585 std::vector<std::string> elementBlockIds;
1589 rowProvider = getGlobalIndexer(i);
1590 colProvider = getColGlobalIndexer(j);
1599 std::vector<std::string>::const_iterator blockItr;
1600 for(blockItr=elementBlockIds.begin();blockItr!=elementBlockIds.end();++blockItr) {
1601 std::string blockId = *blockItr;
1604 const std::vector<LocalOrdinalT> & elements = rowProvider->
getElementBlock(blockId);
1608 std::vector<int> row_gids;
1609 std::vector<int> col_gids;
1612 for(std::size_t elmt=0;elmt<elements.size();elmt++) {
1618 for (
typename std::vector<LocalOrdinalT>::const_iterator eit = aes.begin();
1619 eit != aes.end(); ++eit) {
1620 std::vector<int> other_col_gids;
1622 col_gids.insert(col_gids.end(), other_col_gids.begin(), other_col_gids.end());
1626 for(std::size_t row=0;row<row_gids.size();row++)
1640 template <
typename Traits,
typename LocalOrdinalT>
1646 using Teuchos::rcp_dynamic_cast;
1653 if(filtered_ugi==Teuchos::null)
1654 return buildGhostedGraph(i,j,
true);
1657 std::vector<int> ghostedActive;
1665 for(
int k=0;k<filteredGraph->
NumMyRows();++k) {
1666 std::vector<int> removedIndices;
1671 for(
int m=0;m<numIndices;++m) {
1672 if(ghostedActive[indices[m]]==0)
1673 removedIndices.push_back(indices[m]);
1686 return filteredGraph;
1689 template <
typename Traits,
typename LocalOrdinalT>
1699 template <
typename Traits,
typename LocalOrdinalT>
1709 template <
typename Traits,
typename LocalOrdinalT>
1716 template <
typename Traits,
typename LocalOrdinalT>
1720 return rowDOFManagerContainer_->getFieldBlocks();
1723 template <
typename Traits,
typename LocalOrdinalT>
1727 return colDOFManagerContainer_->getFieldBlocks();
1732 #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.