00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 #include "SundanceCellVectorExpr.hpp"
00032 #include "SundanceListExpr.hpp"
00033 #include "SundanceEvalManager.hpp"
00034 #include "SundanceSparsitySuperset.hpp"
00035 #include "SundanceOut.hpp"
00036 #include "SundanceObjectWithVerbosity.hpp"
00037 
00038 using namespace Sundance;
00039 using namespace Sundance;
00040 
00041 using namespace Sundance;
00042 using namespace Teuchos;
00043 
00044 
00045 
00046 namespace Sundance
00047 {
00048 
00049 Expr CellNormalExpr(int dimension, const std::string& name)
00050 {
00051   Array<Expr> comps(dimension);
00052   for (int i=0; i<dimension; i++)
00053   {
00054     comps[i] = new CellVectorExpr(i, dimension, name + "["
00055       + Teuchos::toString(i) + "]");
00056   }
00057   return new ListExpr(comps);
00058 }
00059 
00060 
00061 Expr CellTangentExpr(int dimension, const std::string& name)
00062 {
00063   Array<Expr> comp(dimension);
00064   for (int i=0; i<dimension; i++)
00065   {
00066     comp[i] = new CellVectorExpr(0, i, dimension, name + "("
00067         + Teuchos::toString(i) + ")");
00068   }
00069   return new ListExpr(comp);
00070 }
00071 
00072 }
00073 
00074 CellVectorExpr::CellVectorExpr(int tangentBasisIndex, 
00075              int tangentComponentIndex,
00076              int dim,
00077              const std::string& name)
00078   : EvaluatableExpr(), name_(name), dim_(dim), type_(CellTangentSpace),
00079     basisMemberIndex_(tangentBasisIndex), 
00080     componentIndex_(tangentComponentIndex)
00081 {}
00082 
00083 
00084 CellVectorExpr::CellVectorExpr(int normalComponentIndex, int dim,
00085   const std::string& name)
00086   : EvaluatableExpr(), name_(name), dim_(dim), type_(CellNormalVector),
00087     basisMemberIndex_(-1), componentIndex_(normalComponentIndex)
00088 {}
00089 
00090 bool CellVectorExpr::lessThan(const ScalarExpr* other) const
00091 {
00092   const CellVectorExpr* f = dynamic_cast<const CellVectorExpr*>(other);
00093   TEUCHOS_TEST_FOR_EXCEPTION(f==0, std::logic_error, "cast should never fail at this point");
00094   if (type_ < f->type_) return true;
00095   if (type_ > f->type_) return false;
00096   if (dim_ < f->dim_) return true;
00097   if (dim_ > f->dim_) return false;
00098   if (basisMemberIndex_ < f->basisMemberIndex_) return true;
00099   if (basisMemberIndex_ > f->basisMemberIndex_) return false;
00100   return componentIndex_ < f->componentIndex_;
00101 }
00102 
00103 
00104 XMLObject CellVectorExpr::toXML() const 
00105 {
00106   XMLObject rtn("CellVectorExpr");
00107   rtn.addAttribute("name", name_);
00108   return rtn;
00109 }
00110 
00111 
00112 
00113 Set<MultipleDeriv> 
00114 CellVectorExpr::internalFindW(int order, const EvalContext& context) const
00115 {
00116   Set<MultipleDeriv> rtn;
00117   
00118   if (order==0) rtn.put(MultipleDeriv());
00119   
00120   return rtn;
00121 }
00122 
00123 
00124 
00125 
00126 std::ostream& CellVectorExpr::toText(std::ostream& os, bool paren) const
00127 {
00128   os << name();
00129   return os;
00130 }
00131 
00132 
00133 
00134