SundanceStringEvalMediator.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 
00032 #include "SundanceStringEvalMediator.hpp"
00033 #include "SundanceCoordExpr.hpp"
00034 #include "SundanceCellDiameterExpr.hpp"
00035 #include "SundanceCellVectorExpr.hpp"
00036 #include "SundanceDiscreteFuncElement.hpp"
00037 #include "SundanceOut.hpp"
00038 #include "PlayaTabs.hpp"
00039 #include "PlayaExceptions.hpp"
00040 
00041 using namespace Sundance;
00042 using namespace Sundance;
00043 using namespace Sundance;
00044 using namespace Sundance;
00045 
00046 using namespace Teuchos;
00047 using namespace std;
00048 
00049 
00050 
00051 StringEvalMediator::StringEvalMediator()
00052   : AbstractEvalMediator() 
00053 {}
00054 
00055 void StringEvalMediator::evalCoordExpr(const CoordExpr* expr,
00056                                        RCP<EvalVector>& vec) const
00057 {
00058   SUNDANCE_MSG1(verb(), 
00059     "evaluating coord expr " << expr->toString());
00060   
00061   vec->resize(1);
00062   vec->start()[0]=0.0;
00063   vec->setString(expr->name());
00064 }
00065 
00066 void StringEvalMediator::evalCellDiameterExpr(const CellDiameterExpr* expr,
00067                                               RCP<EvalVector>& vec) const
00068 {
00069   SUNDANCE_MSG1(verb(), 
00070     "evaluating cell diameter expr " << expr->toXML().toString());
00071   
00072   vec->resize(1);
00073   vec->start()[0]=0.0;
00074   vec->setString(expr->name());
00075 }
00076 
00077 void StringEvalMediator::evalCellVectorExpr(const CellVectorExpr* expr,
00078                                               RCP<EvalVector>& vec) const
00079 {
00080   SUNDANCE_MSG1(verb(), "evaluating cell vector expr " << expr->toXML().toString());
00081   
00082   vec->resize(1);
00083   vec->start()[0]=0.0;
00084   vec->setString(expr->name());
00085 }
00086 
00087 void StringEvalMediator
00088 ::evalDiscreteFuncElement(const DiscreteFuncElement* expr,
00089                           const Array<MultiIndex>& mi,
00090                           Array<RCP<EvalVector> >& vec) const 
00091 {
00092   static Array<string> coordNames;
00093 
00094   if (coordNames.size() != 3)
00095     {
00096       coordNames.resize(3);
00097       coordNames[0] = "x";
00098       coordNames[1] = "y";
00099       coordNames[2] = "z";
00100     }
00101 
00102   std::string funcName = expr->name();
00103   
00104   for (int i=0; i<mi.size(); i++)
00105     {
00106       vec[i]->resize(1);
00107       vec[i]->start()[0]=0.0;
00108       if (mi[i].order()==0)
00109         {
00110           vec[i]->setString(funcName);
00111         }
00112       else
00113         {
00114           int dir = mi[i].firstOrderDirection();
00115           std::string deriv = "D[" + funcName + ", " + coordNames[dir] + "]";
00116           vec[i]->setString(deriv);
00117         }
00118     }
00119 }

Site Contact