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

Site Contact