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"
22#include "EpetraExt_VectorIn.h"
23#include "EpetraExt_VectorOut.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"
52template <
typename Traits,
typename LocalOrdinalT>
55 const Teuchos::RCP<const GlobalIndexer> & gidProvider,
56 bool useDiscreteAdjoint)
75template <
typename Traits,
typename LocalOrdinalT>
78 const Teuchos::RCP<const GlobalIndexer> & gidProvider,
79 const Teuchos::RCP<const GlobalIndexer> & colGidProvider,
80 bool useDiscreteAdjoint)
101template <
typename Traits,
typename LocalOrdinalT>
108template <
typename Traits,
typename LocalOrdinalT>
114 using Teuchos::rcp_dynamic_cast;
115 using Teuchos::dyn_cast;
121 RCP<Thyra::VectorBase<double> > vec;
133 TEUCHOS_ASSERT(
false);
138 RCP<ProductVectorBase<double> > b_vec = Thyra::nonconstProductVectorBase(vec);
141 for(
int i=0;i<blockRows;i++) {
142 RCP<Thyra::VectorBase<double> > x = b_vec->getNonconstVectorBlock(i);
143 RCP<Epetra_Vector> ex = Thyra::get_Epetra_Vector(*
getMap(i),x);
146 std::stringstream ss;
147 ss << identifier <<
"-" << i <<
".mm";
150 Epetra_Vector * ptr_ex = 0;
151 TEUCHOS_ASSERT(0==EpetraExt::MatrixMarketFileToVector(ss.str().c_str(),*
getMap(i),ptr_ex));
158template <
typename Traits,
typename LocalOrdinalT>
164 using Teuchos::rcp_dynamic_cast;
165 using Teuchos::dyn_cast;
171 RCP<const Thyra::VectorBase<double> > vec;
183 TEUCHOS_ASSERT(
false);
188 RCP<const ProductVectorBase<double> > b_vec = Thyra::productVectorBase(vec);
191 for(
int i=0;i<blockRows;i++) {
192 RCP<const Thyra::VectorBase<double> > x = b_vec->getVectorBlock(i);
193 RCP<const Epetra_Vector> ex = Thyra::get_Epetra_Vector(*
getMap(i),x);
196 std::stringstream ss;
197 ss << identifier <<
"-" << i <<
".mm";
200 TEUCHOS_ASSERT(0==EpetraExt::VectorToMatrixMarketFile(ss.str().c_str(),*ex));
204template <
typename Traits,
typename LocalOrdinalT>
214 std::vector<Teuchos::RCP<const Epetra_Map> > blockMaps;
216 for(std::size_t i=0;i<blockDim;i++)
217 blockMaps.push_back(
getMap(i));
220 container->setMapsForBlocks(blockMaps);
225template <
typename Traits,
typename LocalOrdinalT>
235 std::vector<Teuchos::RCP<const Epetra_Map> > blockMaps;
237 for(std::size_t i=0;i<blockDim;i++)
241 container->setMapsForBlocks(blockMaps);
246template <
typename Traits,
typename LocalOrdinalT>
250 using Teuchos::is_null;
262 if ( !is_null(e_in.
get_x()) && !is_null(e_out.
get_x()) && ((mem & LOC::X)==LOC::X))
265 if ( !is_null(e_in.
get_dxdt()) && !is_null(e_out.
get_dxdt()) && ((mem & LOC::DxDt)==LOC::DxDt))
268 if ( !is_null(e_in.
get_f()) && !is_null(e_out.
get_f()) && ((mem & LOC::F)==LOC::F))
272 const BLOC & b_in = Teuchos::dyn_cast<const BLOC>(in);
273 BLOC & b_out = Teuchos::dyn_cast<BLOC>(out);
277 if ( !is_null(b_in.get_x()) && !is_null(b_out.get_x()) && ((mem & LOC::X)==LOC::X))
280 if ( !is_null(b_in.get_dxdt()) && !is_null(b_out.get_dxdt()) && ((mem & LOC::DxDt)==LOC::DxDt))
283 if ( !is_null(b_in.get_f()) && !is_null(b_out.get_f()) && ((mem & LOC::F)==LOC::F))
288template <
typename Traits,
typename LocalOrdinalT>
292 using Teuchos::is_null;
304 if ( !is_null(e_in.
get_x()) && !is_null(e_out.
get_x()) && ((mem & LOC::X)==LOC::X))
307 if ( !is_null(e_in.
get_f()) && !is_null(e_out.
get_f()) && ((mem & LOC::F)==LOC::F))
310 if ( !is_null(e_in.
get_A()) && !is_null(e_out.
get_A()) && ((mem & LOC::Mat)==LOC::Mat))
314 const BLOC & b_in = Teuchos::dyn_cast<const BLOC>(in);
315 BLOC & b_out = Teuchos::dyn_cast<BLOC>(out);
319 if ( !is_null(b_in.get_x()) && !is_null(b_out.get_x()) && ((mem & LOC::X)==LOC::X))
322 if ( !is_null(b_in.get_f()) && !is_null(b_out.get_f()) && ((mem & LOC::F)==LOC::F))
325 if ( !is_null(b_in.get_A()) && !is_null(b_out.get_A()) && ((mem & LOC::Mat)==LOC::Mat))
330template <
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;
352 const TOC & b_localBCRows = Teuchos::dyn_cast<const TOC>(localBCRows);
353 const TOC & b_globalBCRows = Teuchos::dyn_cast<const TOC>(globalBCRows);
354 TOC & b_ghosted = Teuchos::dyn_cast<TOC>(ghostedObjs);
356 TEUCHOS_ASSERT(b_localBCRows.get_f_th()!=Teuchos::null);
357 TEUCHOS_ASSERT(b_globalBCRows.get_f_th()!=Teuchos::null);
360 RCP<PhysicallyBlockedLinearOpBase<double> > A = rcp_dynamic_cast<PhysicallyBlockedLinearOpBase<double> >(b_ghosted.get_A_th());
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()));
366 RCP<ProductVectorBase<double> > f = b_ghosted.get_f_th()==Teuchos::null
368 : Thyra::castOrCreateNonconstProductVectorBase(b_ghosted.get_f_th());
369 RCP<ProductVectorBase<double> > local_bcs = b_localBCRows.get_f_th()==Teuchos::null
371 : Thyra::castOrCreateNonconstProductVectorBase(b_localBCRows.get_f_th());
372 RCP<ProductVectorBase<double> > global_bcs = b_globalBCRows.get_f_th()==Teuchos::null
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++) {
387 RCP<const Epetra_Vector> e_local_bcs = get_Epetra_Vector(*
getGhostedMap(i),local_bcs->getVectorBlock(i));
388 RCP<const Epetra_Vector> e_global_bcs = get_Epetra_Vector(*
getGhostedMap(i),global_bcs->getVectorBlock(i));
391 RCP<VectorBase<double> > th_f = (f==Teuchos::null) ? Teuchos::null : f->getNonconstVectorBlock(i);
392 RCP<Epetra_Vector> e_f;
393 if(th_f==Teuchos::null)
398 for(
int j=0;j<cBlockDim;j++) {
401 RCP<LinearOpBase<double> > th_A = (A== Teuchos::null)? Teuchos::null : A->getNonconstBlock(i,j);
404 RCP<Epetra_CrsMatrix> e_A;
405 if(th_A==Teuchos::null)
408 e_A = rcp_dynamic_cast<Epetra_CrsMatrix>(get_Epetra_Operator(*th_A),
true);
418template <
typename Traits,
typename LocalOrdinalT>
421 const Epetra_Vector & global_bcs,
422 const Teuchos::Ptr<Epetra_Vector> & f,
423 const Teuchos::Ptr<Epetra_CrsMatrix> & A,
424 bool zeroVectorRows)
const
426 if(f==Teuchos::null && A==Teuchos::null)
429 TEUCHOS_ASSERT(local_bcs.MyLength()==global_bcs.MyLength());
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) {
442 if(!Teuchos::is_null(f))
444 if(!Teuchos::is_null(A)) {
445 A->ExtractMyRowView(i,numEntries,values,indices);
446 for(
int c=0;c<numEntries;c++)
453 double scaleFactor = global_bcs[i];
456 if(!Teuchos::is_null(f))
457 (*f)[i] /= scaleFactor;
458 if(!Teuchos::is_null(A)) {
459 A->ExtractMyRowView(i,numEntries,values,indices);
460 for(
int c=0;c<numEntries;c++)
461 values[c] /= scaleFactor;
467template <
typename Traits,
typename LocalOrdinalT>
473 using Teuchos::rcp_dynamic_cast;
474 using Teuchos::dyn_cast;
481 RCP<const PVector> count = Thyra::castOrCreateProductVectorBase(th_counter.
get_f_th().getConst());
482 RCP<const PVector> f_in = Thyra::castOrCreateProductVectorBase(th_counter.
get_f_th().getConst());
483 RCP<PVector> f_out = Thyra::castOrCreateNonconstProductVectorBase(th_result.get_f_th());
486 for(
int i=0;i<rBlockDim;i++) {
488 Teuchos::ArrayRCP<const double> count_array,f_in_array;
489 Teuchos::ArrayRCP<double> f_out_array;
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));
495 TEUCHOS_ASSERT(count_array.size()==f_in_array.size());
496 TEUCHOS_ASSERT(count_array.size()==f_out_array.size());
498 for(Teuchos::ArrayRCP<double>::size_type j=0;j<count_array.size();++j) {
499 if(count_array[j]!=0.0)
500 f_out_array[j] = f_in_array[j];
510template<
typename Traits,
typename LocalOrdinalT>
511Teuchos::RCP<ReadOnlyVector_GlobalEvaluationData>
526 auto ged = rcp(
new EVROGED);
533 vector<RCP<ROVGED>> gedBlocks;
536 auto vecGed = rcp(
new EVROGED);
539 gedBlocks.push_back(vecGed);
541 auto ged = rcp(
new BVROGED);
552template<
typename Traits,
typename LocalOrdinalT>
553Teuchos::RCP<WriteVector_GlobalEvaluationData>
568 auto ged = rcp(
new EVWGED);
575 vector<RCP<WVGED>> gedBlocks;
578 auto vecGed = rcp(
new EVWGED);
581 gedBlocks.push_back(vecGed);
583 auto ged = rcp(
new BVWGED);
589template <
typename Traits,
typename LocalOrdinalT>
596template <
typename Traits,
typename LocalOrdinalT>
602 TOC & toc = Teuchos::dyn_cast<TOC>(loc);
606template <
typename Traits,
typename LocalOrdinalT>
613 TOC & toc = Teuchos::dyn_cast<TOC>(loc);
619 BLOC & bloc = Teuchos::dyn_cast<BLOC>(loc);
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)
641template <
typename Traits,
typename LocalOrdinalT>
649 if((mem & LOC::X) == LOC::X)
652 if((mem & LOC::DxDt) == LOC::DxDt)
655 if((mem & LOC::F) == LOC::F)
658 if((mem & LOC::Mat) == LOC::Mat)
662template <
typename Traits,
typename LocalOrdinalT>
670 if((mem & LOC::X) == LOC::X)
673 if((mem & LOC::DxDt) == LOC::DxDt)
676 if((mem & LOC::F) == LOC::F)
679 if((mem & LOC::Mat) == LOC::Mat)
683template <
typename Traits,
typename LocalOrdinalT>
690template <
typename Traits,
typename LocalOrdinalT>
694 for(std::size_t i=0;i<exPairs.size();i++)
698template <
typename Traits,
typename LocalOrdinalT>
705template <
typename Traits,
typename LocalOrdinalT>
717template<
typename Traits,
typename LocalOrdinalT>
721 std::size_t blockCnt,
722 std::size_t colBlockCnt)
724 maps_.resize(blockCnt);
744template <
typename Traits,
typename LocalOrdinalT>
751 std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > > vsArray;
753 vsArray.push_back(Thyra::create_VectorSpace(
getColMap(i)));
755 domainSpace_ = Thyra::productVectorSpace<double>(vsArray);
767template <
typename Traits,
typename LocalOrdinalT>
774 std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > > vsArray;
776 vsArray.push_back(Thyra::create_VectorSpace(
getMap(i)));
778 rangeSpace_ = Thyra::productVectorSpace<double>(vsArray);
790template <
typename Traits,
typename LocalOrdinalT>
794 Teuchos::RCP<Thyra::VectorBase<double> > vec =
796 Thyra::assign(vec.ptr(),0.0);
801template <
typename Traits,
typename LocalOrdinalT>
805 Teuchos::RCP<Thyra::VectorBase<double> > vec =
807 Thyra::assign(vec.ptr(),0.0);
812template <
typename Traits,
typename LocalOrdinalT>
822 Teuchos::RCP<Thyra::PhysicallyBlockedLinearOpBase<double> > blockedOp = Thyra::defaultBlockedLinearOp<double>();
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++) {
836 Teuchos::RCP<Thyra::LinearOpBase<double> > block = Thyra::nonconstEpetraLinearOp(
getEpetraMatrix(i,j));
837 blockedOp->setNonconstBlock(i,j,block);
843 blockedOp->endBlockFill();
853template<
typename Traits,
typename LocalOrdinalT>
854Teuchos::RCP<const Thyra::VectorSpaceBase<double>>
860 using Thyra::create_VectorSpace;
861 using Thyra::productVectorSpace;
868 vector<RCP<const VectorSpaceBase<double>>> vsArray;
888template<
typename Traits,
typename LocalOrdinalT>
889Teuchos::RCP<const Thyra::VectorSpaceBase<double>>
895 using Thyra::create_VectorSpace;
896 using Thyra::productVectorSpace;
903 vector<RCP<const VectorSpaceBase<double>>> vsArray;
918template <
typename Traits,
typename LocalOrdinalT>
925 std::vector<Teuchos::RCP<const Thyra::VectorSpaceBase<double> > > vsArray;
927 vsArray.push_back(Thyra::create_VectorSpace(
getGhostedMap(i)));
941template <
typename Traits,
typename LocalOrdinalT>
945 Teuchos::RCP<Thyra::VectorBase<double> > vec =
947 Thyra::assign(vec.ptr(),0.0);
952template <
typename Traits,
typename LocalOrdinalT>
956 Teuchos::RCP<Thyra::VectorBase<double> > vec =
958 Thyra::assign(vec.ptr(),0.0);
963template <
typename Traits,
typename LocalOrdinalT>
973 Teuchos::RCP<Thyra::PhysicallyBlockedLinearOpBase<double> > blockedOp = Thyra::defaultBlockedLinearOp<double>();
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++) {
987 Teuchos::RCP<Thyra::LinearOpBase<double> > block = Thyra::nonconstEpetraLinearOp(
getGhostedEpetraMatrix(i,j));
988 blockedOp->setNonconstBlock(i,j,block);
994 blockedOp->endBlockFill();
999template <
typename Traits,
typename LocalOrdinalT>
1005 using Teuchos::rcp_dynamic_cast;
1007 using Thyra::get_Epetra_Vector;
1012 RCP<const ProductVectorBase<double> > prod_in = Thyra::castOrCreateProductVectorBase(in);
1013 RCP<ProductVectorBase<double> > prod_out = Thyra::castOrCreateNonconstProductVectorBase(out);
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++) {
1020 RCP<const Epetra_Vector> ep_in;
1021 RCP<Epetra_Vector> ep_out;
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));
1036template <
typename Traits,
typename LocalOrdinalT>
1041 using Teuchos::rcp_dynamic_cast;
1042 using Teuchos::dyn_cast;
1044 using Thyra::PhysicallyBlockedLinearOpBase;
1045 using Thyra::get_Epetra_Operator;
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++) {
1064 RCP<const LinearOpBase<double> > th_in = prod_in.getBlock(i,j);
1065 RCP<LinearOpBase<double> > th_out = prod_out.getNonconstBlock(i,j);
1068 TEUCHOS_ASSERT(th_in!=Teuchos::null);
1069 TEUCHOS_ASSERT(th_out!=Teuchos::null);
1072 RCP<const Epetra_CrsMatrix> ep_in = rcp_dynamic_cast<const Epetra_CrsMatrix>(get_Epetra_Operator(*th_in),
true);
1073 RCP<Epetra_CrsMatrix> ep_out = rcp_dynamic_cast<Epetra_CrsMatrix>(get_Epetra_Operator(*th_out),
true);
1082template <
typename Traits,
typename LocalOrdinalT>
1088 using Teuchos::rcp_dynamic_cast;
1090 using Thyra::get_Epetra_Vector;
1095 RCP<const ProductVectorBase<double> > prod_in = Thyra::castOrCreateProductVectorBase(in);
1096 RCP<ProductVectorBase<double> > prod_out = Thyra::castOrCreateNonconstProductVectorBase(out);
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++) {
1103 RCP<const Epetra_Vector> ep_in;
1104 RCP<Epetra_Vector> ep_out;
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));
1123template <
typename Traits,
typename LocalOrdinalT>
1132 int err = out.Export(in,*exporter,Add);
1133 TEUCHOS_ASSERT_EQUALITY(err,0);
1136template <
typename Traits,
typename LocalOrdinalT>
1145 int err = out.Export(in,*exporter,Add);
1146 TEUCHOS_ASSERT_EQUALITY(err,0);
1149template <
typename Traits,
typename LocalOrdinalT>
1158 int err = out.Import(in,*importer,Insert);
1159 TEUCHOS_ASSERT_EQUALITY(err,0);
1163template <
typename Traits,
typename LocalOrdinalT>
1167 if(
maps_[i]==Teuchos::null)
1174template <
typename Traits,
typename LocalOrdinalT>
1192template<
typename Traits,
typename LocalOrdinalT>
1193const Teuchos::RCP<Epetra_Map>
1208template<
typename Traits,
typename LocalOrdinalT>
1209const Teuchos::RCP<Epetra_Map>
1224template<
typename Traits,
typename LocalOrdinalT>
1225const Teuchos::RCP<Epetra_Map>
1242template<
typename Traits,
typename LocalOrdinalT>
1243const Teuchos::RCP<Epetra_Map>
1256template <
typename Traits,
typename LocalOrdinalT>
1260 typedef std::unordered_map<std::pair<int,int>,Teuchos::RCP<Epetra_CrsGraph>,
panzer::pair_hash> GraphMap;
1262 GraphMap::const_iterator itr =
graphs_.find(std::make_pair(i,j));
1263 Teuchos::RCP<Epetra_CrsGraph> graph;
1266 graphs_[std::make_pair(i,j)] = graph;
1269 graph = itr->second;
1271 TEUCHOS_ASSERT(graph!=Teuchos::null);
1275template <
typename Traits,
typename LocalOrdinalT>
1279 typedef std::unordered_map<std::pair<int,int>,Teuchos::RCP<Epetra_CrsGraph>,
panzer::pair_hash> GraphMap;
1281 GraphMap::const_iterator itr =
ghostedGraphs_.find(std::make_pair(i,j));
1282 Teuchos::RCP<Epetra_CrsGraph> ghostedGraph;
1288 ghostedGraph = itr->second;
1290 TEUCHOS_ASSERT(ghostedGraph!=Teuchos::null);
1291 return ghostedGraph;
1299template<
typename Traits,
typename LocalOrdinalT>
1300const Teuchos::RCP<Epetra_Import>
1316template<
typename Traits,
typename LocalOrdinalT>
1317const Teuchos::RCP<Epetra_Import>
1333template<
typename Traits,
typename LocalOrdinalT>
1334const Teuchos::RCP<Epetra_Import>
1353template<
typename Traits,
typename LocalOrdinalT>
1354const Teuchos::RCP<Epetra_Import>
1373template<
typename Traits,
typename LocalOrdinalT>
1374const Teuchos::RCP<Epetra_Export>
1390template<
typename Traits,
typename LocalOrdinalT>
1391const Teuchos::RCP<Epetra_Export>
1407template<
typename Traits,
typename LocalOrdinalT>
1408const Teuchos::RCP<Epetra_Export>
1427template<
typename Traits,
typename LocalOrdinalT>
1428const Teuchos::RCP<Epetra_Export>
1442template <
typename Traits,
typename LocalOrdinalT>
1446 std::vector<int> indices;
1451 return Teuchos::rcp(
new Epetra_Map(-1,indices.size(),&indices[0],0,*
eComm_));
1454template <
typename Traits,
typename LocalOrdinalT>
1461 std::vector<int> indices;
1466 return Teuchos::rcp(
new Epetra_Map(-1,indices.size(),&indices[0],0,*
eComm_));
1474template<
typename Traits,
typename LocalOrdinalT>
1475const Teuchos::RCP<Epetra_Map>
1482 vector<int> indices;
1484 return rcp(
new Epetra_Map(-1, indices.size(), &indices[0], 0, *
eComm_));
1492template<
typename Traits,
typename LocalOrdinalT>
1493const Teuchos::RCP<Epetra_Map>
1500 vector<int> indices;
1502 return rcp(
new Epetra_Map(-1, indices.size(), &indices[0], 0, *
eComm_));
1510template<
typename Traits,
typename LocalOrdinalT>
1511const Teuchos::RCP<Epetra_Map>
1520 vector<int> indices;
1522 return rcp(
new Epetra_Map(-1, indices.size(), &indices[0], 0, *
eComm_));
1530template<
typename Traits,
typename LocalOrdinalT>
1531const Teuchos::RCP<Epetra_Map>
1540 vector<int> indices;
1542 return rcp(
new Epetra_Map(-1, indices.size(), &indices[0], 0, *
eComm_));
1546template <
typename Traits,
typename LocalOrdinalT>
1555 RCP<Epetra_Map> map_i =
getMap(i);
1558 TEUCHOS_ASSERT(map_i!=Teuchos::null);
1559 TEUCHOS_ASSERT(map_j!=Teuchos::null);
1561 RCP<Epetra_CrsGraph> graph = rcp(
new Epetra_CrsGraph(
Copy,*map_i,0));
1568 int err = graph->Export( *oGraph, *exporter, Insert );
1569 TEUCHOS_ASSERT_EQUALITY(err,0);
1570 graph->FillComplete(*map_j,*map_i);
1571 graph->OptimizeStorage();
1576template <
typename Traits,
typename LocalOrdinalT>
1583 Teuchos::RCP<Epetra_CrsGraph> graph = Teuchos::rcp(
new Epetra_CrsGraph(
Copy,*rowMap,*colMap,0));
1585 std::vector<std::string> elementBlockIds;
1587 Teuchos::RCP<const GlobalIndexer> rowProvider, colProvider;
1592 rowProvider->getElementBlockIds(elementBlockIds);
1595 const Teuchos::RCP<const ConnManager> conn_mgr = colProvider->getConnManager();
1596 const bool han = conn_mgr.is_null() ? false : conn_mgr->hasAssociatedNeighbors();
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++) {
1613 rowProvider->getElementGIDsAsInt(elements[elmt],row_gids);
1614 colProvider->getElementGIDsAsInt(elements[elmt],col_gids);
1617 const std::vector<LocalOrdinalT>& aes = conn_mgr->getAssociatedNeighbors(elements[elmt]);
1618 for (
typename std::vector<LocalOrdinalT>::const_iterator eit = aes.begin();
1619 eit != aes.end(); ++eit) {
1620 std::vector<int> other_col_gids;
1621 colProvider->getElementGIDsAsInt(*eit, 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++)
1627 graph->InsertGlobalIndices(row_gids[row],col_gids.size(),&col_gids[0]);
1633 graph->FillComplete(*colMap,*rowMap);
1635 graph->OptimizeStorage();
1640template <
typename Traits,
typename LocalOrdinalT>
1646 using Teuchos::rcp_dynamic_cast;
1649 RCP<const Filtered_GlobalIndexer> filtered_ugi
1653 if(filtered_ugi==Teuchos::null)
1657 std::vector<int> ghostedActive;
1658 filtered_ugi->getOwnedAndGhostedNotFilteredIndicator(ghostedActive);
1665 for(
int k=0;k<filteredGraph->NumMyRows();++k) {
1666 std::vector<int> removedIndices;
1669 TEUCHOS_ASSERT(filteredGraph->ExtractMyRowView(k,numIndices,indices)==0);
1671 for(
int m=0;m<numIndices;++m) {
1672 if(ghostedActive[indices[m]]==0)
1673 removedIndices.push_back(indices[m]);
1676 TEUCHOS_ASSERT(filteredGraph->RemoveMyIndices(k,Teuchos::as<int>(removedIndices.size()),&removedIndices[0])==0);
1683 TEUCHOS_ASSERT(filteredGraph->FillComplete(*colMap,*rowMap)==0);
1684 TEUCHOS_ASSERT(filteredGraph->OptimizeStorage()==0);
1686 return filteredGraph;
1689template <
typename Traits,
typename LocalOrdinalT>
1693 Teuchos::RCP<Epetra_CrsGraph> eGraph =
getGraph(i,j);
1694 Teuchos::RCP<Epetra_CrsMatrix> mat = Teuchos::rcp(
new Epetra_CrsMatrix(
Copy, *eGraph));
1695 TEUCHOS_ASSERT(mat->Filled());
1699template <
typename Traits,
typename LocalOrdinalT>
1704 Teuchos::RCP<Epetra_CrsMatrix> mat = Teuchos::rcp(
new Epetra_CrsMatrix(
Copy, *eGraph));
1705 TEUCHOS_ASSERT(mat->Filled());
1709template <
typename Traits,
typename LocalOrdinalT>
1716template <
typename Traits,
typename LocalOrdinalT>
1723template <
typename Traits,
typename LocalOrdinalT>
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)
Abstract, linear-algebra-library-agnostic container for the vectors and matrix used in a nonlinear/tr...
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
A hash functor for std::pair, combining the hashes of both elements via hash_combine()....