Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "TSFEpetraGhostImporter.hpp"
00028 #include "TSFEpetraGhostView.hpp"
00029 #include "TSFEpetraVector.hpp"
00030
00031
00032 #ifndef HAVE_TEUCHOS_EXPLICIT_INSTANTIATION
00033 #include "TSFVectorImpl.hpp"
00034 #endif
00035
00036 using namespace Teuchos;
00037 using namespace TSFExtended;
00038
00039 EpetraGhostImporter
00040 ::EpetraGhostImporter(const RCP<const Epetra_Map>& localMap,
00041 int nGhost,
00042 const int* ghostElements)
00043 : localMap_(localMap),
00044 ghostMap_(),
00045 importer_()
00046 {
00047 if (false && nGhost==0)
00048 {
00049 ghostMap_ = localMap_;
00050
00051 importer_ = rcp(new Epetra_Import(*ghostMap_, *localMap_));
00052 }
00053 else
00054 {
00055
00056 int nLocal = localMap_->NumMyElements();
00057 int nGhostView = nLocal+nGhost;
00058 std::vector<int> globalIndices(nGhostView);
00059 for (int i=0; i<nLocal; i++) globalIndices[i] = localMap_->GID(i);
00060 for (int i=0; i<nGhost; i++) globalIndices[i+nLocal] = ghostElements[i];
00061
00062 const Epetra_Comm& comm = localMap_->Comm();
00063
00064 ghostMap_ = rcp(new Epetra_Map(-1, nGhostView,
00065 &(globalIndices[0]), 0, comm));
00066
00067 importer_ = rcp(new Epetra_Import(*ghostMap_, *localMap_));
00068 }
00069 }
00070
00071 void EpetraGhostImporter
00072 ::importView(const Vector<double>& x,
00073 RCP<GhostView<double> >& ghostView) const
00074 {
00075
00076 if (ghostView.get()==0)
00077 {
00078 ghostView = rcp(new EpetraGhostView());
00079 }
00080
00081
00082 EpetraGhostView* epgv
00083 = dynamic_cast<EpetraGhostView*>(ghostView.get());
00084
00085 TEST_FOR_EXCEPTION(epgv==0, std::runtime_error,
00086 "argument ghostView to EpetraGhostImporter::importView() "
00087 "could not be cast to a EpetraGhostView pointer");
00088
00089 const Epetra_Vector& xVec = EpetraVector::getConcrete(x);
00090
00091
00092 epgv->import(*importer_, xVec);
00093 }
00094