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