• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Aeras_GatherCoordinateVector_Def.hpp

Go to the documentation of this file.
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 <vector>
00008 #include <string>
00009 
00010 #include "Teuchos_TestForException.hpp"
00011 #include "Phalanx_DataLayout.hpp"
00012 
00013 namespace Aeras {
00014 
00015 template<typename EvalT, typename Traits>
00016 GatherCoordinateVector<EvalT, Traits>::
00017 GatherCoordinateVector(const Teuchos::ParameterList& p,
00018                               const Teuchos::RCP<Albany::Layouts>& dl) :
00019   coordVec  (p.get<std::string> ("Coordinate Vector Name"), dl->node_3vector ),
00020   numNodes(0), numCoords(0), worksetSize(0)
00021 {  
00022   this->addEvaluatedField(coordVec);
00023   this->setName("Aeras::GatherCoordinateVector"+PHX::TypeString<EvalT>::value);
00024 }
00025 
00026 // **********************************************************************
00027 template<typename EvalT, typename Traits> 
00028 void GatherCoordinateVector<EvalT, Traits>::postRegistrationSetup(typename Traits::SetupData d,
00029                       PHX::FieldManager<Traits>& fm)
00030 {
00031   this->utils.setFieldData(coordVec,fm);
00032 
00033   typename std::vector< typename PHX::template MDField<MeshScalarT,Cell,Vertex,Dim>::size_type > dims;
00034   coordVec.dimensions(dims); //get dimensions
00035 
00036   worksetSize = dims[0];
00037   numNodes = dims[1];
00038   numCoords = dims[2];
00039 
00040 }
00041 
00042 // **********************************************************************
00043 template<typename EvalT, typename Traits>
00044 void GatherCoordinateVector<EvalT, Traits>::evaluateFields(typename Traits::EvalData workset)
00045 { 
00046   unsigned int numCells = workset.numCells;
00047   Teuchos::ArrayRCP<Teuchos::ArrayRCP<double*> > wsCoords = workset.wsCoords;
00048 
00049   for (std::size_t cell=0; cell < numCells; ++cell) {
00050     for (std::size_t node = 0; node < numNodes; ++node) {
00051       for (std::size_t i=0; i < numCoords; ++i) { 
00052         coordVec(cell,node,i) = wsCoords[cell][node][i]; 
00053       }
00054     }
00055   }
00056 
00057   // Since Intrepid will later perform calculations on the entire workset size
00058   // and not just the used portion, we must fill the excess with reasonable 
00059   // values. Leaving this out leads to calculations on singular elements.
00060   for (std::size_t cell=numCells; cell < worksetSize; ++cell) {
00061     for (std::size_t node = 0; node < numNodes; ++node) {
00062       for (std::size_t i=0; i < numCoords; ++i) { 
00063         coordVec(cell,node,i) = coordVec(0,node,i); 
00064       }
00065     }
00066   }
00067 }
00068 
00069 }

Generated on Wed Mar 26 2014 18:36:35 for Albany: a Trilinos-based PDE code by  doxygen 1.7.1