SundanceCurveNormExpr.cpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                             Sundance
00005 //                 Copyright 2011 Sandia Corporation
00006 // 
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Kevin Long (kevin.long@ttu.edu)
00038 // 
00039 
00040 /* @HEADER@ */
00041 
00042 #include "SundanceCurveNormExpr.hpp"
00043 #include "SundanceEvalManager.hpp"
00044 #include "SundanceSparsitySuperset.hpp"
00045 #include "SundanceOut.hpp"
00046 #include "SundanceObjectWithVerbosity.hpp"
00047 
00048 using namespace Sundance;
00049 using namespace Teuchos;
00050 
00051 
00052 CurveNormExpr::CurveNormExpr(int dir, const std::string& name)
00053   : EvaluatableExpr(),
00054     dir_(dir),
00055     name_(coordName(dir, name))
00056 {}
00057 
00058 bool CurveNormExpr::lessThan(const ScalarExpr* other) const
00059 {
00060   const CurveNormExpr* c = dynamic_cast<const CurveNormExpr*>(other);
00061   TEUCHOS_TEST_FOR_EXCEPTION(c==0, std::logic_error, "cast should never fail at this point");
00062   return dir() < c->dir();
00063 }
00064 
00065 XMLObject CurveNormExpr::toXML() const
00066 {
00067   XMLObject rtn("CurveNormExpr");
00068   rtn.addAttribute("dir", Teuchos::toString(dir_));
00069   rtn.addAttribute("name", name());
00070   return rtn;
00071 }
00072 
00073 string CurveNormExpr::coordName(int dir, const std::string& name)
00074 {
00075   if (name.length() > 0) return name;
00076   switch(dir)
00077     {
00078     case 0:
00079       return "nx";
00080     case 1:
00081       return "ny";
00082     case 2:
00083       return "nz";
00084     default:
00085       TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error,
00086                          "CurveNormExpr::coordName direction out of range [0,2]");
00087       return "error";
00088     }
00089 }
00090 
00091 
00092 Set<MultipleDeriv> 
00093 CurveNormExpr::internalFindW(int order, const EvalContext& context) const
00094 {
00095   Tabs tab0;
00096   SUNDANCE_VERB_HIGH(tab0 << "CurveNormExpr::internalFindW() for " << toString());
00097   Set<MultipleDeriv> rtn;
00098 
00099   if (order==0) rtn.put(MultipleDeriv());
00100 
00101   if (order==1) 
00102     {
00103     /* todo: in case of first derivative currently we return nothing,
00104        * considering the normal as constant, which mathematically is not
00105        * correct.
00106        * However calculating the derivative of the normal vector in one
00107        * direction is not trivial, remains to be done later */
00108     }
00109 
00110   SUNDANCE_VERB_HIGH(tab0 << "W[" << order << "]=" << rtn);
00111   return rtn;
00112 }
00113 
00114 /*
00115 Set<MultipleDeriv> 
00116 CurveNormEvaluator::internalFindV(int order, const EvalContext& context) const
00117 {
00118   Tabs tab0;
00119   SUNDANCE_VERB_HIGH(tab0 << "CurveNormEvaluator::internalFindV() for " << toString());
00120   Set<MultipleDeriv> rtn;
00121 
00122   if (order==0) rtn.put(MultipleDeriv());
00123 
00124   SUNDANCE_VERB_HIGH(tab0 << "V[" << order << "]=" << rtn);
00125   return rtn;
00126 }
00127 */
00128 
00129 /*
00130 Set<MultipleDeriv> 
00131 CurveNormEvaluator::internalFindC(int order, const EvalContext& context) const
00132 {
00133   Tabs tab0;
00134   SUNDANCE_VERB_HIGH(tab0 << "CurveNormEvaluator::internalFindC() for " << toString());
00135   Set<MultipleDeriv> rtn;
00136 
00137   if (order==1) 
00138     {
00139       Deriv x = coordDeriv(dir_);
00140       MultipleDeriv md;
00141       md.put(x);
00142       rtn.put(md);
00143     }
00144   SUNDANCE_VERB_HIGH(tab0 << "C[" << order << "]=" << rtn);
00145   return rtn;
00146 }*/
00147 
00148 
00149 
00150 
00151 
00152 

Site Contact