00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "SundanceFuncWithBasis.hpp"
00032 #include "SundanceOut.hpp"
00033 #include "PlayaTabs.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 TEUCHOS_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 TEUCHOS_TEST_FOR_EXCEPTION(fe==0, std::runtime_error, "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 TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "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 }