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

PHAL_HelmholtzResid_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 #include "Intrepid_FunctionSpaceTools.hpp"
00011 
00012 namespace PHAL {
00013 
00014 //**********************************************************************
00015 template<typename EvalT, typename Traits>
00016 HelmholtzResid<EvalT, Traits>::
00017 HelmholtzResid(const Teuchos::ParameterList& p) :
00018   wBF         (p.get<std::string>                   ("Weighted BF Name"),
00019          p.get<Teuchos::RCP<PHX::DataLayout> >("Node QP Scalar Data Layout") ),
00020   U           (p.get<std::string>                   ("U Variable Name"),
00021          p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00022   V           (p.get<std::string>                   ("V Variable Name"),
00023          p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00024   wGradBF     (p.get<std::string>                   ("Weighted Gradient BF Name"),
00025          p.get<Teuchos::RCP<PHX::DataLayout> >("Node QP Vector Data Layout") ),
00026   UGrad       (p.get<std::string>                   ("U Gradient Variable Name"),
00027          p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00028   VGrad       (p.get<std::string>                   ("V Gradient Variable Name"),
00029          p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00030   USource     (p.get<std::string>                   ("U Pressure Source Name"),
00031          p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00032   VSource     (p.get<std::string>                   ("V Pressure Source Name"),
00033          p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00034   haveSource  (p.get<bool>("Have Source")),
00035   ksqr        (p.get<double>("Ksqr")),
00036   UResidual   (p.get<std::string>                   ("U Residual Name"),
00037          p.get<Teuchos::RCP<PHX::DataLayout> >("Node Scalar Data Layout") ),
00038   VResidual   (p.get<std::string>                   ("V Residual Name"),
00039          p.get<Teuchos::RCP<PHX::DataLayout> >("Node Scalar Data Layout") )
00040 {
00041   this->addDependentField(wBF);
00042   this->addDependentField(U);
00043   this->addDependentField(V);
00044   this->addDependentField(wGradBF);
00045   this->addDependentField(UGrad);
00046   this->addDependentField(VGrad);
00047   if (haveSource) {
00048     this->addDependentField(USource);
00049     this->addDependentField(VSource);
00050   }
00051 
00052   this->addEvaluatedField(UResidual);
00053   this->addEvaluatedField(VResidual);
00054 
00055   this->setName("HelmholtzResid"+PHX::TypeString<EvalT>::value);
00056 
00057   // Add K-Squared wavelength as a Sacado-ized parameter
00058   Teuchos::RCP<ParamLib> paramLib =
00059     p.get< Teuchos::RCP<ParamLib> >("Parameter Library");
00060   new Sacado::ParameterRegistration<EvalT, SPL_Traits>("Ksqr", this, paramLib);
00061 
00062 }
00063 
00064 //**********************************************************************
00065 template<typename EvalT, typename Traits>
00066 void HelmholtzResid<EvalT, Traits>::
00067 postRegistrationSetup(typename Traits::SetupData d,
00068                       PHX::FieldManager<Traits>& fm)
00069 {
00070   this->utils.setFieldData(wBF,fm);
00071   this->utils.setFieldData(U,fm);
00072   this->utils.setFieldData(V,fm);
00073   this->utils.setFieldData(wGradBF,fm);
00074   this->utils.setFieldData(UGrad,fm);
00075   this->utils.setFieldData(VGrad,fm);
00076   if (haveSource) {
00077     this->utils.setFieldData(USource,fm);
00078     this->utils.setFieldData(VSource,fm);
00079   }
00080   this->utils.setFieldData(UResidual,fm);
00081   this->utils.setFieldData(VResidual,fm);
00082 }
00083 
00084 //**********************************************************************
00085 template<typename EvalT, typename Traits>
00086 void HelmholtzResid<EvalT, Traits>::
00087 evaluateFields(typename Traits::EvalData workset)
00088 {
00089   typedef Intrepid::FunctionSpaceTools FST;
00090 
00091   FST::integrate<ScalarT>(UResidual, UGrad, wGradBF, Intrepid::COMP_CPP, false); // "false" overwrites
00092   FST::integrate<ScalarT>(VResidual, VGrad, wGradBF, Intrepid::COMP_CPP, false);
00093 
00094   for (int i=0; i < UResidual.size() ; i++) {
00095     UResidual[i] *= -1.0; 
00096     VResidual[i] *= -1.0;
00097   }
00098 
00099   if (haveSource) {
00100     FST::integrate<ScalarT>(UResidual, USource, wBF, Intrepid::COMP_CPP, true); // "true" sums into
00101     FST::integrate<ScalarT>(VResidual, VSource, wBF, Intrepid::COMP_CPP, true);
00102   }
00103 
00104   if (ksqr != 1.0) {
00105     for (int i=0; i < U.size() ; i++) {
00106       U[i] *= ksqr;
00107       V[i] *= ksqr;
00108     }
00109   }
00110 
00111   FST::integrate<ScalarT>(UResidual, U, wBF, Intrepid::COMP_CPP, true); // "true" sums into
00112   FST::integrate<ScalarT>(VResidual, V, wBF, Intrepid::COMP_CPP, true);
00113 
00114  // Potential code for "attenuation"  (1 - 0.05i)k^2 \phi
00115  /*
00116   double alpha=0.05;
00117   for (int i=0; i < U.size() ; i++) {
00118     U[i] *= -alpha;
00119     V[i] *=  alpha;
00120   }
00121 
00122   FST::integrate<ScalarT>(UResidual, V, wBF, Intrepid::COMP_CPP, true); // "true" sums into
00123   FST::integrate<ScalarT>(VResidual, U, wBF, Intrepid::COMP_CPP, true);
00124  */
00125 }
00126 
00127 //**********************************************************************
00128 }
00129 

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