SundanceCurveNormExpr.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 "SundanceCurveNormExpr.hpp"
00032 #include "SundanceEvalManager.hpp"
00033 #include "SundanceSparsitySuperset.hpp"
00034 #include "SundanceOut.hpp"
00035 #include "SundanceObjectWithVerbosity.hpp"
00036 
00037 using namespace Sundance;
00038 using namespace Teuchos;
00039 
00040 
00041 CurveNormExpr::CurveNormExpr(int dir, const std::string& name)
00042   : EvaluatableExpr(),
00043     dir_(dir),
00044     name_(coordName(dir, name))
00045 {}
00046 
00047 bool CurveNormExpr::lessThan(const ScalarExpr* other) const
00048 {
00049   const CurveNormExpr* c = dynamic_cast<const CurveNormExpr*>(other);
00050   TEUCHOS_TEST_FOR_EXCEPTION(c==0, std::logic_error, "cast should never fail at this point");
00051   return dir() < c->dir();
00052 }
00053 
00054 XMLObject CurveNormExpr::toXML() const
00055 {
00056   XMLObject rtn("CurveNormExpr");
00057   rtn.addAttribute("dir", Teuchos::toString(dir_));
00058   rtn.addAttribute("name", name());
00059   return rtn;
00060 }
00061 
00062 string CurveNormExpr::coordName(int dir, const std::string& name)
00063 {
00064   if (name.length() > 0) return name;
00065   switch(dir)
00066     {
00067     case 0:
00068       return "nx";
00069     case 1:
00070       return "ny";
00071     case 2:
00072       return "nz";
00073     default:
00074       TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error,
00075                          "CurveNormExpr::coordName direction out of range [0,2]");
00076       return "error";
00077     }
00078 }
00079 
00080 
00081 Set<MultipleDeriv> 
00082 CurveNormExpr::internalFindW(int order, const EvalContext& context) const
00083 {
00084   Tabs tab0;
00085   SUNDANCE_VERB_HIGH(tab0 << "CurveNormExpr::internalFindW() for " << toString());
00086   Set<MultipleDeriv> rtn;
00087 
00088   if (order==0) rtn.put(MultipleDeriv());
00089 
00090   if (order==1) 
00091     {
00092     /* todo: in case of first derivative currently we return nothing,
00093        * considering the normal as constant, which mathematically is not
00094        * correct.
00095        * However calculating the derivative of the normal vector in one
00096        * direction is not trivial, remains to be done later */
00097     }
00098 
00099   SUNDANCE_VERB_HIGH(tab0 << "W[" << order << "]=" << rtn);
00100   return rtn;
00101 }
00102 
00103 /*
00104 Set<MultipleDeriv> 
00105 CurveNormEvaluator::internalFindV(int order, const EvalContext& context) const
00106 {
00107   Tabs tab0;
00108   SUNDANCE_VERB_HIGH(tab0 << "CurveNormEvaluator::internalFindV() for " << toString());
00109   Set<MultipleDeriv> rtn;
00110 
00111   if (order==0) rtn.put(MultipleDeriv());
00112 
00113   SUNDANCE_VERB_HIGH(tab0 << "V[" << order << "]=" << rtn);
00114   return rtn;
00115 }
00116 */
00117 
00118 /*
00119 Set<MultipleDeriv> 
00120 CurveNormEvaluator::internalFindC(int order, const EvalContext& context) const
00121 {
00122   Tabs tab0;
00123   SUNDANCE_VERB_HIGH(tab0 << "CurveNormEvaluator::internalFindC() for " << toString());
00124   Set<MultipleDeriv> rtn;
00125 
00126   if (order==1) 
00127     {
00128       Deriv x = coordDeriv(dir_);
00129       MultipleDeriv md;
00130       md.put(x);
00131       rtn.put(md);
00132     }
00133   SUNDANCE_VERB_HIGH(tab0 << "C[" << order << "]=" << rtn);
00134   return rtn;
00135 }*/
00136 
00137 
00138 
00139 
00140 
00141 

Site Contact