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

LaplaceResid_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 "Teuchos_TestForException.hpp"
00008 #include "Phalanx_DataLayout.hpp"
00009 
00010 namespace PHAL {
00011 
00012 //**********************************************************************
00013 template<typename EvalT, typename Traits>
00014 LaplaceResid<EvalT, Traits>::
00015 LaplaceResid(const Teuchos::ParameterList& p, const Teuchos::RCP<Albany::Layouts>& dl) :
00016   coordVec(p.get<std::string> ("Coordinate Vector Name"), dl->vertices_vector),
00017   solnVec(p.get<std::string> ("Solution Vector Name"), dl->node_vector),
00018   cubature(p.get<Teuchos::RCP <Intrepid::Cubature<RealType> > >("Cubature")),
00019   cellType(p.get<Teuchos::RCP <shards::CellTopology> > ("Cell Type")),
00020   intrepidBasis(p.get<Teuchos::RCP<Intrepid::Basis<RealType, Intrepid::FieldContainer<RealType> > > > ("Intrepid Basis")),
00021   solnResidual(p.get<std::string> ("Residual Name"), dl->node_vector) {
00022 
00023 
00024   this->addDependentField(coordVec);
00025   this->addDependentField(solnVec);
00026   this->addEvaluatedField(solnResidual);
00027 
00028   std::vector<PHX::DataLayout::size_type> dims;
00029   dl->node_qp_vector->dimensions(dims);
00030   worksetSize = dims[0];
00031   numNodes = dims[1];
00032   numQPs  = dims[2];
00033   numDims = dims[3];
00034 
00035   // Allocate Temporary FieldContainers
00036   grad_at_cub_points.resize(numNodes, numQPs, numDims);
00037   refPoints.resize(numQPs, numDims);
00038   refWeights.resize(numQPs);
00039   jacobian.resize(worksetSize, numQPs, numDims, numDims);
00040   jacobian_det.resize(worksetSize, numQPs);
00041 
00042   // Pre-Calculate reference element quantitites
00043   cubature->getCubature(refPoints, refWeights);
00044   intrepidBasis->getValues(grad_at_cub_points, refPoints, Intrepid::OPERATOR_GRAD);
00045 
00046   this->setName("LaplaceResid" + PHX::TypeString<EvalT>::value);
00047 
00048 }
00049 
00050 //**********************************************************************
00051 template<typename EvalT, typename Traits>
00052 void LaplaceResid<EvalT, Traits>::
00053 postRegistrationSetup(typename Traits::SetupData d,
00054                       PHX::FieldManager<Traits>& fm) {
00055   this->utils.setFieldData(coordVec, fm);
00056   this->utils.setFieldData(solnVec, fm);
00057   this->utils.setFieldData(solnResidual, fm);
00058 }
00059 
00060 //**********************************************************************
00061 template<typename EvalT, typename Traits>
00062 void LaplaceResid<EvalT, Traits>::
00063 evaluateFields(typename Traits::EvalData workset) {
00064 
00065   // setJacobian only needs to be RealType since the data type is only
00066   //  used internally for Basis Fns on reference elements, which are
00067   //  not functions of coordinates. This save 18min of compile time!!!
00068 
00069   Intrepid::CellTools<RealType>::setJacobian(jacobian, refPoints, coordVec, *cellType);
00070   Intrepid::CellTools<MeshScalarT>::setJacobianDet(jacobian_det, jacobian);
00071 
00072    // Straight Laplace's equation evaluation for the nodal coord solution
00073 
00074     for(std::size_t cell = 0; cell < workset.numCells; ++cell) {
00075       for(std::size_t node_a = 0; node_a < numNodes; ++node_a) {
00076 
00077         for(std::size_t eq = 0; eq < numDims; eq++)  {
00078           solnResidual(cell, node_a, eq) = 0.0;
00079         }
00080 
00081         for(std::size_t qp = 0; qp < numQPs; ++qp) {
00082           for(std::size_t node_b = 0; node_b < numNodes; ++node_b) {
00083 
00084             ScalarT kk = 0.0;
00085 
00086             for(std::size_t i = 0; i < numDims; i++) {
00087 
00088               kk += grad_at_cub_points(node_a, qp, i) * grad_at_cub_points(node_b, qp, i);
00089 
00090             }
00091 
00092             for(std::size_t eq = 0; eq < numDims; eq++) {
00093 
00094               solnResidual(cell, node_a, eq) +=
00095                 kk * solnVec(cell, node_b, eq) * jacobian_det(cell, qp) * refWeights(qp);
00096 
00097             }
00098           }
00099         }
00100       }
00101     }
00102 }
00103 
00104 //**********************************************************************
00105 }
00106 

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