Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include "Teuchos_TestForException.hpp"
00007 #include "Phalanx_DataLayout.hpp"
00008
00009 #include "Intrepid_FunctionSpaceTools.hpp"
00010 #include "Intrepid_RealSpaceTools.hpp"
00011
00012 #include <typeinfo>
00013
00014 namespace LCM {
00015
00016 template<typename EvalT, typename Traits>
00017 FaceAverage<EvalT, Traits>::
00018 FaceAverage(const Teuchos::ParameterList& p) :
00019 coordinates(p.get<std::string>("Coordinate Vector Name"),
00020 p.get<Teuchos::RCP<PHX::DataLayout> >("Vertex Vector Data Layout")),
00021 projected(p.get<std::string>("Projected Field Name"),
00022 p.get<Teuchos::RCP<PHX::DataLayout> >("Node Vector Data Layout")),
00023 cubature(p.get<Teuchos::RCP<Intrepid::Cubature<RealType> > >("Face Cubature")),
00024 intrepidBasis(p.get<Teuchos::RCP<Intrepid::Basis
00025 <RealType, Intrepid::FieldContainer<RealType> > > >("Face Intrepid Basis")),
00026 cellType(p.get<Teuchos::RCP<shards::CellTopology> >("Cell Type")),
00027 faceAve(p.get<std::string>("Face Average Name"),
00028 p.get<Teuchos::RCP<PHX::DataLayout> >("Face Vector Data Layout")),
00029 temp(p.get<std::string>("Temp Name"),
00030 p.get<Teuchos::RCP<PHX::DataLayout> >("Cell Scalar Data Layout"))
00031 {
00032 this->addDependentField(coordinates);
00033 this->addDependentField(projected);
00034 this->addEvaluatedField(faceAve);
00035
00036 this->addEvaluatedField(temp);
00037
00038
00039 Teuchos::RCP<PHX::DataLayout> vec_dl =
00040 p.get<Teuchos::RCP<PHX::DataLayout> >("Node Vector Data Layout");
00041 std::vector<PHX::DataLayout::size_type> dims;
00042 vec_dl->dimensions(dims);
00043
00044 worksetSize = dims[0];
00045 numNodes = dims[1];
00046 numComp = dims[2];
00047
00048
00049
00050
00051
00052 Teuchos::RCP<PHX::DataLayout> vertex_dl =
00053 p.get<Teuchos::RCP<PHX::DataLayout> >("Vertex Vector Data Layout");
00054 vertex_dl->dimensions(dims);
00055 numDims = dims[2];
00056
00057
00058 numQPs = cubature->getNumPoints();
00059
00060 numFaces = cellType->getFaceCount();
00061 faceDim = numDims - 1;
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 numFaceNodes = cellType->getNodeCount(numDims-1,0);
00073
00074
00075 sides = cellType->getCellTopologyData()->side;
00076
00077
00078 refPoints.resize(numQPs,faceDim);
00079 refWeights.resize(numQPs);
00080 refValues.resize(numFaceNodes,numQPs);
00081
00082 cubature->getCubature(refPoints,refWeights);
00083 intrepidBasis->getValues(refValues, refPoints, Intrepid::OPERATOR_VALUE);
00084
00085
00086 this->setName("FaceAverage"+PHX::TypeString<EvalT>::value);
00087
00088 }
00089
00090 template<typename EvalT, typename Traits>
00091 void FaceAverage<EvalT,Traits>::
00092 postRegistrationSetup(typename Traits::SetupData d,
00093 PHX::FieldManager<Traits>& fm)
00094 {
00095 this->utils.setFieldData(coordinates,fm);
00096 this->utils.setFieldData(projected, fm);
00097 this->utils.setFieldData(faceAve, fm);
00098
00099 this->utils.setFieldData(temp,fm);
00100
00101 }
00102
00103 template<typename EvalT, typename Traits>
00104 void FaceAverage<EvalT,Traits>::
00105 evaluateFields(typename Traits::EvalData workset)
00106 {
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 for (std::size_t cell=0; cell < workset.numCells; ++cell)
00121 {
00122 for (std::size_t face=0; face<numFaces; ++face)
00123 {
00124 for (std::size_t comp=0; comp<numComp; ++comp)
00125 {
00126 faceAve(cell,face,comp) = 0.0;
00127 double area = 0.0;
00128
00129 for (std::size_t qp=0; qp<numQPs; ++qp)
00130 {
00131 area += refWeights(qp);
00132
00133 for (std::size_t np=0; np<numFaceNodes; ++np)
00134 {
00135
00136
00137 int node = sides[face].node[np];
00138 faceAve(cell,face,comp) += refValues(np,qp)*projected(cell,node,comp)*refWeights(qp);
00139
00140
00141 }
00142 }
00143
00144 faceAve(cell,face,comp) = faceAve(cell,face,comp) / area;
00145
00146
00147
00148
00149
00150
00151 }
00152 }
00153
00154
00155 temp(cell) = cell;
00156 }
00157 }
00158
00159 }
00160