00001 // @HEADER 00002 // ************************************************************************ 00003 // 00004 // Phalanx: A Partial Differential Equation Field Evaluation 00005 // Kernel for Flexible Management of Complex Dependency Chains 00006 // Copyright (2008) Sandia Corporation 00007 // 00008 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, 00009 // the U.S. Government 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 // 00026 // Questions? Contact Roger Pawlowski (rppawlo@sandia.gov), Sandia 00027 // National Laboratories. 00028 // 00029 // ************************************************************************ 00030 // @HEADER 00031 00032 #ifndef PHX_TRAITS_HPP 00033 #define PHX_TRAITS_HPP 00034 00035 // mpl (Meta Programming Library) templates 00036 #include "Sacado_mpl_vector.hpp" 00037 #include "Sacado_mpl_find.hpp" 00038 #include "boost/mpl/map.hpp" 00039 #include "boost/mpl/find.hpp" 00040 00041 // traits Base Class 00042 #include "Phalanx_Traits_Base.hpp" 00043 00044 // Include User Data Types 00045 #include "Phalanx_ConfigDefs.hpp" 00046 #include "Sacado.hpp" 00047 #include "Dimension.hpp" 00048 #include "Cell.hpp" 00049 #include "Workset.hpp" 00050 #include "Phalanx_Allocator_New.hpp" 00051 00052 namespace PHX { 00053 00054 struct MyTraits : public PHX::TraitsBase { 00055 00056 // ****************************************************************** 00057 // *** Scalar Types 00058 // ****************************************************************** 00059 00060 // Scalar types we plan to use 00061 typedef double RealType; 00062 typedef Sacado::Fad::DFad<double> FadType; 00063 00064 // ****************************************************************** 00065 // *** Evaluation Types 00066 // ****************************************************************** 00067 struct Residual { typedef RealType ScalarT; }; 00068 struct Jacobian { typedef FadType ScalarT; }; 00069 typedef Sacado::mpl::vector<Residual, Jacobian> EvalTypes; 00070 00071 // ****************************************************************** 00072 // *** Data Types 00073 // ****************************************************************** 00074 00075 // Create the data types for each evaluation type 00076 00077 // Residual (default scalar type is RealType) 00078 typedef Sacado::mpl::vector<RealType> ResidualDataTypes; 00079 00080 // Jacobian (default scalar type is Fad<double, double>) 00081 typedef Sacado::mpl::vector<FadType> JacobianDataTypes; 00082 00083 // Maps the key EvalType a vector of DataTypes 00084 typedef boost::mpl::map< 00085 boost::mpl::pair<Residual, ResidualDataTypes>, 00086 boost::mpl::pair<Jacobian, JacobianDataTypes> 00087 >::type EvalToDataMap; 00088 00089 // ****************************************************************** 00090 // *** Allocator Type 00091 // ****************************************************************** 00092 typedef PHX::NewAllocator Allocator; 00093 00094 // ****************************************************************** 00095 // *** User Defined Object Passed in for Evaluation Method 00096 // ****************************************************************** 00097 typedef const MyWorkset& EvalData; 00098 typedef void* PreEvalData; 00099 typedef void* PostEvalData; 00100 00101 }; 00102 00103 // ****************************************************************** 00104 // ****************************************************************** 00105 // Debug strings. Specialize the Evaluation and Data types for the 00106 // TypeString object in phalanx/src/Phalanx_TypeString.hpp. 00107 // ****************************************************************** 00108 // ****************************************************************** 00109 00110 // Evaluation Types 00111 template<> struct TypeString<MyTraits::Residual> 00112 { static const std::string value; }; 00113 00114 template<> struct TypeString<MyTraits::Jacobian> 00115 { static const std::string value; }; 00116 00117 const std::string TypeString<MyTraits::Residual>::value = 00118 "Residual"; 00119 00120 const std::string TypeString<MyTraits::Jacobian>::value = 00121 "Jacobian"; 00122 00123 // Data Types 00124 template<> struct TypeString<double> 00125 { static const std::string value; }; 00126 00127 template<> struct TypeString< Sacado::Fad::DFad<double> > 00128 { static const std::string value; }; 00129 00130 const std::string TypeString<double>::value = 00131 "double"; 00132 00133 const std::string TypeString< Sacado::Fad::DFad<double> >:: 00134 value = "Sacado::Fad::DFad<double>"; 00135 00136 } 00137 00138 #endif