00001
00002
00003
00004
00005
00006
00007
00008 #include "Teuchos_TestForException.hpp"
00009 #include "Phalanx_DataLayout.hpp"
00010
00011 #include <Intrepid_MiniTensor.h>
00012
00013
00014 #include "Intrepid_FunctionSpaceTools.hpp"
00015 #include "Intrepid_RealSpaceTools.hpp"
00016
00017 namespace LCM {
00018
00019
00020 template<typename EvalT, typename Traits>
00021 SurfaceL2ProjectionResidual<EvalT, Traits>::
00022 SurfaceL2ProjectionResidual(const Teuchos::ParameterList& p,
00023 const Teuchos::RCP<Albany::Layouts>& dl) :
00024 thickness (p.get<double>("thickness")),
00025 cubature (p.get<Teuchos::RCP<Intrepid::Cubature<RealType> > >("Cubature")),
00026 intrepidBasis (p.get<Teuchos::RCP<Intrepid::Basis<RealType, Intrepid::FieldContainer<RealType> > > >("Intrepid Basis")),
00027 surface_Grad_BF (p.get<std::string>("Surface Scalar Gradient Operator Name"),dl->node_qp_gradient),
00028 refDualBasis (p.get<std::string>("Reference Dual Basis Name"),dl->qp_tensor),
00029 refNormal (p.get<std::string>("Reference Normal Name"),dl->qp_vector),
00030 refArea (p.get<std::string>("Reference Area Name"),dl->qp_scalar),
00031 Cauchy_stress_ (p.get<std::string>("Cauchy Stress Name"),dl->qp_tensor),
00032 detF_ (p.get<std::string>("Jacobian Name"),dl->qp_scalar),
00033 projected_tau_ (p.get<std::string>("HydoStress Name"),dl->qp_scalar),
00034 projection_residual_ (p.get<std::string>("Residual Name"),dl->node_scalar)
00035 {
00036 this->addDependentField(surface_Grad_BF);
00037 this->addDependentField(refDualBasis);
00038 this->addDependentField(refNormal);
00039 this->addDependentField(refArea);
00040 this->addDependentField(detF_);
00041 this->addDependentField(Cauchy_stress_);
00042 this->addDependentField(projected_tau_);
00043
00044 this->addEvaluatedField(projection_residual_);
00045
00046 this->setName("HydroStress Residual"+PHX::TypeString<EvalT>::value);
00047
00048 std::vector<PHX::DataLayout::size_type> dims;
00049 dl->node_vector->dimensions(dims);
00050 worksetSize = dims[0];
00051 numNodes = dims[1];
00052 numDims = dims[2];
00053
00054 numQPs = cubature->getNumPoints();
00055
00056 numPlaneNodes = numNodes / 2;
00057 numPlaneDims = numDims - 1;
00058
00059 #ifdef ALBANY_VERBOSE
00060 std::cout << "in Surface Scalar Residual" << std::endl;
00061 std::cout << " numPlaneNodes: " << numPlaneNodes << std::endl;
00062 std::cout << " numPlaneDims: " << numPlaneDims << std::endl;
00063 std::cout << " numQPs: " << numQPs << std::endl;
00064 std::cout << " cubature->getNumPoints(): " << cubature->getNumPoints() << std::endl;
00065 std::cout << " cubature->getDimension(): " << cubature->getDimension() << std::endl;
00066 #endif
00067
00068
00069 refValues.resize(numPlaneNodes, numQPs);
00070 refGrads.resize(numPlaneNodes, numQPs, numPlaneDims);
00071 refPoints.resize(numQPs, numPlaneDims);
00072 refWeights.resize(numQPs);
00073
00074
00075 cubature->getCubature(refPoints, refWeights);
00076 intrepidBasis->getValues(refValues, refPoints, Intrepid::OPERATOR_VALUE);
00077 intrepidBasis->getValues(refGrads, refPoints, Intrepid::OPERATOR_GRAD);
00078
00079 }
00080
00081
00082 template<typename EvalT, typename Traits>
00083 void SurfaceL2ProjectionResidual<EvalT, Traits>::
00084 postRegistrationSetup(typename Traits::SetupData d,
00085 PHX::FieldManager<Traits>& fm)
00086 {
00087 this->utils.setFieldData(surface_Grad_BF,fm);
00088 this->utils.setFieldData(refDualBasis,fm);
00089 this->utils.setFieldData(refNormal,fm);
00090 this->utils.setFieldData(refArea,fm);
00091 this->utils.setFieldData(projected_tau_, fm);
00092 this->utils.setFieldData(projection_residual_,fm);
00093
00094 this->utils.setFieldData(Cauchy_stress_,fm);
00095 this->utils.setFieldData(detF_,fm);
00096
00097 }
00098
00099
00100 template<typename EvalT, typename Traits>
00101 void SurfaceL2ProjectionResidual<EvalT, Traits>::
00102 evaluateFields(typename Traits::EvalData workset)
00103 {
00104
00105 typedef Intrepid::FunctionSpaceTools FST;
00106 typedef Intrepid::RealSpaceTools<ScalarT> RST;
00107
00108 ScalarT tau(0);
00109
00110
00111 for (std::size_t cell(0); cell < workset.numCells; ++cell) {
00112 for (std::size_t node(0); node < numPlaneNodes; ++node) {
00113 int topNode = node + numPlaneNodes;
00114 projection_residual_(cell, node) = 0;
00115 projection_residual_(cell, topNode) = 0;
00116 }
00117 }
00118
00119 for (std::size_t cell(0); cell < workset.numCells; ++cell) {
00120 for (std::size_t node(0); node < numPlaneNodes; ++node) {
00121 int topNode = node + numPlaneNodes;
00122 for (std::size_t pt=0; pt < numQPs; ++pt) {
00123 tau = 0.0;
00124 for (std::size_t dim=0; dim <numDims; ++dim){
00125 tau += detF_(cell,pt)*Cauchy_stress_(cell, pt, dim, dim)/numDims;
00126 }
00127
00128 projection_residual_(cell, node) += refValues(node,pt)*
00129 (projected_tau_(cell,pt) - tau)*
00130 refArea(cell,pt);
00131
00132 }
00133 projection_residual_(cell, topNode) = projection_residual_(cell, node);
00134
00135 }
00136 }
00137
00138 }
00139
00140 }