SundanceTestFunctionStub.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 #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 

Site Contact