Panzer  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Panzer_LinearObjFactory_Utilities.cpp
Go to the documentation of this file.
2 
3 #include "Teuchos_RCP.hpp"
4 
6 
7 #include "Panzer_TpetraLinearObjFactory.hpp"
10 
11 namespace panzer {
12 
15 {
16  // This just forwards on to the general case. That makes things much easier
17  return cloneWithNewRangeAndDomain(lof,Teuchos::null,dUgi);
18 }
19 
22 {
23  // This just forwards on to the general case. That makes things much easier
24  return cloneWithNewRangeAndDomain(lof,rUgi,Teuchos::null);
25 }
26 
31 {
32  using Teuchos::null;
33  using Teuchos::RCP;
34  using Teuchos::rcp;
35  using Teuchos::rcp_dynamic_cast;
36  using Teuchos::Ptr;
37  using Teuchos::ptr_dynamic_cast;
38  using Teuchos::ptrFromRef;
39 
40  using TpetraUGI = UniqueGlobalIndexer<int, Ordinal64>;
41 /*
42  typedef UniqueGlobalIndexer<int,int> EpetraUGI;
43  typedef BlockedDOFManager<int,int> BlockedEpetraUGI;
44  typedef BlockedDOFManager<int,Ordinal64> BlockedTpetraUGI;
45 */
49 
50  // This proceeds by casting to a number of known LOF types (all explicitly instantiated)
51  // then trying to build a new one. Of course for many of these under implemented operation
52  // this fails and an error is thrown.
53 
54 /*
55  Ptr<const EpetraLOF> epetra_lof = ptr_dynamic_cast<const EpetraLOF>(ptrFromRef(lof));
56  if(epetra_lof!=null) {
57  RCP<const EpetraUGI> rangeUGI = rcp_dynamic_cast<const EpetraUGI>(rUgi==null ? epetra_lof->getRangeGlobalIndexer() : rUgi,true);
58  RCP<const EpetraUGI> domainUGI = rcp_dynamic_cast<const EpetraUGI>(dUgi==null ? epetra_lof->getDomainGlobalIndexer() : dUgi,true);
59  RCP<Teuchos::MpiComm<int> > mpiComm = rcp(new Teuchos::MpiComm<int>(epetra_lof->getComm()));
60  return rcp(new EpetraLOF(mpiComm,rangeUGI,domainUGI));
61  }
62 */
63 
64  Ptr<const TpetraLOF> tpetra_lof = ptr_dynamic_cast<const TpetraLOF>(ptrFromRef(lof));
65  if(tpetra_lof!=null) {
66  auto rangeUGI = rcp_dynamic_cast<const TpetraUGI>(rUgi==null ? tpetra_lof->getRangeGlobalIndexer() : rUgi,true);
67  auto domainUGI = rcp_dynamic_cast<const TpetraUGI>(dUgi==null ? tpetra_lof->getDomainGlobalIndexer() : dUgi,true);
68  auto mpiComm = rcp(new Teuchos::MpiComm<int>(tpetra_lof->getComm()));
69 
70  return rcp(new TpetraLOF(mpiComm,rangeUGI,domainUGI));
71  }
72 
73  Ptr<const BlockedEpetraLOF> blk_epetra_lof = ptr_dynamic_cast<const BlockedEpetraLOF>(ptrFromRef(lof));
74  if(blk_epetra_lof!=null) {
75  auto rangeUGI = (rUgi==null ? blk_epetra_lof->getRangeGlobalIndexer() : rUgi);
76  auto domainUGI = (dUgi==null ? blk_epetra_lof->getDomainGlobalIndexer() : dUgi);
77  RCP<Teuchos::MpiComm<int> > mpiComm = rcp(new Teuchos::MpiComm<int>(blk_epetra_lof->getComm()));
78  return rcp(new BlockedEpetraLOF(mpiComm,rangeUGI,domainUGI));
79  }
80 
81  Ptr<const BlockedTpetraLOF> blk_tpetra_lof = ptr_dynamic_cast<const BlockedTpetraLOF>(ptrFromRef(lof));
82  if(blk_tpetra_lof!=null) {
83  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
84  "panzer::cloneWithNewRangeAndDomain: Blocked Tpetra LOF does not yet support "
85  "different range and domain indexers!");
86  }
87 
88  TEUCHOS_TEST_FOR_EXCEPTION(true,std::logic_error,
89  "panzer::cloneWithNewRangeAndDomain: Could not determine the type of LOF, clone not support!");
90 
91  return Teuchos::null;
92 }
93 
94 }
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.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
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_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
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.