Go to the documentation of this file.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
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "SundanceCoordExpr.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 Sundance;
00050 using namespace Teuchos;
00051
00052
00053 CoordExpr::CoordExpr(int dir, const std::string& name)
00054 : EvaluatableExpr(),
00055 dir_(dir),
00056 name_(coordName(dir, name))
00057 {}
00058
00059 bool CoordExpr::lessThan(const ScalarExpr* other) const
00060 {
00061 const CoordExpr* c = dynamic_cast<const CoordExpr*>(other);
00062 TEUCHOS_TEST_FOR_EXCEPTION(c==0, std::logic_error, "cast should never fail at this point");
00063 return dir() < c->dir();
00064 }
00065
00066 XMLObject CoordExpr::toXML() const
00067 {
00068 XMLObject rtn("CoordExpr");
00069 rtn.addAttribute("dir", Teuchos::toString(dir_));
00070 rtn.addAttribute("name", name());
00071 return rtn;
00072 }
00073
00074 string CoordExpr::coordName(int dir, const std::string& name)
00075 {
00076 if (name.length() > 0) return name;
00077 switch(dir)
00078 {
00079 case 0:
00080 return "x";
00081 case 1:
00082 return "y";
00083 case 2:
00084 return "z";
00085 default:
00086 TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error,
00087 "CoordExpr::coordName direction out of range [0,2]");
00088 return "error";
00089 }
00090 }
00091
00092
00093 Set<MultipleDeriv>
00094 CoordExpr::internalFindW(int order, const EvalContext& context) const
00095 {
00096 Tabs tab0;
00097 SUNDANCE_VERB_HIGH(tab0 << "CoordExpr::internalFindW() for " << toString());
00098 Set<MultipleDeriv> rtn;
00099
00100 if (order==0) rtn.put(MultipleDeriv());
00101
00102 if (order==1)
00103 {
00104 Deriv x = coordDeriv(dir_);
00105 MultipleDeriv md;
00106 md.put(x);
00107 rtn.put(md);
00108 }
00109
00110 SUNDANCE_VERB_HIGH(tab0 << "W[" << order << "]=" << rtn);
00111 return rtn;
00112 }
00113
00114
00115 Set<MultipleDeriv>
00116 CoordExpr::internalFindV(int order, const EvalContext& context) const
00117 {
00118 Tabs tab0;
00119 SUNDANCE_VERB_HIGH(tab0 << "CoordExpr::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 Set<MultipleDeriv>
00130 CoordExpr::internalFindC(int order, const EvalContext& context) const
00131 {
00132 Tabs tab0;
00133 SUNDANCE_VERB_HIGH(tab0 << "CoordExpr::internalFindC() for " << toString());
00134 Set<MultipleDeriv> rtn;
00135
00136 if (order==1)
00137 {
00138 Deriv x = coordDeriv(dir_);
00139 MultipleDeriv md;
00140 md.put(x);
00141 rtn.put(md);
00142 }
00143 SUNDANCE_VERB_HIGH(tab0 << "C[" << order << "]=" << rtn);
00144 return rtn;
00145 }
00146
00147
00148
00149
00150
00151