00001
00002
00003
00004
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 DOFVecGradInterpolation<EvalT, Traits>::
00017 DOFVecGradInterpolation(const Teuchos::ParameterList& p,
00018 const Teuchos::RCP<Albany::Layouts>& dl) :
00019 val_node (p.get<std::string> ("Variable Name"), dl->node_vector),
00020 GradBF (p.get<std::string> ("Gradient BF Name"), dl->node_qp_gradient ),
00021 grad_val_qp (p.get<std::string> ("Gradient Variable Name"), dl->qp_vecgradient )
00022 {
00023 this->addDependentField(val_node);
00024 this->addDependentField(GradBF);
00025 this->addEvaluatedField(grad_val_qp);
00026
00027 this->setName("DOFVecGradInterpolation"+PHX::TypeString<EvalT>::value);
00028
00029 std::vector<PHX::DataLayout::size_type> dims;
00030 GradBF.fieldTag().dataLayout().dimensions(dims);
00031 numNodes = dims[1];
00032 numQPs = dims[2];
00033 numDims = dims[3];
00034
00035 val_node.fieldTag().dataLayout().dimensions(dims);
00036 vecDim = dims[2];
00037 }
00038
00039
00040 template<typename EvalT, typename Traits>
00041 void DOFVecGradInterpolation<EvalT, Traits>::
00042 postRegistrationSetup(typename Traits::SetupData d,
00043 PHX::FieldManager<Traits>& fm)
00044 {
00045 this->utils.setFieldData(val_node,fm);
00046 this->utils.setFieldData(GradBF,fm);
00047 this->utils.setFieldData(grad_val_qp,fm);
00048 }
00049
00050
00051 template<typename EvalT, typename Traits>
00052 void DOFVecGradInterpolation<EvalT, Traits>::
00053 evaluateFields(typename Traits::EvalData workset)
00054 {
00055
00056
00057
00058 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00059 for (std::size_t qp=0; qp < numQPs; ++qp) {
00060 for (std::size_t i=0; i<vecDim; i++) {
00061 for (std::size_t dim=0; dim<numDims; dim++) {
00062
00063 ScalarT& gvqp = grad_val_qp(cell,qp,i,dim);
00064 gvqp = val_node(cell, 0, i) * GradBF(cell, 0, qp, dim);
00065 for (std::size_t node= 1 ; node < numNodes; ++node) {
00066 gvqp += val_node(cell, node, i) * GradBF(cell, node, qp, dim);
00067
00068 }
00069 }
00070 }
00071 }
00072 }
00073
00074 }
00075
00076
00077 template<typename Traits>
00078 DOFVecGradInterpolation<PHAL::AlbanyTraits::Jacobian, Traits>::
00079 DOFVecGradInterpolation(const Teuchos::ParameterList& p,
00080 const Teuchos::RCP<Albany::Layouts>& dl) :
00081 val_node (p.get<std::string> ("Variable Name"), dl->node_vector),
00082 GradBF (p.get<std::string> ("Gradient BF Name"), dl->node_qp_gradient ),
00083 grad_val_qp (p.get<std::string> ("Gradient Variable Name"), dl->qp_vecgradient )
00084 {
00085 this->addDependentField(val_node);
00086 this->addDependentField(GradBF);
00087 this->addEvaluatedField(grad_val_qp);
00088
00089 this->setName("DOFVecGradInterpolation"+PHX::TypeString<PHAL::AlbanyTraits::Jacobian>::value);
00090
00091 std::vector<PHX::DataLayout::size_type> dims;
00092 GradBF.fieldTag().dataLayout().dimensions(dims);
00093 numNodes = dims[1];
00094 numQPs = dims[2];
00095 numDims = dims[3];
00096
00097 val_node.fieldTag().dataLayout().dimensions(dims);
00098 vecDim = dims[2];
00099
00100 offset = p.get<int>("Offset of First DOF");
00101 }
00102
00103
00104 template<typename Traits>
00105 void DOFVecGradInterpolation<PHAL::AlbanyTraits::Jacobian, Traits>::
00106 postRegistrationSetup(typename Traits::SetupData d,
00107 PHX::FieldManager<Traits>& fm)
00108 {
00109 this->utils.setFieldData(val_node,fm);
00110 this->utils.setFieldData(GradBF,fm);
00111 this->utils.setFieldData(grad_val_qp,fm);
00112 }
00113
00114
00115 template<typename Traits>
00116 void DOFVecGradInterpolation<PHAL::AlbanyTraits::Jacobian, Traits>::
00117 evaluateFields(typename Traits::EvalData workset)
00118 {
00119 int num_dof = val_node(0,0,0).size();
00120 int neq = num_dof / numNodes;
00121
00122 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00123 for (std::size_t qp=0; qp < numQPs; ++qp) {
00124 for (std::size_t i=0; i<vecDim; i++) {
00125 for (std::size_t dim=0; dim<numDims; dim++) {
00126
00127 ScalarT& gvqp = grad_val_qp(cell,qp,i,dim);
00128 gvqp = FadType(num_dof, val_node(cell, 0, i).val() * GradBF(cell, 0, qp, dim));
00129 gvqp.fastAccessDx(offset+i) = val_node(cell, 0, i).fastAccessDx(offset+i) * GradBF(cell, 0, qp, dim);
00130 for (std::size_t node= 1 ; node < numNodes; ++node) {
00131 gvqp.val() += val_node(cell, node, i).val() * GradBF(cell, node, qp, dim);
00132 gvqp.fastAccessDx(neq*node+offset+i) += val_node(cell, node, i).fastAccessDx(neq*node+offset+i) * GradBF(cell, node, qp, dim);
00133 }
00134 }
00135 }
00136 }
00137 }
00138
00139 }
00140
00141
00142 }