SundanceCellVectorExpr.cpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //                                                                                 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA                                                                                
00025 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
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 

Site Contact