SundanceAlgebraSpecifier.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 "SundanceAlgebraSpecifier.hpp"
00032 #include "SundanceOut.hpp"
00033 
00034 using namespace Sundance;
00035 using namespace std;
00036 using namespace Sundance;
00037 using namespace Teuchos;
00038 
00039 
00040 
00041 
00042 AlgebraSpecifier::AlgebraSpecifier()
00043   : EnumTypeField<AlgebraType>(ScalarAT), 
00044     direction_(-1)
00045 {}
00046 
00047 AlgebraSpecifier::AlgebraSpecifier(int direction)
00048   : EnumTypeField<AlgebraType>(CoordCompAT), 
00049     direction_(direction)
00050 {}
00051 
00052 AlgebraSpecifier::AlgebraSpecifier(
00053   const AlgebraType& at)
00054   : EnumTypeField<AlgebraType>(at), direction_(-1)
00055 {
00056   assertNotType(CoordCompAT);
00057 }
00058 
00059 int AlgebraSpecifier::direction() const 
00060 {
00061   assertType(CoordCompAT);
00062   return direction_;
00063 }
00064 
00065 bool AlgebraSpecifier::operator<(const AlgebraSpecifier& other) const 
00066 {
00067   if (type() < other.type()) return true;
00068   if (type() > other.type()) return false;
00069   
00070   if (isCoordinateComponent())
00071     return direction() < other.direction();
00072   return false;
00073 }
00074 
00075 string AlgebraSpecifier::toString() const 
00076 {
00077   TeuchosOStringStream os;
00078   os << *this;
00079   return os.str();
00080 }
00081 
00082 namespace std
00083 {
00084 
00085 ostream& operator<<(std::ostream& os, 
00086   const Sundance::AlgebraType& at)
00087 {
00088   switch(at)
00089   {
00090     case ScalarAT:
00091       os << "Scalar";
00092       break;
00093     case VectorAT:
00094       os << "Vector";
00095       break;
00096     case CoordCompAT:
00097       os << "CoordComp";
00098       break;
00099     case NormalAT:
00100       os << "Normal";
00101       break;
00102     default:
00103       TEUCHOS_TEST_FOR_EXCEPT(1);
00104   }
00105   return os;
00106 }
00107 
00108 ostream& operator<<(std::ostream& os, const Sundance::AlgebraSpecifier& as)
00109 {
00110   os << as.type();
00111   if (as.isCoordinateComponent()) os << "(d=" << as.direction() << ")";
00112   else os << "()";
00113   return os;
00114 }
00115 
00116 }
00117 
00118 namespace Sundance
00119 {
00120 
00121 /** \relates AlgebraSpecifier */
00122 AlgebraSpecifier vectorAlgebraSpec()
00123 {
00124   return AlgebraSpecifier(VectorAT);
00125 }
00126 
00127 /** AlgebraSpecifier */
00128 AlgebraSpecifier scalarAlgebraSpec()
00129 {
00130   return AlgebraSpecifier(ScalarAT);
00131 }
00132 
00133 /** AlgebraSpecifier */
00134 AlgebraSpecifier normalAlgebraSpec()
00135 {
00136   return AlgebraSpecifier(NormalAT);
00137 }
00138 
00139 /** AlgebraSpecifier */
00140 AlgebraSpecifier coordAlgebraSpec(int dir)
00141 {
00142   return AlgebraSpecifier(dir);
00143 }
00144 
00145 }

Site Contact