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 "SundanceUnknownFunctionStub.hpp"
00032 #include "SundanceUnknownFuncElement.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 UnknownFunctionStub::UnknownFunctionStub(const std::string& name, 
00046   int tensorOrder,
00047   int dim, 
00048   const RCP<const UnknownFuncDataStub>& 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     Expr u = new UnknownFuncElement(data, name, "", myFid);
00056     append(u);
00057   }
00058   else if (tensorOrder==1)
00059   {
00060     for (int d=0; d<dim; d++)
00061     {
00062       std::string suffix="[" + Teuchos::toString(d) + "]";
00063       FunctionIdentifier fid = myFid.createComponent(d);
00064       append(new UnknownFuncElement(data, name, suffix, fid));
00065     }
00066   }
00067   else 
00068   {
00069     TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "tensor order = " << tensorOrder
00070       << " not supported");
00071   }
00072 }
00073 
00074 
00075 
00076 UnknownFunctionStub::UnknownFunctionStub(const std::string& name, 
00077   const SpectralBasis& sbasis, int tensorOrder, int dim,
00078   const RCP<const UnknownFuncDataStub>& data)
00079   : SymbolicFunc(FunctionIdentifier(),
00080     rcp_dynamic_cast<const CommonFuncDataStub>(data)), data_(data)
00081 {
00082   Array<FunctionIdentifier> cFid(sbasis.nterms());
00083 
00084   for (int n=0; n<sbasis.nterms(); n++)
00085   {
00086     cFid[n] = makeFuncID(tensorOrder);
00087   }
00088   
00089   if (tensorOrder==0 || dim==1)
00090   {
00091     Array<Expr> coeffs(sbasis.nterms());
00092     for (int n=0; n<sbasis.nterms(); n++)
00093     {
00094       std::string suffix="";
00095       if (sbasis.nterms()>1) suffix = "[" + Teuchos::toString(n) + "]";
00096       coeffs[n] = new UnknownFuncElement(data, name, suffix, cFid[n]);
00097     }
00098     append(new SpectralExpr(sbasis, coeffs));
00099   }
00100   else if (tensorOrder==1)
00101   {
00102     for (int d=0; d<dim; d++)
00103     {
00104       std::string suffix="[" + Teuchos::toString(d) + "]";
00105       Array<Expr> coeffs(sbasis.nterms());
00106       for (int n=0; n<sbasis.nterms(); n++)
00107       {
00108         FunctionIdentifier fid = cFid[n].createComponent(d);
00109         if (sbasis.nterms()>1) suffix += "[" + Teuchos::toString(n) + "]";
00110         coeffs[n]= new UnknownFuncElement(data, name, suffix, fid);
00111       }
00112       append(new SpectralExpr(sbasis, coeffs));
00113     }
00114   }
00115   else 
00116   {
00117     TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "tensor order = " << tensorOrder
00118       << " not supported");
00119   }
00120 }
00121 
00122