Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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;
00028 const double rho = 910;
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
00071
00072
00073
00074
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