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

Site Contact