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 "SundanceFuncWithBasis.hpp" 00032 #include "SundanceOut.hpp" 00033 #include "SundanceTabs.hpp" 00034 #include "SundanceExpr.hpp" 00035 #include "SundanceDiscreteFuncElement.hpp" 00036 #include "SundanceUnknownFuncElement.hpp" 00037 #include "SundanceTestFuncElement.hpp" 00038 00039 00040 namespace Sundance 00041 { 00042 using namespace Teuchos; 00043 00044 std::string describeFunction(const Expr& f) 00045 { 00046 TEST_FOR_EXCEPT(f.ptr().get()==0); 00047 00048 if (f.size() == 1) 00049 { 00050 const FuncElementBase* fe = dynamic_cast<const FuncElementBase*>(f[0].ptr().get()); 00051 TEST_FOR_EXCEPTION(fe==0, RuntimeError, "expected a FuncElementBase, " 00052 "found " << typeid(*fe).name()); 00053 00054 const UnknownFuncElement* u = dynamic_cast<const UnknownFuncElement*>(f[0].ptr().get()); 00055 00056 const TestFuncElement* t = dynamic_cast<const TestFuncElement*>(f[0].ptr().get()); 00057 00058 const DiscreteFuncElement* d = dynamic_cast<const DiscreteFuncElement*>(f[0].ptr().get()); 00059 00060 std::string type; 00061 if (t != 0) 00062 { 00063 type = "TFElem"; 00064 } 00065 else if (u != 0) 00066 { 00067 type = "UFElem"; 00068 } 00069 else if (d != 0) 00070 { 00071 type = "DFElem"; 00072 } 00073 else 00074 { 00075 TEST_FOR_EXCEPTION(true, RuntimeError, "unrecognized function " 00076 << f[0]); 00077 } 00078 00079 std::string rtn = type + "[name=" + fe->name() + ", fid=" + fe->fid().toString() + "]"; 00080 return rtn; 00081 00082 } 00083 else 00084 { 00085 std::string rtn = "{"; 00086 for (int i=0; i<f.size(); i++) 00087 { 00088 if (i != 0) rtn += ", "; 00089 rtn += describeFunction(f[i]); 00090 } 00091 rtn += "}"; 00092 return rtn; 00093 } 00094 } 00095 }