• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

PHAL_AlbanyTraits.hpp

Go to the documentation of this file.
00001 //*****************************************************************//
00002 //    Albany 2.0:  Copyright 2012 Sandia Corporation               //
00003 //    This Software is released under the BSD license detailed     //
00004 //    in the file "license.txt" in the top-level Albany directory  //
00005 //*****************************************************************//
00006 
00007 #ifndef PHAL_ALBANYTRAITS_HPP
00008 #define PHAL_ALBANYTRAITS_HPP
00009 
00010 // mpl (Meta Programming Library) templates
00011 //#include "Sacado.hpp"
00012 #include "Sacado_mpl_vector.hpp"
00013 #include "Sacado_mpl_find.hpp"
00014 #include "boost/mpl/map.hpp"
00015 #include "boost/mpl/find.hpp"
00016 #include "boost/mpl/vector.hpp"
00017 
00018 // traits Base Class
00019 #include "Phalanx_Traits_Base.hpp"
00020 
00021 // Include User Data Types
00022 #include "Phalanx_ConfigDefs.hpp"
00023 #include "Phalanx_Allocator_Contiguous.hpp"
00024 #include "Phalanx_Allocator_New.hpp"
00025 #include "Phalanx_TypeStrings.hpp"
00026 
00027 #include "Albany_DataTypes.hpp"
00028 #include "PHAL_Dimension.hpp"
00029 
00031 namespace PHAL {
00032 
00033   // Forward declaration since Workset needs AlbanyTraits
00034   struct Workset;
00035 
00036   struct AlbanyTraits : public PHX::TraitsBase {
00037 
00038     // ******************************************************************
00039     // *** Evaluation Types
00040     //   * ScalarT is for quantities that depend on solution/params
00041     //   * MeshScalarT  is for quantities that depend on mesh coords only
00042     // ******************************************************************
00043     struct Residual   { typedef RealType  ScalarT; typedef RealType MeshScalarT; };
00044     struct Jacobian   { typedef FadType   ScalarT; typedef RealType MeshScalarT; };
00045     struct Tangent    { typedef TanFadType   ScalarT;
00046                         typedef TanFadType   MeshScalarT; };  // Use this for shape opt
00047                         //typedef RealType MeshScalarT; }; // Uncomment for no shape opt
00048 #ifdef ALBANY_SG_MP
00049     struct SGResidual { typedef SGType    ScalarT; typedef RealType MeshScalarT; };
00050     struct SGJacobian { typedef SGFadType ScalarT; typedef RealType MeshScalarT; };
00051     struct SGTangent  { typedef SGFadType ScalarT; typedef RealType MeshScalarT; };
00052     struct MPResidual { typedef MPType    ScalarT; typedef RealType MeshScalarT; };
00053     struct MPJacobian { typedef MPFadType ScalarT; typedef RealType MeshScalarT; };
00054     struct MPTangent  { typedef MPFadType ScalarT; typedef RealType MeshScalarT; };
00055 #endif //ALBANY_SG_MP
00056 
00057 #ifdef ALBANY_SG_MP
00058     typedef Sacado::mpl::vector<Residual, Jacobian, Tangent, 
00059         SGResidual, SGJacobian, SGTangent,
00060         MPResidual, MPJacobian, MPTangent> EvalTypes;
00061     typedef boost::mpl::vector<Residual, Jacobian, Tangent, 
00062              SGResidual, SGJacobian, SGTangent,
00063              MPResidual, MPJacobian, MPTangent> BEvalTypes;
00064 #else
00065     typedef Sacado::mpl::vector<Residual, Jacobian, Tangent> EvalTypes;
00066     typedef boost::mpl::vector<Residual, Jacobian, Tangent> BEvalTypes;
00067 #endif //ALBANY_SG_MP
00068     
00069     // ******************************************************************
00070     // *** Data Types
00071     // ******************************************************************
00072     
00073     // Create the data types for each evaluation type
00074     //AGS RPP 3/2010: Added RealType as acceptible Field
00075     //   type for all EvalT so that coordVec(double) for
00076     //   all EvalT
00077     
00078     // Residual (default scalar type is RealType)
00079     typedef Sacado::mpl::vector<RealType> ResidualDataTypes;
00080   
00081     // Jacobian (default scalar type is Fad<double, double>)
00082     typedef Sacado::mpl::vector<FadType,RealType> JacobianDataTypes;
00083 
00084     // Tangent (default scalar type is Fad<double>)
00085     typedef Sacado::mpl::vector<TanFadType,RealType> TangentDataTypes;
00086 
00087 #ifdef ALBANY_SG_MP
00088     // SG Residual (default scalar type is SGType)
00089     typedef Sacado::mpl::vector<SGType,RealType> SGResidualDataTypes;
00090   
00091     // SG Jacobian (default scalar type is Fad<SGType>)
00092     typedef Sacado::mpl::vector<SGFadType,RealType> SGJacobianDataTypes;
00093 
00094     // SG Tangent (default scalar type is Fad<SGType>)
00095     typedef Sacado::mpl::vector<SGFadType,RealType> SGTangentDataTypes;
00096 
00097     // MP Residual (default scalar type is MPType)
00098     typedef Sacado::mpl::vector<MPType,RealType> MPResidualDataTypes;
00099   
00100     // MP Jacobian (default scalar type is Fad<MPType>)
00101     typedef Sacado::mpl::vector<MPFadType,RealType> MPJacobianDataTypes;
00102 
00103     // MP Tangent (default scalar type is Fad<MPType>)
00104     typedef Sacado::mpl::vector<MPFadType,RealType> MPTangentDataTypes;
00105 #endif //ALBANY_SG_MP
00106 
00107     // Maps the key EvalType a vector of DataTypes
00108 #ifdef ALBANY_SG_MP
00109     typedef boost::mpl::map<
00110       boost::mpl::pair<Residual, ResidualDataTypes>,
00111       boost::mpl::pair<Jacobian, JacobianDataTypes>,
00112       boost::mpl::pair<Tangent,  TangentDataTypes>,
00113       boost::mpl::pair<SGResidual, SGResidualDataTypes>,
00114       boost::mpl::pair<SGJacobian, SGJacobianDataTypes>,
00115       boost::mpl::pair<SGTangent,  SGTangentDataTypes>,
00116       boost::mpl::pair<MPResidual, MPResidualDataTypes>,
00117       boost::mpl::pair<MPJacobian, MPJacobianDataTypes>,
00118       boost::mpl::pair<MPTangent,  MPTangentDataTypes >
00119     >::type EvalToDataMap;
00120 #else
00121     typedef boost::mpl::map<
00122       boost::mpl::pair<Residual, ResidualDataTypes>,
00123       boost::mpl::pair<Jacobian, JacobianDataTypes>,
00124       boost::mpl::pair<Tangent,  TangentDataTypes>
00125     >::type EvalToDataMap;
00126 #endif //ALBANY_SG_MP
00127 
00128     // ******************************************************************
00129     // *** Allocator Type
00130     // ******************************************************************
00131     typedef PHX::NewAllocator Allocator;
00132     //typedef PHX::ContiguousAllocator<RealType> Allocator;
00133 
00134     // ******************************************************************
00135     // *** User Defined Object Passed in for Evaluation Method
00136     // ******************************************************************
00137     typedef const std::string& SetupData;
00138     //typedef const Albany::AbstractDiscretization& SetupData;
00139     typedef Workset& EvalData;
00140     typedef Workset& PreEvalData;
00141     typedef Workset& PostEvalData;
00142 
00143   };
00144  
00145   // ******************************************************************
00146   // ******************************************************************
00147   // Debug strings.  Specialize the Evaluation and Data types for the
00148   // TypeString object in phalanx/src/Phalanx_TypeStrings.hpp.
00149   // ******************************************************************
00150   // ******************************************************************
00151 
00152 }
00153 
00154 namespace PHX {
00155   // Evaluation Types
00156   template<> struct TypeString<PHAL::AlbanyTraits::Residual> 
00157   { static const std::string value; };
00158 
00159   template<> struct TypeString<PHAL::AlbanyTraits::Jacobian> 
00160   { static const std::string value; };
00161 
00162   template<> struct TypeString<PHAL::AlbanyTraits::Tangent> 
00163   { static const std::string value; };
00164 
00165 #ifdef ALBANY_SG_MP
00166   template<> struct TypeString<PHAL::AlbanyTraits::SGResidual> 
00167   { static const std::string value; };
00168 
00169   template<> struct TypeString<PHAL::AlbanyTraits::SGJacobian> 
00170   { static const std::string value; };
00171 
00172   template<> struct TypeString<PHAL::AlbanyTraits::SGTangent> 
00173   { static const std::string value; };
00174 
00175   template<> struct TypeString<PHAL::AlbanyTraits::MPResidual> 
00176   { static const std::string value; };
00177 
00178   template<> struct TypeString<PHAL::AlbanyTraits::MPJacobian> 
00179   { static const std::string value; };
00180 
00181   template<> struct TypeString<PHAL::AlbanyTraits::MPTangent> 
00182   { static const std::string value; };
00183 #endif //ALBANY_SG_MP
00184 
00185   // Data Types
00186   template<> struct TypeString<RealType> 
00187   { static const std::string value; };
00188 
00189   template<> struct TypeString<FadType > 
00190   { static const std::string value; };
00191 
00192 #ifdef ALBANY_FADTYPE_NOTEQUAL_TANFADTYPE
00193 // This is necessary iff TanFadType is different from FadType
00194   template<> struct TypeString<TanFadType > 
00195   { static const std::string value; };
00196 #endif
00197 
00198 #ifdef ALBANY_SG_MP
00199   template<> struct TypeString<SGType> 
00200   { static const std::string value; };
00201 
00202   template<> struct TypeString<SGFadType> 
00203   { static const std::string value; };
00204 
00205   template<> struct TypeString<MPType> 
00206   { static const std::string value; };
00207 
00208   template<> struct TypeString<MPFadType> 
00209   { static const std::string value; };
00210 #endif //ALBANY_SG_MP
00211 
00212 }
00213 
00214 // Define macro for explicit template instantiation
00215 #define PHAL_INSTANTIATE_TEMPLATE_CLASS_RESIDUAL(name) \
00216   template class name<PHAL::AlbanyTraits::Residual, PHAL::AlbanyTraits>;
00217 #define PHAL_INSTANTIATE_TEMPLATE_CLASS_JACOBIAN(name) \
00218   template class name<PHAL::AlbanyTraits::Jacobian, PHAL::AlbanyTraits>;
00219 #define PHAL_INSTANTIATE_TEMPLATE_CLASS_TANGENT(name) \
00220   template class name<PHAL::AlbanyTraits::Tangent, PHAL::AlbanyTraits>;
00221 
00222 #ifdef ALBANY_SG_MP
00223 #define PHAL_INSTANTIATE_TEMPLATE_CLASS_SGRESIDUAL(name) \
00224   template class name<PHAL::AlbanyTraits::SGResidual, PHAL::AlbanyTraits>;
00225 #define PHAL_INSTANTIATE_TEMPLATE_CLASS_SGJACOBIAN(name) \
00226   template class name<PHAL::AlbanyTraits::SGJacobian, PHAL::AlbanyTraits>;
00227 #define PHAL_INSTANTIATE_TEMPLATE_CLASS_SGTANGENT(name) \
00228   template class name<PHAL::AlbanyTraits::SGTangent, PHAL::AlbanyTraits>;
00229 #define PHAL_INSTANTIATE_TEMPLATE_CLASS_MPRESIDUAL(name) \
00230   template class name<PHAL::AlbanyTraits::MPResidual, PHAL::AlbanyTraits>;
00231 #define PHAL_INSTANTIATE_TEMPLATE_CLASS_MPJACOBIAN(name) \
00232   template class name<PHAL::AlbanyTraits::MPJacobian, PHAL::AlbanyTraits>;
00233 #define PHAL_INSTANTIATE_TEMPLATE_CLASS_MPTANGENT(name) \
00234   template class name<PHAL::AlbanyTraits::MPTangent, PHAL::AlbanyTraits>;
00235 #endif //ALBANY_SG_MP
00236 
00237 #ifdef ALBANY_SG_MP
00238 #define PHAL_INSTANTIATE_TEMPLATE_CLASS(name)    \
00239   PHAL_INSTANTIATE_TEMPLATE_CLASS_RESIDUAL(name)   \
00240   PHAL_INSTANTIATE_TEMPLATE_CLASS_JACOBIAN(name)   \
00241   PHAL_INSTANTIATE_TEMPLATE_CLASS_TANGENT(name)    \
00242   PHAL_INSTANTIATE_TEMPLATE_CLASS_SGRESIDUAL(name)   \
00243   PHAL_INSTANTIATE_TEMPLATE_CLASS_SGJACOBIAN(name)   \
00244   PHAL_INSTANTIATE_TEMPLATE_CLASS_SGTANGENT(name)  \
00245   PHAL_INSTANTIATE_TEMPLATE_CLASS_MPRESIDUAL(name)   \
00246   PHAL_INSTANTIATE_TEMPLATE_CLASS_MPJACOBIAN(name)   \
00247   PHAL_INSTANTIATE_TEMPLATE_CLASS_MPTANGENT(name)
00248 #else
00249 #define PHAL_INSTANTIATE_TEMPLATE_CLASS(name)    \
00250   PHAL_INSTANTIATE_TEMPLATE_CLASS_RESIDUAL(name)   \
00251   PHAL_INSTANTIATE_TEMPLATE_CLASS_JACOBIAN(name)   \
00252   PHAL_INSTANTIATE_TEMPLATE_CLASS_TANGENT(name)
00253 #endif //ALBANY_SG_MP
00254 
00255 #include "PHAL_Workset.hpp"
00256 
00257 #endif

Generated on Wed Mar 26 2014 18:36:40 for Albany: a Trilinos-based PDE code by  doxygen 1.7.1