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

FELIX_ViscosityL1L2_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_ParameterRegistration.hpp" 
00022 
00023 #include "Intrepid_FunctionSpaceTools.hpp"
00024 
00025 namespace FELIX {
00026 
00027 const double pi = 3.1415926535897932385;
00028 const double g = 9.8; //gravity for FELIX; hard-coded here for now
00029 const double rho = 910; //density for FELIX; hard-coded here for now
00030 //should values of these be hard-coded here, or read in from the input file?
00031 //for now, I have hard coded them here.
00032  
00033 //**********************************************************************
00034 template<typename EvalT, typename Traits>
00035 ViscosityL1L2<EvalT, Traits>::
00036 ViscosityL1L2(const Teuchos::ParameterList& p,
00037               const Teuchos::RCP<Albany::Layouts>& dl) :
00038   mu          (p.get<std::string> ("FELIX Viscosity QP Variable Name"), dl->qp_scalar), 
00039   epsilonB    (p.get<std::string> ("FELIX EpsilonB QP Variable Name"), dl->qp_scalar), 
00040   homotopyParam (1.0), 
00041   A(1.0), 
00042   n(3.0)
00043 {
00044   Teuchos::ParameterList* visc_list = 
00045    p.get<Teuchos::ParameterList*>("Parameter List");
00046 
00047   std::string viscType = visc_list->get("Type", "Constant");
00048   homotopyParam = visc_list->get("Glen's Law Homotopy Parameter", 0.2);
00049   A = visc_list->get("Glen's Law A", 1.0); 
00050   n = visc_list->get("Glen's Law n", 3.0);  
00051 
00052   //L and alpha: parameters for ISMIP-HOM test cases
00053   L = visc_list->get("L", 1.0); 
00054   alpha = visc_list->get("alpha", 0.0);
00055   alpha *= pi/180; 
00056    
00057   //type of geometry for basal/surface boundaries
00058   surfType = visc_list->get("Z Surface", "Box");
00059 
00060   Teuchos::RCP<Teuchos::FancyOStream> out(Teuchos::VerboseObjectBase::getDefaultOStream());
00061   if (viscType == "Constant"){ 
00062     *out << "Constant viscosity!" << std::endl;
00063     visc_type = CONSTANT;
00064   }
00065   else if (viscType == "Glen's Law"){
00066     visc_type = GLENSLAW; 
00067     *out << "Glen's law viscosity!" << std::endl;
00068     *out << "A: " << A << std::endl; 
00069     *out << "n: " << n << std::endl;  
00070   }
00071 
00072   if (surfType == "Box") 
00073     surf_type = BOX; 
00074   else if (surfType == "Test A")
00075     surf_type == TESTA; 
00076   
00077   coordVec = PHX::MDField<MeshScalarT,Cell,QuadPoint,Dim>(
00078             p.get<std::string>("Coordinate Vector Name"), dl->qp_gradient);
00079 
00080   this ->addDependentField(coordVec); 
00081   this ->addDependentField(epsilonB); 
00082   this->addEvaluatedField(mu);
00083 
00084   numQPsZ = 100; 
00085 
00086   std::vector<PHX::DataLayout::size_type> dims;
00087   dl->qp_gradient->dimensions(dims);
00088   numQPs  = dims[1];
00089   numDims = dims[2];
00090 
00091   Teuchos::RCP<ParamLib> paramLib = p.get< Teuchos::RCP<ParamLib> >("Parameter Library"); 
00092   
00093   new Sacado::ParameterRegistration<EvalT, SPL_Traits>("Glen's Law Homotopy Parameter", this, paramLib);   
00094 
00095   this->setName("ViscosityL1L2"+PHX::TypeString<EvalT>::value);
00096 }
00097 
00098 //**********************************************************************
00099 template<typename EvalT, typename Traits>
00100 void ViscosityL1L2<EvalT, Traits>::
00101 postRegistrationSetup(typename Traits::SetupData d,
00102                       PHX::FieldManager<Traits>& fm)
00103 {
00104   this->utils.setFieldData(mu,fm); 
00105   this->utils.setFieldData(coordVec,fm); 
00106   this->utils.setFieldData(epsilonB,fm); 
00107 }
00108 
00109 //**********************************************************************
00110 template<typename EvalT,typename Traits>
00111 typename ViscosityL1L2<EvalT,Traits>::ScalarT& 
00112 ViscosityL1L2<EvalT,Traits>::getValue(const std::string &n)
00113 {
00114   return homotopyParam;
00115 }
00116 
00117 //**********************************************************************
00118 template<typename EvalT, typename Traits>
00119 void ViscosityL1L2<EvalT, Traits>::
00120 evaluateFields(typename Traits::EvalData workset)
00121 {
00122   if (visc_type == CONSTANT){
00123     for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00124       for (std::size_t qp=0; qp < numQPs; ++qp) {
00125         mu(cell,qp) = 1.0; 
00126       }
00127     }
00128   }
00129   else if (visc_type == GLENSLAW) {
00130     if (n == 1.0) {
00131       for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00132         for (std::size_t qp=0; qp < numQPs; ++qp) {
00133           mu(cell,qp) = 1.0/A; 
00134         }
00135       }
00136     }
00137     else if (n == 3.0) {
00138       if (surf_type == BOX) {
00139         if (homotopyParam == 0.0) {
00140           for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00141             for (std::size_t qp=0; qp < numQPs; ++qp) {
00142               mu(cell,qp) = pow(A, -1.0/3.0);
00143            }
00144          }
00145        }
00146         else {
00147           ScalarT ff = pow(10.0, -10.0*homotopyParam);
00148           for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00149             for (std::size_t qp=0; qp < numQPs; ++qp) {
00150                mu(cell,qp) = epsilonB(cell,qp) + ff; 
00151                mu(cell,qp) = sqrt(mu(cell,qp)); 
00152                mu(cell,qp) = pow(A, -1.0/3.0)*pow(mu(cell,qp), -2.0/3.0); 
00153             }
00154           }
00155         }
00156       }
00157       else if (surf_type == TESTA) { //ISMIP-HOM Test A
00158         PHX::MDField<ScalarT,Cell,QuadPoint> q;
00159         PHX::MDField<ScalarT,Cell,QuadPoint> w;
00160         PHX::MDField<ScalarT,Cell,QuadPoint> tauPar2;
00161         PHX::MDField<ScalarT,Cell,QuadPoint> Int;
00162         for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00163           for (std::size_t qp=0; qp < numQPs; ++qp) {
00164              MeshScalarT x = coordVec(cell,qp,0);
00165              MeshScalarT y = coordVec(cell,qp,1);
00166              MeshScalarT s = -x*tan(alpha);
00167              MeshScalarT b = s - 1.0 + 0.5*sin(2.0*pi*x/L)*sin(2.0*pi*y/L);
00168              MeshScalarT dsdx = -tan(alpha);
00169              MeshScalarT dsdy = 0.0; 
00170              Int(cell,qp) = 0.0; 
00171              q(cell,qp) = 1.0/(2.0*A)*sqrt(epsilonB(cell,qp)); //TO DO: need to put in continuation here 
00172              for (std::size_t qpZ = 0; qp<numQPsZ; ++qpZ) { //apply Trapezoidal rule to compute integral in z
00173                 MeshScalarT zQP = qpZ*(s-b)/(2.0*numQPsZ); 
00174                 MeshScalarT tauPerp2 = rho*rho*g*g*(s-zQP)*(s-zQP)*(dsdx*dsdx + dsdy*dsdy); 
00175                 MeshScalarT p = 1.0/3.0*tauPerp2;
00176                 w(cell,qp) = pow(q(cell,qp) + sqrt(q(cell,qp)*q(cell,qp) + p*p*p), 1.0/3.0); 
00177                 tauPar2(cell,qp) = (w(cell,qp)-p/(3.0*w(cell,qp)))*(w(cell,qp)-p/(3.0*w(cell,qp))); 
00178                 Int(cell,qp) += 1.0/(tauPerp2 + tauPar2(cell,qp));  
00179              }
00180             mu(cell,qp) = 1.0/A*Int(cell,qp); 
00181           }
00182         }
00183       }
00184     }
00185   }
00186 }
00187 }

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