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

PHAL_GatherSHeight_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 PHAL {
00014 
00015 template<typename EvalT, typename Traits>
00016 GatherSHeight<EvalT, Traits>::
00017 GatherSHeight(const Teuchos::ParameterList& p,
00018                               const Teuchos::RCP<Albany::Layouts>& dl) :
00019   sHeight  (p.get<std::string> ("Surface Height Name"), dl->node_scalar ),
00020   numVertices(0), worksetSize(0)
00021 {  
00022   this->addEvaluatedField(sHeight);
00023   this->setName("Gather Surface Height"+PHX::TypeString<EvalT>::value);
00024 }
00025 
00026 template<typename EvalT, typename Traits>
00027 GatherSHeight<EvalT, Traits>::
00028 GatherSHeight(const Teuchos::ParameterList& p) :
00029   sHeight  (p.get<std::string> ("Surface Height Name"),p.get<Teuchos::RCP<PHX::DataLayout> >("Data Layout") ),
00030   numVertices(0), worksetSize(0)
00031 {
00032   this->addEvaluatedField(sHeight);
00033   this->setName("Gather Surface Height"+PHX::TypeString<EvalT>::value);
00034 }
00035 
00036 // **********************************************************************
00037 template<typename EvalT, typename Traits> 
00038 void GatherSHeight<EvalT, Traits>::postRegistrationSetup(typename Traits::SetupData d,
00039                       PHX::FieldManager<Traits>& fm)
00040 {
00041   this->utils.setFieldData(sHeight,fm);
00042 
00043   typename std::vector< typename PHX::template MDField<ScalarT,Cell,Vertex>::size_type > dims;
00044   sHeight.dimensions(dims); //get dimensions
00045 
00046   worksetSize = dims[0];
00047   numVertices = dims[1];
00048 }
00049 
00050 // **********************************************************************
00051 template<typename EvalT, typename Traits>
00052 void GatherSHeight<EvalT, Traits>::evaluateFields(typename Traits::EvalData workset)
00053 { 
00054   unsigned int numCells = workset.numCells;
00055   Teuchos::ArrayRCP<Teuchos::ArrayRCP<double> > wsSHeight = workset.wsSHeight;
00056 
00057   for (std::size_t cell=0; cell < numCells; ++cell) {
00058     for (std::size_t node = 0; node < numVertices; ++node) {
00059         sHeight(cell,node) = wsSHeight[cell][node];
00060       }
00061     }
00062 
00063 
00064   // Since Intrepid will later perform calculations on the entire workset size
00065   // and not just the used portion, we must fill the excess with reasonable 
00066   // values. Leaving this out leads to calculations on singular elements.
00067   for (std::size_t cell=numCells; cell < worksetSize; ++cell) {
00068     for (std::size_t node = 0; node < numVertices; ++node) {
00069         sHeight(cell,node) = sHeight(0,node);
00070     }
00071   }
00072 }
00073 }

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