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

PHAL_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 PHAL {
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->vertices_vector ),
00020   numVertices(0), numDim(0), worksetSize(0)
00021 {  
00022   if (p.isType<bool>("Periodic BC")) periodic = p.get<bool>("Periodic BC");
00023   else periodic = false;
00024 
00025   this->addEvaluatedField(coordVec);
00026   this->setName("Gather Coordinate Vector"+PHX::TypeString<EvalT>::value);
00027 }
00028 
00029 template<typename EvalT, typename Traits>
00030 GatherCoordinateVector<EvalT, Traits>::
00031 GatherCoordinateVector(const Teuchos::ParameterList& p) :
00032   coordVec         (p.get<std::string>                   ("Coordinate Vector Name"),
00033                     p.get<Teuchos::RCP<PHX::DataLayout> >("Coordinate Data Layout") ),
00034   numVertices(0), numDim(0), worksetSize(0)
00035 {  
00036   if (p.isType<bool>("Periodic BC")) periodic = p.get<bool>("Periodic BC");
00037   else periodic = false;
00038 
00039   this->addEvaluatedField(coordVec);
00040   this->setName("Gather Coordinate Vector"+PHX::TypeString<EvalT>::value);
00041 }
00042 
00043 // **********************************************************************
00044 template<typename EvalT, typename Traits> 
00045 void GatherCoordinateVector<EvalT, Traits>::postRegistrationSetup(typename Traits::SetupData d,
00046                       PHX::FieldManager<Traits>& fm)
00047 {
00048   this->utils.setFieldData(coordVec,fm);
00049 
00050   typename std::vector< typename PHX::template MDField<MeshScalarT,Cell,Vertex,Dim>::size_type > dims;
00051   coordVec.dimensions(dims); //get dimensions
00052 
00053   worksetSize = dims[0];
00054   numVertices = dims[1];
00055   numDim = dims[2];
00056 }
00057 
00058 // **********************************************************************
00059 template<typename EvalT, typename Traits>
00060 void GatherCoordinateVector<EvalT, Traits>::evaluateFields(typename Traits::EvalData workset)
00061 { 
00062   unsigned int numCells = workset.numCells;
00063   Teuchos::ArrayRCP<Teuchos::ArrayRCP<double*> > wsCoords = workset.wsCoords;
00064 
00065   for (std::size_t cell=0; cell < numCells; ++cell) {
00066     for (std::size_t node = 0; node < numVertices; ++node) {
00067       for (std::size_t eq=0; eq < numDim; ++eq) { 
00068         coordVec(cell,node,eq) = wsCoords[cell][node][eq]; 
00069       }
00070     }
00071   }
00072 
00073   // Since Intrepid will later perform calculations on the entire workset size
00074   // and not just the used portion, we must fill the excess with reasonable 
00075   // values. Leaving this out leads to calculations on singular elements.
00076   for (std::size_t cell=numCells; cell < worksetSize; ++cell) {
00077     for (std::size_t node = 0; node < numVertices; ++node) {
00078       for (std::size_t eq=0; eq < numDim; ++eq) { 
00079         coordVec(cell,node,eq) = coordVec(0,node,eq); 
00080       }
00081     }
00082   }
00083 }
00084 // **********************************************************************
00085 template<typename Traits>
00086 GatherCoordinateVector<PHAL::AlbanyTraits::Tangent, Traits>::
00087 GatherCoordinateVector(const Teuchos::ParameterList& p,
00088                               const Teuchos::RCP<Albany::Layouts>& dl) :
00089   coordVec         (p.get<std::string> ("Coordinate Vector Name"), dl->vertices_vector ),
00090   numVertices(0), numDim(0), worksetSize(0)
00091 {  
00092   if (p.isType<bool>("Periodic BC")) periodic = p.get<bool>("Periodic BC");
00093   else periodic = false;
00094 
00095   this->addEvaluatedField(coordVec);
00096   this->setName("Gather Coordinate Vector"
00097                 +PHX::TypeString<PHAL::AlbanyTraits::Tangent>::value);
00098 }
00099 
00100 template<typename Traits>
00101 GatherCoordinateVector<PHAL::AlbanyTraits::Tangent, Traits>::
00102 GatherCoordinateVector(const Teuchos::ParameterList& p) :
00103   coordVec         (p.get<std::string>                   ("Coordinate Vector Name"),
00104                     p.get<Teuchos::RCP<PHX::DataLayout> >("Coordinate Data Layout") ),
00105   numVertices(0), numDim(0), worksetSize(0)
00106 {  
00107   if (p.isType<bool>("Periodic BC")) periodic = p.get<bool>("Periodic BC");
00108   else periodic = false;
00109 
00110   this->addEvaluatedField(coordVec);
00111   this->setName("Gather Coordinate Vector"
00112                 +PHX::TypeString<PHAL::AlbanyTraits::Tangent>::value);
00113 }
00114 
00115 // **********************************************************************
00116 template<typename Traits> 
00117 void GatherCoordinateVector<PHAL::AlbanyTraits::Tangent, Traits>::
00118 postRegistrationSetup(typename Traits::SetupData d,
00119                       PHX::FieldManager<Traits>& fm)
00120 {
00121   this->utils.setFieldData(coordVec,fm);
00122 
00123   typename std::vector< typename PHX::template MDField<MeshScalarT,Cell,Vertex,Dim>::size_type > dims;
00124   coordVec.dimensions(dims); //get dimensions
00125 
00126   worksetSize = dims[0];
00127   numVertices = dims[1];
00128   numDim = dims[2];
00129 }
00130 // **********************************************************************
00131 template<typename Traits>
00132 void GatherCoordinateVector<PHAL::AlbanyTraits::Tangent, Traits>::
00133 evaluateFields(typename Traits::EvalData workset)
00134 { 
00135   unsigned int numCells = workset.numCells;
00136 
00137   Teuchos::ArrayRCP<Teuchos::ArrayRCP<double*> > wsCoords = workset.wsCoords;
00138   const Teuchos::ArrayRCP<Teuchos::ArrayRCP<Teuchos::ArrayRCP<Teuchos::ArrayRCP<double> > > > & ws_coord_derivs = workset.ws_coord_derivs;
00139   std::vector<int> *coord_deriv_indices = workset.coord_deriv_indices;
00140   int numShapeDerivs = ws_coord_derivs.size();
00141   int numParams = workset.num_cols_p;
00142 
00143   for (std::size_t cell=0; cell < numCells; ++cell) {
00144     for (std::size_t node = 0; node < numVertices; ++node) {
00145       for (std::size_t eq=0; eq < numDim; ++eq) { 
00146         coordVec(cell,node,eq) = TanFadType(numParams, wsCoords[cell][node][eq]); 
00147         for (int j=0; j < numShapeDerivs; ++j) { 
00148           coordVec(cell,node,eq).fastAccessDx((*coord_deriv_indices)[j]) 
00149                =  ws_coord_derivs[j][cell][node][eq];
00150         }
00151       }
00152     }
00153   }
00154 
00155   // Since Intrepid will later perform calculations on the entire workset size
00156   // and not just the used portion, we must fill the excess with reasonable 
00157   // values. Leaving this out leads to calculations on singular elements.
00158   //
00159   for (std::size_t cell=numCells; cell < worksetSize; ++cell) {
00160     for (std::size_t node = 0; node < numVertices; ++node) {
00161       for (std::size_t eq=0; eq < numDim; ++eq) { 
00162         coordVec(cell,node,eq) = coordVec(0,node,eq); 
00163       }
00164     }
00165   }
00166 }
00167 }

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