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 #ifndef SUNDANCE_SPATIALDERIVSPECIFIER_HPP 00032 #define SUNDANCE_SPATIALDERIVSPECIFIER_HPP 00033 00034 #include "SundanceEnumTypeField.hpp" 00035 #include "SundanceMultiIndex.hpp" 00036 00037 namespace Sundance 00038 { 00039 using namespace Sundance; 00040 00041 /** */ 00042 enum SpatialDerivType {IdentitySDT, PartialSDT, NormalSDT, DivSDT}; 00043 00044 00045 00046 /** 00047 * This class is a compact description of type of spatial derivative 00048 * acting on an operative function: partial derivative, divergence, 00049 * or normal derivative. 00050 */ 00051 class SpatialDerivSpecifier : public EnumTypeField<SpatialDerivType> 00052 { 00053 public: 00054 /** Empty ctor creates an identity operator 00055 * (zeroth order partial derivative) */ 00056 SpatialDerivSpecifier(); 00057 00058 /** Create a spatial derivative */ 00059 SpatialDerivSpecifier(const MultiIndex& mi); 00060 00061 /** Create a derivative of a specified type and order. */ 00062 SpatialDerivSpecifier(const SpatialDerivType& type, int order=0); 00063 00064 /** Return the multiindex of a spatial partial derivative */ 00065 const MultiIndex& mi() const ; 00066 00067 /** Return true if I am a divergence */ 00068 bool isDivergence() const ; 00069 00070 /** Return true if I am a partial derivative in a coordinate direction */ 00071 bool isPartial() const ; 00072 00073 /** Return true if I am a normal derivative */ 00074 bool isNormal() const ; 00075 00076 /** Return true if I am an identity operator */ 00077 bool isIdentity() const ; 00078 00079 /** Return the order of differentiation in the normal direction */ 00080 int normalDerivOrder() const ; 00081 00082 /** Return the order of differentiation */ 00083 int derivOrder() const ; 00084 00085 /** Write me to a std::string */ 00086 std::string toString() const ; 00087 00088 /** Comparison operator for use in sorted containers */ 00089 bool operator<(const SpatialDerivSpecifier& other) const ; 00090 00091 /** Create a new derivative that increments my multiindex by the input 00092 * multiindex */ 00093 SpatialDerivSpecifier derivWrtMultiIndex(const MultiIndex& mi) const ; 00094 00095 private: 00096 MultiIndex mi_; 00097 00098 int normalDerivOrder_; 00099 }; 00100 00101 00102 } 00103 00104 00105 namespace std 00106 { 00107 /** \relates SpatialDerivSpecifier */ 00108 ostream& operator<<(std::ostream& os, const Sundance::SpatialDerivSpecifier& sds); 00109 /** \relates SpatialDerivSpecifier */ 00110 ostream& operator<<(std::ostream& os, const Sundance::SpatialDerivType& sdt); 00111 } 00112 00113 00114 #endif