SundanceUnknownParameterElement.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 "SundanceUnknownParameterElement.hpp"
00032 
00033 
00034 #include "SundanceDerivSet.hpp"
00035 #include "PlayaTabs.hpp"
00036 
00037 
00038 using namespace Sundance;
00039 using namespace Teuchos;
00040 
00041 UnknownParameterElement
00042 ::UnknownParameterElement(const std::string& name,
00043   const std::string& suffix,
00044   const FunctionIdentifier& fid)
00045   : UnknownFuncElement(rcp(new UnknownFuncDataStub()), name, 
00046   suffix, fid),
00047   SpatiallyConstantExpr()
00048 {}
00049 
00050 
00051 
00052 Set<MultipleDeriv> 
00053 UnknownParameterElement::internalFindW(int order, const EvalContext& context) const
00054 {
00055   Tabs tab;
00056   SUNDANCE_MSG2(context.setupVerbosity(), 
00057     tab << "in UPE::internalFindW, order=" << order);
00058   Set<MultipleDeriv> rtn;
00059 
00060   if (order==0) 
00061   {
00062     if (!evalPtIsZero()) rtn.put(MultipleDeriv());
00063   }
00064   else if (order==1)
00065   {
00066     MultipleDeriv md = makeMultiDeriv(funcDeriv(this));
00067     rtn.put(md);
00068   }
00069 
00070   return rtn;
00071 }
00072 
00073 
00074 
00075 Set<MultipleDeriv> 
00076 UnknownParameterElement::internalFindV(int order, const EvalContext& context) const
00077 {
00078   Tabs tab;
00079   SUNDANCE_MSG2(context.setupVerbosity(), 
00080     tab << "UPE::internalFindV is a no-op");
00081   Set<MultipleDeriv> rtn;
00082 
00083   return rtn;
00084 }
00085 
00086 
00087 Set<MultipleDeriv> 
00088 UnknownParameterElement::internalFindC(int order, const EvalContext& context) const
00089 {
00090   Tabs tab;
00091   SUNDANCE_MSG2(context.setupVerbosity(), 
00092     tab << "in UPE::internalFindC, order=" << order);
00093   Set<MultipleDeriv> rtn;
00094 
00095   if (order==0)
00096   {
00097     MultipleDeriv md;
00098     if (!evalPtIsZero()) rtn.put(md);
00099   }
00100 
00101   if (order==1)
00102   {
00103     MultipleDeriv md = makeMultiDeriv(funcDeriv(this));
00104     rtn.put(md);
00105   }
00106   return rtn.intersection(UnknownFuncElement::findR(order, context));
00107 }
00108 
00109 
00110 
00111 Evaluator* UnknownParameterElement
00112 ::createEvaluator(const EvaluatableExpr* expr,
00113   const EvalContext& context) const 
00114 {
00115   return SymbolicFuncElement::createEvaluator(expr, context);
00116 }
00117 
00118 
00119 const Parameter* UnknownParameterElement::parameterValue() const 
00120 {
00121   const Parameter* p = dynamic_cast<const Parameter*>(evalPt());
00122   TEUCHOS_TEST_FOR_EXCEPTION(p==0, std::logic_error, 
00123     "UnknownParameter evalPt() is not a Parameter");
00124   return p;
00125 }
00126 
00127 Parameter* UnknownParameterElement::parameterValue()  
00128 {
00129   Parameter* p = dynamic_cast<Parameter*>(evalPt());
00130   TEUCHOS_TEST_FOR_EXCEPTION(p==0, std::logic_error, 
00131     "UnknownParameter evalPt() is not a Parameter");
00132   return p;
00133 }
00134 
00135 
00136 bool UnknownParameterElement::lessThan(const ScalarExpr* other) const
00137 {
00138   const UnknownParameterElement* p 
00139     = dynamic_cast<const UnknownParameterElement*>(other);
00140   TEUCHOS_TEST_FOR_EXCEPT(p==0);
00141 
00142   if (name() < p->name()) return true;
00143 
00144   TEUCHOS_TEST_FOR_EXCEPTION(name()==p->name() && this == p, std::runtime_error,
00145     "detected two different parameters with the same name");
00146   return false;
00147 }
00148 
00149 
00150 
00151 
00152 XMLObject UnknownParameterElement::toXML() const 
00153 {
00154   XMLObject rtn("UnknownParameterElement");
00155   rtn.addAttribute("name", name());
00156   return rtn;
00157 }
00158 

Site Contact