SundanceFunctionIdentifier.hpp
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 #ifndef SUNDANCE_FUNCTIONIDENTIFIER_H
00043 #define SUNDANCE_FUNCTIONIDENTIFIER_H
00044 
00045 #include "SundanceAlgebraSpecifier.hpp"
00046 
00047 namespace Sundance
00048 {
00049 
00050 /** 
00051  * FunctionIdentifier provides a means for distinguishing between different
00052  * functions and different vector components of the same function. 
00053  * Functions discretized with vector bases will shared a common dofID,
00054  * because their vector components are not independent. Functions 
00055  * discretized componentwise will have different IDs for each component.
00056  */
00057 class FunctionIdentifier
00058 {
00059 public:
00060   /** */
00061   FunctionIdentifier();
00062   /** ctor */
00063   FunctionIdentifier(const AlgebraSpecifier& algSpec);
00064   /** ctor */
00065   FunctionIdentifier(const FunctionIdentifier* parent,
00066     const AlgebraSpecifier& componentAlgSpec);
00067 
00068   /** */
00069   std::string toString() const ;
00070 
00071   /** Return the ID number to be used when assigning DOFs 
00072       for this function */
00073   int dofID() const {return dofID_;}
00074 
00075   /** If this FID corresponds to a vector component, return the 
00076    *  index of the coordinate direction */
00077   int componentIndex() const ;
00078 
00079   /** Return a specification of the type of object represented, i.e.,
00080    * a component in a coord direction, a normal component, or a whole
00081    * vector. */
00082   const AlgebraSpecifier& algSpec() const 
00083     {return algSpec_;}
00084 
00085   /** Create a new FID representing a component of "this" vector function. */
00086   FunctionIdentifier createComponent(int index) const ;
00087 
00088   /** Create a new FID representing the normal 
00089    * component of "this" vector function. */
00090   FunctionIdentifier createNormal() const ;
00091 
00092   /** Comparison operator for storage in sets and maps */
00093   bool operator<(const FunctionIdentifier& other) const ;
00094 
00095   /** Equality test */
00096   bool operator==(const FunctionIdentifier& other) const 
00097     {return !(*this!=other);} 
00098 
00099   /** Inequality test */
00100   bool operator!=(const FunctionIdentifier& other) const 
00101     {return *this < other || other < *this;}
00102 
00103   /** Return true if I am a vector */
00104   bool isVector() const {return algSpec().isVector();}
00105 
00106   /** Return true if I am a coordinate component */
00107   bool isCoordinateComponent() const {return algSpec().isCoordinateComponent();}
00108 
00109   /** Return true if I am a normal component */
00110   bool isNormalComponent() const {return algSpec().isNormal();}
00111 
00112   /** Return true if I am a scalar */
00113   bool isScalar() const {return algSpec().isScalar();}
00114 
00115 private:
00116 
00117   /** Generate a unique ID */
00118   static int nextID() {static int id=0; id++; return id;}
00119 
00120   int dofID_;
00121 
00122   AlgebraSpecifier algSpec_;
00123 };
00124 
00125 /** \relates FunctionIdentifier */
00126 FunctionIdentifier makeFuncID(int tensorOrder);
00127 
00128 }
00129 
00130 
00131 namespace std
00132 {
00133 /** \relates FunctionIdentifier */
00134 ostream& operator<<(std::ostream& os, const Sundance::FunctionIdentifier& fid);
00135 }
00136 
00137 #endif

Site Contact