SundanceUnknownParameterElement.cpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                             Sundance
00005 //                 Copyright 2011 Sandia Corporation
00006 // 
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Kevin Long (kevin.long@ttu.edu)
00038 // 
00039 
00040 /* @HEADER@ */
00041 
00042 #include "SundanceUnknownParameterElement.hpp"
00043 
00044 
00045 #include "SundanceDerivSet.hpp"
00046 #include "PlayaTabs.hpp"
00047 
00048 
00049 using namespace Sundance;
00050 using namespace Teuchos;
00051 
00052 UnknownParameterElement
00053 ::UnknownParameterElement(const std::string& name,
00054   const std::string& suffix,
00055   const FunctionIdentifier& fid)
00056   : UnknownFuncElement(rcp(new UnknownFuncDataStub()), name, 
00057   suffix, fid),
00058   SpatiallyConstantExpr()
00059 {}
00060 
00061 
00062 
00063 Set<MultipleDeriv> 
00064 UnknownParameterElement::internalFindW(int order, const EvalContext& context) const
00065 {
00066   Tabs tab;
00067   SUNDANCE_MSG2(context.setupVerbosity(), 
00068     tab << "in UPE::internalFindW, order=" << order);
00069   Set<MultipleDeriv> rtn;
00070 
00071   if (order==0) 
00072   {
00073     if (!evalPtIsZero()) rtn.put(MultipleDeriv());
00074   }
00075   else if (order==1)
00076   {
00077     MultipleDeriv md = makeMultiDeriv(funcDeriv(this));
00078     rtn.put(md);
00079   }
00080 
00081   return rtn;
00082 }
00083 
00084 
00085 
00086 Set<MultipleDeriv> 
00087 UnknownParameterElement::internalFindV(int order, const EvalContext& context) const
00088 {
00089   Tabs tab;
00090   SUNDANCE_MSG2(context.setupVerbosity(), 
00091     tab << "UPE::internalFindV is a no-op");
00092   Set<MultipleDeriv> rtn;
00093 
00094   return rtn;
00095 }
00096 
00097 
00098 Set<MultipleDeriv> 
00099 UnknownParameterElement::internalFindC(int order, const EvalContext& context) const
00100 {
00101   Tabs tab;
00102   SUNDANCE_MSG2(context.setupVerbosity(), 
00103     tab << "in UPE::internalFindC, order=" << order);
00104   Set<MultipleDeriv> rtn;
00105 
00106   if (order==0)
00107   {
00108     MultipleDeriv md;
00109     if (!evalPtIsZero()) rtn.put(md);
00110   }
00111 
00112   if (order==1)
00113   {
00114     MultipleDeriv md = makeMultiDeriv(funcDeriv(this));
00115     rtn.put(md);
00116   }
00117   return rtn.intersection(UnknownFuncElement::findR(order, context));
00118 }
00119 
00120 
00121 
00122 Evaluator* UnknownParameterElement
00123 ::createEvaluator(const EvaluatableExpr* expr,
00124   const EvalContext& context) const 
00125 {
00126   return SymbolicFuncElement::createEvaluator(expr, context);
00127 }
00128 
00129 
00130 const Parameter* UnknownParameterElement::parameterValue() const 
00131 {
00132   const Parameter* p = dynamic_cast<const Parameter*>(evalPt());
00133   TEUCHOS_TEST_FOR_EXCEPTION(p==0, std::logic_error, 
00134     "UnknownParameter evalPt() is not a Parameter");
00135   return p;
00136 }
00137 
00138 Parameter* UnknownParameterElement::parameterValue()  
00139 {
00140   Parameter* p = dynamic_cast<Parameter*>(evalPt());
00141   TEUCHOS_TEST_FOR_EXCEPTION(p==0, std::logic_error, 
00142     "UnknownParameter evalPt() is not a Parameter");
00143   return p;
00144 }
00145 
00146 
00147 bool UnknownParameterElement::lessThan(const ScalarExpr* other) const
00148 {
00149   const UnknownParameterElement* p 
00150     = dynamic_cast<const UnknownParameterElement*>(other);
00151   TEUCHOS_TEST_FOR_EXCEPT(p==0);
00152 
00153   if (name() < p->name()) return true;
00154 
00155   TEUCHOS_TEST_FOR_EXCEPTION(name()==p->name() && this == p, std::runtime_error,
00156     "detected two different parameters with the same name");
00157   return false;
00158 }
00159 
00160 
00161 
00162 
00163 XMLObject UnknownParameterElement::toXML() const 
00164 {
00165   XMLObject rtn("UnknownParameterElement");
00166   rtn.addAttribute("name", name());
00167   return rtn;
00168 }
00169 

Site Contact