Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "Teuchos_TestForException.hpp"
00008 #include "Teuchos_VerboseObject.hpp"
00009 #include "Phalanx_DataLayout.hpp"
00010 #include "Sacado_ParameterRegistration.hpp"
00011
00012 #include "Intrepid_FunctionSpaceTools.hpp"
00013 #include "Albany_Layouts.hpp"
00014
00015
00016 namespace Aeras {
00017
00018 const double pi = 3.1415926535897932385;
00019
00020
00021 template<typename EvalT, typename Traits>
00022 SurfaceHeight<EvalT, Traits>::
00023 SurfaceHeight(const Teuchos::ParameterList& p,
00024 const Teuchos::RCP<Albany::Layouts>& dl) :
00025 sphere_coord (p.get<std::string> ("Spherical Coord Name"), dl->qp_gradient),
00026 hs (p.get<std::string> ("Aeras Surface Height QP Variable Name"), dl->qp_scalar)
00027 {
00028 Teuchos::ParameterList* hs_list =
00029 p.get<Teuchos::ParameterList*>("Parameter List");
00030
00031 std::string hsType = hs_list->get("Type", "None");
00032
00033 gravity = hs_list->get<double>("Gravity", 1.0);
00034
00035 Teuchos::RCP<Teuchos::FancyOStream> out(Teuchos::VerboseObjectBase::getDefaultOStream());
00036 if (hsType == "None"){
00037 *out << "Zero surface height!" << std::endl;
00038 hs_type = NONE;
00039 }
00040 else if (hsType == "Mountain") {
00041 *out << "Mountain surface height!" << std::endl;
00042 hs_type = MOUNTAIN;
00043 sphere_coord = PHX::MDField<MeshScalarT,Cell,QuadPoint,Dim>(
00044 p.get<std::string>("Spherical Coord Name"),dl->qp_gradient);
00045 this->addDependentField(sphere_coord);
00046 }
00047
00048 this->addEvaluatedField(hs);
00049
00050 std::vector<PHX::DataLayout::size_type> dims;
00051 dl->qp_gradient->dimensions(dims);
00052 numQPs = dims[1];
00053 numDims = dims[2];
00054
00055 this->setName("SurfaceHeight"+PHX::TypeString<EvalT>::value);
00056 }
00057
00058
00059 template<typename EvalT, typename Traits>
00060 void SurfaceHeight<EvalT, Traits>::
00061 postRegistrationSetup(typename Traits::SetupData d,
00062 PHX::FieldManager<Traits>& fm)
00063 {
00064 this->utils.setFieldData(hs,fm);
00065 if (hs_type == MOUNTAIN)
00066 this->utils.setFieldData(sphere_coord,fm);
00067 }
00068
00069
00070
00071
00072
00073 template<typename EvalT,typename Traits>
00074 typename SurfaceHeight<EvalT,Traits>::ScalarT&
00075 SurfaceHeight<EvalT,Traits>::getValue(const std::string &n)
00076 {
00077 return gravity;
00078 }
00079
00080
00081
00082 template<typename EvalT, typename Traits>
00083 void SurfaceHeight<EvalT, Traits>::
00084 evaluateFields(typename Traits::EvalData workset)
00085 {
00086 switch (hs_type) {
00087 case NONE:
00088 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00089 for (std::size_t qp=0; qp < numQPs; ++qp)
00090 hs(cell,qp) = 0.0;
00091 }
00092 break;
00093 case MOUNTAIN:
00094 const double R = pi/9.0;
00095 const double lambdac = 2.0*pi/3.0;
00096 const double thetac = pi/6.0;
00097 const double hs0 = 2000;
00098 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00099 for (std::size_t qp = 0; qp < numQPs; ++qp) {
00100 MeshScalarT lambda = sphere_coord(cell,qp,1);
00101 MeshScalarT theta = sphere_coord(cell,qp,0);
00102 MeshScalarT radius2 = (lambda-lambdac)*(lambda-lambdac) + (theta-thetac)*(theta-thetac);
00103
00104 MeshScalarT r;
00105 if (radius2 > R*R) r = R;
00106 else r = sqrt(radius2);
00107
00108 hs(cell,qp) = hs0*(1.0-r/R);
00109 }
00110 }
00111 break;
00112 }
00113 }
00114 }