SundanceDiscreteFuncElement.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 "SundanceDiscreteFuncElement.hpp"
00032 #include "SundanceDiscreteFunctionStub.hpp"
00033 
00034 #include "SundanceDeriv.hpp"
00035 
00036 using namespace Sundance;
00037 using namespace Sundance;
00038 
00039 using namespace Sundance;
00040 using namespace Sundance;
00041 using namespace Teuchos;
00042 
00043 
00044 DiscreteFuncElement
00045 ::DiscreteFuncElement(const RCP<DiscreteFuncDataStub>& data,
00046   const std::string& name,
00047   const std::string& suffix,
00048   const FunctionIdentifier& fid, int myIndex)
00049   : EvaluatableExpr(), 
00050     FuncElementBase(name, suffix, fid),
00051     commonData_(data),
00052     miSet_(),
00053     myIndex_(myIndex)
00054 {}
00055 
00056 
00057 RCP<Array<Set<MultipleDeriv> > > DiscreteFuncElement
00058 ::internalDetermineR(const EvalContext& context,
00059                      const Array<Set<MultipleDeriv> >& RInput) const
00060 {
00061   Tabs tab;
00062   int verb = context.setupVerbosity();
00063   SUNDANCE_MSG3(verb, tab << "DFE::internalDetermineR() for "
00064                      << toString());
00065   Array<Set<MultipleDeriv> > RIn = RInput;
00066   Set<MultiIndex> miSet = activeSpatialDerivs(context);
00067 
00068   for (Set<MultiIndex>::const_iterator i=miSet.begin(); i!=miSet.end(); i++)
00069     {
00070       const MultiIndex& mi = *i;
00071       int order = mi.order();
00072       if (order==0) RIn[0].put(MultipleDeriv());
00073       if (order==1) RIn[1].put(MultipleDeriv(coordDeriv(mi)));
00074     }
00075 
00076   return EvaluatableExpr::internalDetermineR(context, RIn);
00077 }
00078 
00079 
00080 Set<MultipleDeriv> 
00081 DiscreteFuncElement::internalFindW(int order, const EvalContext& context) const
00082 {
00083   Tabs tab;
00084   int verb = context.setupVerbosity();
00085   SUNDANCE_MSG3(verb, tab << "DFE::internalFindW(order=" << order << ") for "
00086                      << toString());
00087   Set<MultipleDeriv> rtn;
00088 
00089   Set<MultiIndex> miSet = activeSpatialDerivs(context);
00090 
00091   if (order==0) 
00092     {
00093       if (miSet.contains(MultiIndex())) rtn.put(MultipleDeriv());
00094     }
00095   if (order==1)
00096     {
00097       for (Set<MultiIndex>::const_iterator i=miSet.begin(); i!=miSet.end(); i++)
00098         {
00099           const MultiIndex& mi = *i;
00100           int diffOrder = mi.order();
00101           if (diffOrder==1) 
00102             rtn.put(MultipleDeriv(coordDeriv(mi)));
00103         }
00104     }
00105 
00106   return rtn;
00107 }
00108 
00109 Set<MultipleDeriv> 
00110 DiscreteFuncElement::internalFindV(int order, const EvalContext& context) const
00111 {
00112   Tabs tab;
00113   int verb = context.setupVerbosity();
00114   SUNDANCE_MSG3(verb, tab << "DFE::internalFindV(order=" << order << ") for "
00115                      << toString());
00116   Set<MultipleDeriv> rtn;
00117   Set<MultiIndex> miSet = activeSpatialDerivs(context);
00118 
00119   if (order==0) 
00120     {
00121       if (miSet.contains(MultiIndex())) rtn.put(MultipleDeriv());
00122     }
00123   if (order==1)
00124     {
00125       for (Set<MultiIndex>::const_iterator i=miSet.begin(); i!=miSet.end(); i++)
00126         {
00127           const MultiIndex& mi = *i;
00128           int diffOrder = mi.order();
00129           if (diffOrder==1) 
00130             rtn.put(MultipleDeriv(coordDeriv(mi)));
00131         }
00132     }
00133   
00134   rtn = rtn.intersection(findR(order, context));
00135   return rtn;
00136 }
00137 
00138 Set<MultipleDeriv> 
00139 DiscreteFuncElement::internalFindC(int order, const EvalContext& context) const
00140 {
00141   Tabs tab;
00142   SUNDANCE_MSG5(context.setupVerbosity(), 
00143     tab << "DFE::internalFindC is a no-op");
00144   Set<MultipleDeriv> rtn;
00145   return rtn;
00146 }
00147 
00148 void DiscreteFuncElement::addMultiIndex(const MultiIndex& newMi) const
00149 {
00150   miSet_.put(newMi);
00151 }
00152 
00153 XMLObject DiscreteFuncElement::toXML() const 
00154 {
00155   XMLObject rtn("DiscreteFuncElement");
00156   rtn.addAttribute("name", name());
00157   return rtn;
00158 }
00159 
00160 
00161 bool DiscreteFuncElement::lessThan(const ScalarExpr* other) const
00162 {
00163   const DiscreteFuncElement* p 
00164     = dynamic_cast<const DiscreteFuncElement*>(other);
00165   TEST_FOR_EXCEPT(p==0);
00166 
00167   return fid() < p->fid();
00168 }

Site Contact