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(0);
00062   int verb = context.setupVerbosity();
00063   SUNDANCE_MSG2(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(0);
00084   int verb = context.setupVerbosity();
00085   SUNDANCE_MSG2(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   SUNDANCE_MSG3(verb, tab << "W[" << order << "]=" << rtn);
00107   SUNDANCE_MSG3(verb, tab << "done with DFE::internalFindW(" << order << ") for "
00108     << toString());
00109   return rtn;
00110 }
00111 
00112 Set<MultipleDeriv> 
00113 DiscreteFuncElement::internalFindV(int order, const EvalContext& context) const
00114 {
00115   Tabs tab(0);
00116   int verb = context.setupVerbosity();
00117   SUNDANCE_MSG2(verb, tab << "DFE::internalFindV(order=" << order << ") for "
00118     << toString());
00119   Set<MultipleDeriv> rtn;
00120   Set<MultiIndex> miSet = activeSpatialDerivs(context);
00121 
00122   if (order==0) 
00123   {
00124     if (miSet.contains(MultiIndex())) rtn.put(MultipleDeriv());
00125   }
00126   if (order==1)
00127   {
00128     for (Set<MultiIndex>::const_iterator i=miSet.begin(); i!=miSet.end(); i++)
00129     {
00130       const MultiIndex& mi = *i;
00131       int diffOrder = mi.order();
00132       if (diffOrder==1) 
00133         rtn.put(MultipleDeriv(coordDeriv(mi)));
00134     }
00135   }
00136   
00137   rtn = rtn.intersection(findR(order, context));
00138 
00139   SUNDANCE_MSG2(verb, tab << "V[" << order << "]=" << rtn);
00140   SUNDANCE_MSG2(verb, tab << "done with DFE::internalFindV(" << order << ") for "
00141     << toString());
00142   return rtn;
00143 }
00144 
00145 Set<MultipleDeriv> 
00146 DiscreteFuncElement::internalFindC(int order, const EvalContext& context) const
00147 {
00148   Tabs tab(0);
00149   SUNDANCE_MSG2(context.setupVerbosity(), 
00150     tab << "DFE::internalFindC is a no-op");
00151   Set<MultipleDeriv> rtn;
00152   return rtn;
00153 }
00154 
00155 void DiscreteFuncElement::addMultiIndex(const MultiIndex& newMi) const
00156 {
00157   miSet_.put(newMi);
00158 }
00159 
00160 XMLObject DiscreteFuncElement::toXML() const 
00161 {
00162   XMLObject rtn("DiscreteFuncElement");
00163   rtn.addAttribute("name", name());
00164   return rtn;
00165 }
00166 
00167 
00168 bool DiscreteFuncElement::lessThan(const ScalarExpr* other) const
00169 {
00170   const DiscreteFuncElement* p 
00171     = dynamic_cast<const DiscreteFuncElement*>(other);
00172   TEUCHOS_TEST_FOR_EXCEPT(p==0);
00173 
00174   return fid() < p->fid();
00175 }

Site Contact