SundanceParameter.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 "SundanceParameter.hpp"
00032 #include "SundanceSymbolicFunc.hpp"
00033 
00034 using namespace Sundance;
00035 using namespace Sundance;
00036 
00037 using namespace Sundance;
00038 using namespace Teuchos;
00039 
00040 Parameter::Parameter(const double& value, const std::string& name)
00041   : DiscreteFuncElement(rcp(new ParameterData(value)), 
00042     name, "", makeFuncID(0), 0),
00043     SpatiallyConstantExpr()
00044 {;}
00045 
00046 void Parameter::setValue(const double& value)
00047 {
00048   data()->setValue(value);
00049 }
00050 
00051 const double& Parameter::value() const {return data()->value();}
00052 
00053 
00054 RCP<Array<Set<MultipleDeriv> > > Parameter
00055 ::internalDetermineR(const EvalContext& context,
00056                      const Array<Set<MultipleDeriv> >& RInput) const
00057 {
00058   Tabs tab;
00059   SUNDANCE_VERB_HIGH(tab << "Parameter::internalDetermineR() for "
00060                      << toString());
00061   return EvaluatableExpr::internalDetermineR(context, RInput);
00062 }
00063 
00064 Set<MultipleDeriv> 
00065 Parameter::internalFindW(int order, const EvalContext& context) const
00066 {
00067   Set<MultipleDeriv> rtn;
00068 
00069   if (order==0) rtn.put(MultipleDeriv());
00070 
00071   return rtn;
00072 }
00073 
00074 Set<MultipleDeriv> 
00075 Parameter::internalFindV(int order, const EvalContext& context) const
00076 {
00077   Set<MultipleDeriv> rtn;
00078 
00079   return rtn;
00080 }
00081 
00082 
00083 Set<MultipleDeriv> 
00084 Parameter::internalFindC(int order, const EvalContext& context) const
00085 {
00086   Tabs tab;
00087   int verb = context.setupVerbosity();
00088   SUNDANCE_MSG3(verb, tab 
00089     << "Parameter::internalFindC(order=" << order << ") for "
00090     << toString());
00091   Set<MultipleDeriv> rtn;
00092 
00093   if (order==0)
00094     {
00095       rtn.put(MultipleDeriv());
00096     }
00097 
00098   rtn = rtn.intersection(findR(order, context));
00099 
00100   SUNDANCE_MSG3(verb,  tab << "Parameter: C[" << order << "] = " << rtn );
00101   return rtn;
00102 }
00103 
00104 
00105 Evaluator* Parameter::createEvaluator(const EvaluatableExpr* expr,
00106                                       const EvalContext& context) const 
00107 {
00108   return new ConstantEvaluator(this, context);
00109 }
00110 
00111 
00112 XMLObject Parameter::toXML() const 
00113 {
00114   XMLObject rtn("Parameter");
00115   rtn.addAttribute("name", name());
00116   rtn.addAttribute("value", Teuchos::toString(value()));
00117   return rtn;
00118 }
00119 
00120 
00121 const ParameterData* Parameter::data() const
00122 {
00123   const ParameterData* pd = dynamic_cast<const ParameterData*>(commonData().get());
00124 
00125   TEUCHOS_TEST_FOR_EXCEPTION(pd==0, std::logic_error, "cast failed");
00126 
00127   return pd;
00128 }
00129 
00130 
00131 
00132 ParameterData* Parameter::data()
00133 {
00134   ParameterData* pd = dynamic_cast<ParameterData*>(commonData());
00135 
00136   TEUCHOS_TEST_FOR_EXCEPTION(pd==0, std::logic_error, "cast failed");
00137 
00138   return pd;
00139 }

Site Contact