Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include <Teuchos_TestForException.hpp>
00008 #include <Phalanx_DataLayout.hpp>
00009
00010 namespace LCM {
00011
00012
00013 template<typename EvalT, typename Traits>
00014 GradientElementLength<EvalT, Traits>::
00015 GradientElementLength(const Teuchos::ParameterList& p,
00016 const Teuchos::RCP<Albany::Layouts>& dl) :
00017 grad_bf_(p.get<std::string>("Gradient BF Name"), dl->node_qp_vector),
00018 unit_grad_(p.get<std::string>("Unit Gradient QP Variable Name"), dl->qp_vector),
00019 element_length_(p.get<std::string>("Element Length Name"), dl->qp_scalar)
00020 {
00021 this->addDependentField(unit_grad_);
00022 this->addDependentField(grad_bf_);
00023 this->addEvaluatedField(element_length_);
00024
00025 this->setName("Element Length"+PHX::TypeString<EvalT>::value);
00026
00027 std::vector<PHX::DataLayout::size_type> dims;
00028 dl->node_qp_vector->dimensions(dims);
00029 num_nodes_ = dims[1];
00030 num_pts_ = dims[2];
00031 num_dims_ = dims[3];
00032 }
00033
00034
00035 template<typename EvalT, typename Traits>
00036 void GradientElementLength<EvalT, Traits>::
00037 postRegistrationSetup(typename Traits::SetupData d,
00038 PHX::FieldManager<Traits>& fm)
00039 {
00040 this->utils.setFieldData(grad_bf_,fm);
00041 this->utils.setFieldData(unit_grad_,fm);
00042 this->utils.setFieldData(element_length_,fm);
00043 }
00044
00045
00046 template<typename EvalT, typename Traits>
00047 void GradientElementLength<EvalT, Traits>::
00048 evaluateFields(typename Traits::EvalData workset)
00049 {
00050 ScalarT scalar_h(0.0);
00051
00052 for (std::size_t cell(0); cell < workset.numCells; ++cell) {
00053 for (std::size_t pt(0); pt < num_pts_; ++pt) {
00054 scalar_h = 0.0;
00055 for (std::size_t j(0); j < num_dims_; ++j) {
00056 for (std::size_t node(0); node < num_nodes_; ++node) {
00057 scalar_h +=
00058 std::abs(grad_bf_(cell,node,pt,j)/std::sqrt(num_dims_));
00059 }
00060 }
00061 element_length_(cell,pt) = 2.0/scalar_h;
00062 }
00063 }
00064 }
00065
00066 }