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

FELIX_StokesL1L2BodyForce_Def.hpp

Go to the documentation of this file.
00001 /********************************************************************\
00002 *            Albany, Copyright (2010) Sandia Corporation             *
00003 *                                                                    *
00004 * Notice: This computer software was prepared by Sandia Corporation, *
00005 * hereinafter the Contractor, under Contract DE-AC04-94AL85000 with  *
00006 * the Department of Energy (DOE). All rights in the computer software*
00007 * are reserved by DOE on behalf of the United States Government and  *
00008 * the Contractor as provided in the Contract. You are authorized to  *
00009 * use this computer software for Governmental purposes but it is not *
00010 * to be released or distributed to the public. NEITHER THE GOVERNMENT*
00011 * NOR THE CONTRACTOR MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR      *
00012 * ASSUMES ANY LIABILITY L1L2R THE USE OF THIS SOFTWARE. This notice    *
00013 * including this sentence must appear on any copies of this software.*
00014 *    Questions to Andy Salinger, agsalin@sandia.gov                  *
00015 \********************************************************************/
00016 
00017 
00018 #include "Teuchos_TestForException.hpp"
00019 #include "Teuchos_VerboseObject.hpp"
00020 #include "Phalanx_DataLayout.hpp"
00021 #include "Sacado.hpp"
00022 
00023 #include "Intrepid_FunctionSpaceTools.hpp"
00024 
00025 namespace FELIX {
00026 const double pi = 3.1415926535897932385;
00027 const double g = 9.8; //gravity for FELIX; hard-coded here for now
00028 const double rho = 910; //density for FELIX; hard-coded here for now
00029 
00030 //**********************************************************************
00031 
00032 template<typename EvalT, typename Traits>
00033 StokesL1L2BodyForce<EvalT, Traits>::
00034 StokesL1L2BodyForce(const Teuchos::ParameterList& p,
00035                     const Teuchos::RCP<Albany::Layouts>& dl) :
00036   force(p.get<std::string>("Body Force Name"), dl->qp_vector ), 
00037   A(1.0), 
00038   n(3.0), 
00039   alpha(0.0)
00040 {
00041   Teuchos::ParameterList* bf_list = 
00042     p.get<Teuchos::ParameterList*>("Parameter List");
00043 
00044   std::string type = bf_list->get("Type", "None");
00045   A = bf_list->get("Glen's Law A", 1.0); 
00046   n = bf_list->get("Glen's Law n", 3.0); 
00047   alpha = bf_list->get("FELIX alpha", 0.0);
00048   if (type == "None") {
00049     bf_type = NONE;
00050   }
00051   else if (type == "L1L2SinCos") {
00052     bf_type = L1L2_SINCOS;  
00053     muFELIX = PHX::MDField<ScalarT,Cell,QuadPoint>(
00054             p.get<std::string>("FELIX Viscosity QP Variable Name"),dl->qp_scalar); 
00055     coordVec = PHX::MDField<MeshScalarT,Cell,QuadPoint,Dim>(
00056             p.get<std::string>("Coordinate Vector Name"), dl->qp_gradient);
00057     this->addDependentField(muFELIX); 
00058     this->addDependentField(coordVec);
00059   }
00060 
00061   this->addEvaluatedField(force);
00062 
00063   std::vector<PHX::DataLayout::size_type> dims;
00064   dl->qp_gradient->dimensions(dims);
00065   numQPs  = dims[1];
00066   numDims = dims[2];
00067   dl->qp_vector->dimensions(dims);
00068   vecDim  = dims[2];
00069 
00070 //  Teuchos::RCP<Teuchos::FancyOStream> out(Teuchos::VerboseObjectBase::getDefaultOStream());
00071 //*out << " in FELIX Stokes L1L2 source! " << endl;
00072 //*out << " vecDim = " << vecDim << endl;
00073 //*out << " numDims = " << numDims << endl;
00074 //*out << " numQPs = " << numQPs << endl; 
00075 
00076 
00077   this->setName("StokesL1L2BodyForce"+PHX::TypeString<EvalT>::value);
00078 }
00079 
00080 //**********************************************************************
00081 template<typename EvalT, typename Traits>
00082 void StokesL1L2BodyForce<EvalT, Traits>::
00083 postRegistrationSetup(typename Traits::SetupData d,
00084                       PHX::FieldManager<Traits>& fm)
00085 {
00086   this->utils.setFieldData(force,fm); 
00087   if (bf_type == L1L2_SINCOS) {
00088     this->utils.setFieldData(muFELIX,fm);
00089     this->utils.setFieldData(coordVec,fm);
00090   }
00091 }
00092 
00093 //**********************************************************************
00094 template<typename EvalT, typename Traits>
00095 void StokesL1L2BodyForce<EvalT, Traits>::
00096 evaluateFields(typename Traits::EvalData workset)
00097 {
00098  if (bf_type == NONE) {
00099    for (std::size_t cell=0; cell < workset.numCells; ++cell) 
00100      for (std::size_t qp=0; qp < numQPs; ++qp)       
00101        for (std::size_t i=0; i < vecDim; ++i) 
00102      force(cell,qp,i) = 0.0;
00103  }
00104  else if (bf_type == L1L2_SINCOS) {
00105    double xphase=0.0, yphase=0.0;
00106    double r = 3*pi;
00107    for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00108      for (std::size_t qp=0; qp < numQPs; ++qp) {      
00109        ScalarT* f = &force(cell,qp,0);
00110        MeshScalarT x2pi = 2.0*pi*coordVec(cell,qp,0);
00111        MeshScalarT y2pi = 2.0*pi*coordVec(cell,qp,1);
00112        MeshScalarT muargt = 2.0*pi*cos(x2pi + xphase)*cos(y2pi + yphase) + r;  
00113        MeshScalarT muqp = pow(A, -1.0/n)*pow(muargt, 1.0/n - 1.0);
00114        MeshScalarT dmuargtdx = -4.0*pi*pi*sin(x2pi + xphase)*cos(y2pi + yphase); 
00115        MeshScalarT dmuargtdy = -4.0*pi*pi*cos(x2pi + xphase)*sin(y2pi + yphase); 
00116        MeshScalarT exx = 2.0*pi*cos(x2pi + xphase)*cos(y2pi + yphase) + r; 
00117        MeshScalarT eyy = -2.0*pi*cos(x2pi + xphase)*cos(y2pi + yphase) - r; 
00118        MeshScalarT exy = 0.0;  
00119        f[0] = 2.0*muqp*(-4.0*pi*pi*sin(x2pi + xphase)*cos(y2pi + yphase))  
00120             + 2.0*pow(A, -1.0/n)*(1.0/n - 1.0)*pow(muargt, 1.0/n - 2.0)*(dmuargtdx*(2.0*exx + eyy) + dmuargtdy*exy); 
00121        f[1] = 2.0*muqp*(4.0*pi*pi*cos(x2pi + xphase)*sin(y2pi + yphase)) 
00122             + 2.0*pow(A, -1.0/n)*(1.0/n - 1.0)*pow(muargt, 1.0/n - 2.0)*(dmuargtdx*exy + dmuargtdy*(exx + 2.0*eyy));
00123      }
00124    }
00125  }
00126 }
00127 }
00128 

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