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" // for std::vector 00046 #include "AlgebraicTypes.hpp" 00047 #include "Workset.hpp" 00048 #include "Cell.hpp" 00049 #include "Phalanx_Allocator_New.hpp" 00050 00051 namespace PHX { 00052 00070 struct MyTraits : public PHX::TraitsBase { 00071 00072 // ****************************************************************** 00073 // *** Scalar Types 00074 // ****************************************************************** 00075 00076 // Scalar types we plan to use 00077 typedef double RealType; 00078 typedef Sacado::Fad::DFad<double> FadType; 00079 00080 // ****************************************************************** 00081 // *** Evaluation Types 00082 // ****************************************************************** 00083 struct Residual { typedef RealType ScalarT; }; 00084 struct Jacobian { typedef FadType ScalarT; }; 00085 typedef Sacado::mpl::vector<Residual, Jacobian> EvalTypes; 00086 00087 // ****************************************************************** 00088 // *** Data Types 00089 // ****************************************************************** 00090 00091 // Create the data types for each evaluation type 00092 00093 // Residual (default scalar type is RealType) 00094 typedef Sacado::mpl::vector< RealType, 00095 MyVector<RealType>, 00096 MyTensor<RealType> 00097 > ResidualDataTypes; 00098 00099 // Jacobian (default scalar type is Fad<double, double>) 00100 typedef Sacado::mpl::vector< FadType, 00101 MyVector<FadType>, 00102 MyTensor<FadType> 00103 > JacobianDataTypes; 00104 00105 // Maps the key EvalType a vector of DataTypes 00106 typedef boost::mpl::map< 00107 boost::mpl::pair<Residual, ResidualDataTypes>, 00108 boost::mpl::pair<Jacobian, JacobianDataTypes> 00109 >::type EvalToDataMap; 00110 00111 // ****************************************************************** 00112 // *** Allocator Type 00113 // ****************************************************************** 00114 typedef PHX::NewAllocator Allocator; 00115 00116 // ****************************************************************** 00117 // *** User Defined Object Passed in for Evaluation Method 00118 // ****************************************************************** 00119 typedef const MyWorkset& EvalData; 00120 typedef void* PreEvalData; 00121 typedef void* PostEvalData; 00122 00123 }; 00124 00125 // ****************************************************************** 00126 // ****************************************************************** 00127 // Debug strings. Specialize the Evaluation and Data types for the 00128 // TypeString object in the phalanx/src/Phalanx_TypeString.hpp file. 00129 // ****************************************************************** 00130 // ****************************************************************** 00131 00132 // Evaluation Types 00133 template<> struct TypeString<MyTraits::Residual> 00134 { static const std::string value; }; 00135 00136 template<> struct TypeString<MyTraits::Jacobian> 00137 { static const std::string value; }; 00138 00139 const std::string TypeString<MyTraits::Residual>::value = 00140 "Residual"; 00141 00142 const std::string TypeString<MyTraits::Jacobian>::value = 00143 "Jacobian"; 00144 00145 // Data Types 00146 template<> struct TypeString<double> 00147 { static const std::string value; }; 00148 00149 template<> struct TypeString< MyVector<double> > 00150 { static const std::string value; }; 00151 00152 template<> struct TypeString< MyTensor<double> > 00153 { static const std::string value; }; 00154 00155 template<> struct TypeString< Sacado::Fad::DFad<double> > 00156 { static const std::string value; }; 00157 00158 template<> struct TypeString< MyVector<Sacado::Fad::DFad<double> > > 00159 { static const std::string value; }; 00160 00161 template<> struct TypeString< MyTensor<Sacado::Fad::DFad<double> > > 00162 { static const std::string value; }; 00163 00164 const std::string TypeString<double>::value = 00165 "double"; 00166 00167 const std::string TypeString< MyVector<double> >::value = 00168 "MyVector<double>"; 00169 00170 const std::string TypeString< MyTensor<double> >::value = 00171 "MyTensor<double>"; 00172 00173 const std::string TypeString< Sacado::Fad::DFad<double> >:: 00174 value = "Sacado::Fad::DFad<double>"; 00175 00176 const std::string TypeString< MyVector<Sacado::Fad::DFad<double> > >:: 00177 value = "Sacado::Fad::DFad< MyVector<double> >"; 00178 00179 const std::string TypeString< MyTensor<Sacado::Fad::DFad<double> > >:: 00180 value = "Sacado::Fad::DFad< MyTensor<double> >"; 00181 } 00182 00183 #endif