00001 //*****************************************************************// 00002 // Albany 2.0: Copyright 2012 Sandia Corporation // 00003 // This Software is released under the BSD license detailed // 00004 // in the file "license.txt" in the top-level Albany directory // 00005 //*****************************************************************// 00006 00007 #include "Albany_StkNodalBasisSource.hpp" 00008 00009 #include "Albany_AbstractMeshStruct.hpp" 00010 00011 #include "Teuchos_Assert.hpp" 00012 00013 namespace Albany { 00014 00015 StkNodalBasisSource::StkNodalBasisSource(const Teuchos::RCP<STKDiscretization> &disc) : 00016 disc_(disc), 00017 currentVectorRank_(-1), 00018 currentVector_(new Epetra_Vector(*disc->getMap(), /*zeroOut =*/ false)) 00019 { 00020 // Nothing to do 00021 } 00022 00023 Epetra_Map 00024 StkNodalBasisSource::atomMap() const 00025 { 00026 return Epetra_Map(*disc_->getNodeMap()); 00027 } 00028 00029 int 00030 StkNodalBasisSource::entryCount(int /*localAtomRank*/) const 00031 { 00032 return disc_->getNumEq(); 00033 } 00034 00035 int 00036 StkNodalBasisSource::entryCountMax() const 00037 { 00038 return disc_->getNumEq(); 00039 } 00040 00041 int 00042 StkNodalBasisSource::vectorCount() const 00043 { 00044 return disc_->getSTKMeshStruct()->getSolutionFieldHistoryDepth(); 00045 } 00046 00047 int 00048 StkNodalBasisSource::currentVectorRank() const 00049 { 00050 return currentVectorRank_; 00051 } 00052 00053 void 00054 StkNodalBasisSource::currentVectorRankIs(int vr) 00055 { 00056 if (vr != currentVectorRank_) { 00057 disc_->getSTKMeshStruct()->loadSolutionFieldHistory(vr); 00058 currentVector_ = disc_->getSolutionField(); 00059 currentVectorRank_ = vr; 00060 } 00061 } 00062 00063 Teuchos::ArrayView<const double> 00064 StkNodalBasisSource::atomData(int localAtomRank, const Teuchos::ArrayView<double> &result) const 00065 { 00066 TEUCHOS_ASSERT(result.size() <= this->entryCount(localAtomRank)); 00067 const int dofCount = this->entryCount(localAtomRank); 00068 for (int dofRank = 0; dofRank < dofCount; ++dofRank) { 00069 const int localEntryIndex = disc_->getOwnedDOF(localAtomRank, dofRank); 00070 result[dofRank] = (*currentVector_)[localEntryIndex]; 00071 } 00072 return result; 00073 } 00074 00075 } // end namespace Albany