Panzer  Version of the Day
Panzer_LinearObjFactory_Utilities.cpp
Go to the documentation of this file.
2 
3 #include "Teuchos_RCP.hpp"
4 
6 
7 #include "Panzer_EpetraLinearObjFactory.hpp"
8 #include "Panzer_TpetraLinearObjFactory.hpp"
11 
12 namespace panzer {
13 
14 Teuchos::RCP<const LinearObjFactory<panzer::Traits> > cloneWithNewDomain(const LinearObjFactory<panzer::Traits> & lof,
15  const Teuchos::RCP<const UniqueGlobalIndexerBase> & dUgi)
16 {
17  // This just forwards on to the general case. That makes things much easier
18  return cloneWithNewRangeAndDomain(lof,Teuchos::null,dUgi);
19 }
20 
21 Teuchos::RCP<const LinearObjFactory<panzer::Traits> > cloneWithNewRange(const LinearObjFactory<panzer::Traits> & lof,
22  const Teuchos::RCP<const UniqueGlobalIndexerBase> & rUgi)
23 {
24  // This just forwards on to the general case. That makes things much easier
25  return cloneWithNewRangeAndDomain(lof,rUgi,Teuchos::null);
26 }
27 
28 Teuchos::RCP<const LinearObjFactory<panzer::Traits> > cloneWithNewRangeAndDomain(
30  const Teuchos::RCP<const UniqueGlobalIndexerBase> & rUgi,
31  const Teuchos::RCP<const UniqueGlobalIndexerBase> & dUgi)
32 {
33  using Teuchos::null;
34  using Teuchos::RCP;
35  using Teuchos::rcp;
36  using Teuchos::rcp_dynamic_cast;
37  using Teuchos::Ptr;
38  using Teuchos::ptr_dynamic_cast;
39  using Teuchos::ptrFromRef;
40 
41 /*
42  typedef UniqueGlobalIndexer<int,int> EpetraUGI;
43  typedef UniqueGlobalIndexer<int,Ordinal64> TpetraUGI;
44  typedef BlockedDOFManager<int,int> BlockedEpetraUGI;
45  typedef BlockedDOFManager<int,Ordinal64> BlockedTpetraUGI;
46 
47  typedef EpetraLinearObjFactory<panzer::Traits,int> EpetraLOF;
48 */
52 
53  // This proceeds by casting to a number of known LOF types (all explicitly instantiated)
54  // then trying to build a new one. Of course for many of these under implemented operation
55  // this fails and an error is thrown.
56 
57 /*
58  Ptr<const EpetraLOF> epetra_lof = ptr_dynamic_cast<const EpetraLOF>(ptrFromRef(lof));
59  if(epetra_lof!=null) {
60  RCP<const EpetraUGI> rangeUGI = rcp_dynamic_cast<const EpetraUGI>(rUgi==null ? epetra_lof->getRangeGlobalIndexer() : rUgi,true);
61  RCP<const EpetraUGI> domainUGI = rcp_dynamic_cast<const EpetraUGI>(dUgi==null ? epetra_lof->getDomainGlobalIndexer() : dUgi,true);
62  RCP<Teuchos::MpiComm<int> > mpiComm = rcp(new Teuchos::MpiComm<int>(epetra_lof->getComm()));
63  return rcp(new EpetraLOF(mpiComm,rangeUGI,domainUGI));
64  }
65 */
66 
67  Ptr<const TpetraLOF> tpetra_lof = ptr_dynamic_cast<const TpetraLOF>(ptrFromRef(lof));
68  if(tpetra_lof!=null) {
69  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
70  "panzer::cloneWithNewRangeAndDomain: Tpetra LOF does not yet support "
71  "different range and domain indexers!");
72  }
73 
74  Ptr<const BlockedEpetraLOF> blk_epetra_lof = ptr_dynamic_cast<const BlockedEpetraLOF>(ptrFromRef(lof));
75  if(blk_epetra_lof!=null) {
76  auto rangeUGI = (rUgi==null ? blk_epetra_lof->getRangeGlobalIndexer() : rUgi);
77  auto domainUGI = (dUgi==null ? blk_epetra_lof->getDomainGlobalIndexer() : dUgi);
78  RCP<Teuchos::MpiComm<int> > mpiComm = rcp(new Teuchos::MpiComm<int>(blk_epetra_lof->getComm()));
79  return rcp(new BlockedEpetraLOF(mpiComm,rangeUGI,domainUGI));
80  }
81 
82  Ptr<const BlockedTpetraLOF> blk_tpetra_lof = ptr_dynamic_cast<const BlockedTpetraLOF>(ptrFromRef(lof));
83  if(blk_tpetra_lof!=null) {
84  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
85  "panzer::cloneWithNewRangeAndDomain: Blocked Tpetra LOF does not yet support "
86  "different range and domain indexers!");
87  }
88 
89  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
90  "panzer::cloneWithNewRangeAndDomain: Could not determine the type of LOF, clone not support!");
91 
92  return Teuchos::null;
93 }
94 
95 }
Teuchos::RCP< const LinearObjFactory< panzer::Traits > > cloneWithNewRangeAndDomain(const LinearObjFactory< panzer::Traits > &lof, const Teuchos::RCP< const UniqueGlobalIndexerBase > &rUgi, const Teuchos::RCP< const UniqueGlobalIndexerBase > &dUgi)
Clone a linear object factory, but using a different range and domain.
Teuchos::RCP< const LinearObjFactory< panzer::Traits > > cloneWithNewDomain(const LinearObjFactory< panzer::Traits > &lof, const Teuchos::RCP< const UniqueGlobalIndexerBase > &dUgi)
Clone a linear object factory, but using a different domain.
Teuchos::RCP< const LinearObjFactory< panzer::Traits > > cloneWithNewRange(const LinearObjFactory< panzer::Traits > &lof, const Teuchos::RCP< const UniqueGlobalIndexerBase > &rUgi)
Clone a linear object factory, but using a different range.