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 "SundanceTestFunctionStub.hpp"
00032 #include "SundanceTestFuncElement.hpp"
00033 #include "SundanceSpectralBasis.hpp"
00034 #include "SundanceSpectralExpr.hpp"
00035 
00036 
00037 using namespace Sundance;
00038 using namespace Sundance;
00039 
00040 using namespace Sundance;
00041 using namespace Teuchos;
00042 
00043 
00044 
00045 TestFunctionStub::TestFunctionStub(const std::string& name, 
00046   int tensorOrder,
00047   int dim, 
00048   const RCP<const TestFuncDataStub>& data)
00049   : SymbolicFunc(makeFuncID(tensorOrder), 
00050     rcp_dynamic_cast<const CommonFuncDataStub>(data)), data_(data)
00051 {
00052   FunctionIdentifier myFid = fid();
00053   if (tensorOrder==0)
00054   {
00055     append(new TestFuncElement(data, name, "", myFid));
00056   }
00057   else if (tensorOrder==1)
00058   {
00059     for (int d=0; d<dim; d++)
00060     {
00061       std::string suffix="[" + Teuchos::toString(d) + "]";
00062       FunctionIdentifier fid = myFid.createComponent(d);
00063       append(new TestFuncElement(data, name, suffix, fid));
00064     }
00065   }
00066   else 
00067   {
00068     TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "tensor order = " << tensorOrder
00069       << " not supported");
00070   }
00071 }
00072 
00073 TestFunctionStub::TestFunctionStub(const std::string& name, 
00074   const SpectralBasis& sbasis, int tensorOrder, int dim,
00075   const RCP<const TestFuncDataStub>& data)
00076   :  SymbolicFunc(makeFuncID(tensorOrder), 
00077     rcp_dynamic_cast<const CommonFuncDataStub>(data)), data_(data)
00078 {
00079   Array<FunctionIdentifier> cFid(sbasis.nterms());
00080 
00081   for (int n=0; n<sbasis.nterms(); n++)
00082   {
00083     cFid[n] = makeFuncID(tensorOrder);
00084   }
00085   
00086   if (tensorOrder==0 || dim==1)
00087   {
00088     Array<Expr> coeffs(sbasis.nterms());
00089     for (int n=0; n<sbasis.nterms(); n++)
00090     {
00091       std::string suffix="";
00092       if (sbasis.nterms()>1) suffix = "[" + Teuchos::toString(n) + "]";
00093       coeffs[n] = new TestFuncElement(data, name, suffix, cFid[n]);
00094     }
00095     append(new SpectralExpr(sbasis, coeffs));
00096   }
00097   else if (tensorOrder==1)
00098   {
00099     for (int d=0; d<dim; d++)
00100     {
00101       std::string suffix="[" + Teuchos::toString(d) + "]";
00102       Array<Expr> coeffs(sbasis.nterms());
00103       for (int n=0; n<sbasis.nterms(); n++)
00104       {
00105         FunctionIdentifier fid = cFid[n].createComponent(d);
00106         if (sbasis.nterms()>1) suffix += "[" + Teuchos::toString(n) + "]";
00107         coeffs[n]= new TestFuncElement(data, name, suffix, fid);
00108       }
00109       append(new SpectralExpr(sbasis, coeffs));
00110     }
00111   }
00112   else 
00113   {
00114     TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "tensor order = " << tensorOrder
00115       << " not supported");
00116   }
00117 }
00118 
00119 
00120 
00121