SundanceProductExpr.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 
00032 #include "SundanceProductExpr.hpp"
00033 #include "SundanceProductEvaluator.hpp"
00034 #include "SundanceDeriv.hpp"
00035 
00036 #include "SundanceOut.hpp"
00037 #include "SundanceTabs.hpp"
00038 
00039 using namespace Sundance;
00040 using namespace Sundance;
00041 
00042 using namespace Sundance;
00043 using namespace Teuchos;
00044 
00045 
00046 
00047 ProductExpr::ProductExpr(const RCP<ScalarExpr>& left,
00048   const RCP<ScalarExpr>& right)
00049   : BinaryExpr(left, right, 1)
00050 {}
00051 
00052 
00053 Evaluator* ProductExpr::createEvaluator(const EvaluatableExpr* expr,
00054   const EvalContext& context) const
00055 {
00056   return new ProductEvaluator(dynamic_cast<const ProductExpr*>(expr), context);
00057 }
00058 
00059 bool ProductExpr::isHungryDiffOp() const
00060 {
00061   return rightScalar()->isHungryDiffOp();
00062 }
00063 
00064 
00065 
00066 const std::string& ProductExpr::xmlTag() const 
00067 {
00068   static std::string timesStr = "Times";
00069   static std::string divideStr = "Divide";
00070   if (sign() < 0) return divideStr;
00071   return timesStr;
00072 }
00073 
00074 const std::string& ProductExpr::opChar() const 
00075 {
00076   static std::string timesStr = "*";
00077   static std::string divideStr = "/";
00078   if (sign() < 0) return divideStr;
00079   return timesStr;
00080 }
00081 
00082 
00083 
00084 Set<MultiSet<int> > ProductExpr::internalFindQ_W(int order, const EvalContext& context) const
00085 {
00086   Tabs tab0;
00087   int verb = context.setupVerbosity();
00088   SUNDANCE_MSG3(verb, tab0 << "ProdExpr::internalFindQ_W(" << order << ")");
00089 
00090   Set<MultiSet<int> > rtn;
00091   if (order > 2) return rtn;
00092 
00093   if (order==2)
00094   {
00095     rtn.put(makeMultiSet<int>(0,1));
00096     return rtn;
00097   }
00098 
00099 
00100   const Set<MultipleDeriv>& wLeft 
00101     = leftEvaluatable()->findW(0, context);
00102   SUNDANCE_MSG3(verb, tab0 << "wLeft=" << wLeft);
00103 
00104   const Set<MultipleDeriv>& wRight
00105     = rightEvaluatable()->findW(0, context);
00106   SUNDANCE_MSG3(verb, tab0 << "wRight=" << wRight);
00107   
00108   if (order==0)
00109   {
00110     if (wLeft.size() > 0)
00111     {
00112       rtn.put(makeMultiSet<int>(0));
00113     }
00114     if (wRight.size() > 0)
00115     {
00116       rtn.put(makeMultiSet<int>(1));
00117     }
00118   }
00119   
00120   if (order==1)
00121   {
00122     if (wLeft.size() > 0) rtn.put(makeMultiSet<int>(1));
00123     if (wRight.size() > 0) rtn.put(makeMultiSet<int>(0));
00124   }
00125   
00126   return rtn;
00127 }
00128 
00129 
00130 Set<MultiSet<int> > ProductExpr::internalFindQ_V(int order, const EvalContext& context) const
00131 {
00132   Tabs tab0;
00133   int verb = context.setupVerbosity();
00134   SUNDANCE_MSG3(verb, tab0 << "ProdExpr::internalFindQ_V(" << order << ")");
00135 
00136   Set<MultiSet<int> > rtn;
00137   if (order > 1) return rtn;
00138 
00139   const Set<MultipleDeriv>& vLeft 
00140     = leftEvaluatable()->findV(0, context);
00141   const Set<MultipleDeriv>& vRight
00142     = rightEvaluatable()->findV(0, context);
00143 
00144   if (order==0)
00145   {
00146     if (vLeft.size() > 0)
00147     {
00148       rtn.put(makeMultiSet<int>(0));
00149     }
00150     if (vRight.size() > 0)
00151     {
00152       rtn.put(makeMultiSet<int>(1));
00153     }
00154   }
00155 
00156   if (order==1)
00157   {
00158     if (vLeft.size() > 0) rtn.put(makeMultiSet<int>(1));
00159     if (vRight.size() > 0) rtn.put(makeMultiSet<int>(0));
00160   }
00161 
00162   
00163   return rtn;
00164 }
00165 

Site Contact