FEApp_TemplateTypes.hpp

Go to the documentation of this file.
00001 // $Id$ 
00002 // $Source$ 
00003 // @HEADER
00004 // ***********************************************************************
00005 // 
00006 //                           Sacado Package
00007 //                 Copyright (2006) Sandia Corporation
00008 // 
00009 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00010 // the U.S. Government retains certain rights in this software.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //  
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
00027 // (etphipp@sandia.gov).
00028 // 
00029 // ***********************************************************************
00030 // @HEADER
00031 
00032 #ifndef FEAPP_TEMPLATETYPES_HPP
00033 #define FEAPP_TEMPLATETYPES_HPP
00034 
00035 #include "Sacado_ConfigDefs.h"
00036 
00037 // Conditionally enable Stokhos stochastic Galerkin expansions
00038 #ifdef HAVE_SACADO_STOKHOS
00039 #define SG_ACTIVE 1
00040 #else
00041 #define SG_ACTIVE 0
00042 #endif
00043 
00044 // Include the MPL vector
00045 #include "Sacado_mpl_vector.hpp"
00046 
00047 // Include all of our AD types
00048 #include "Sacado_MathFunctions.hpp"
00049 #include "Sacado.hpp"
00050 //#include "Sacado_CacheFad_DFad.hpp"
00051 #if SG_ACTIVE
00052 #include "Sacado_PCE_OrthogPoly.hpp"
00053 #endif
00054 
00055 // Include ScalarParameterLibrary to specialize traits
00056 #include "Sacado_ScalarParameterLibrary.hpp"
00057 
00058 // Typedef AD types to standard names
00059 typedef double RealType;
00060 typedef Sacado::Fad::DFad<double> FadType;
00061 #if SG_ACTIVE
00062 typedef Sacado::PCE::OrthogPoly<double> SGType;
00063 typedef Sacado::Fad::DFad< Sacado::PCE::OrthogPoly<double> > SGFadType;
00064 #endif
00065 
00066 // Set up evaluation traits
00067 namespace FEApp {
00068 
00069   // Evaluation types
00070   struct ResidualType {};
00071   struct JacobianType {};
00072   struct TangentType {};
00073 #if SG_ACTIVE
00074   struct SGResidualType {};
00075   struct SGJacobianType {};
00076 #endif
00077 
00078   // Evaluation traits
00079   struct EvaluationTraits {
00080     template <class EvalT> struct apply {};
00081   };
00082 
00083   template <> struct EvaluationTraits::apply<ResidualType> { 
00084     typedef RealType type; };
00085   template <> struct EvaluationTraits::apply<JacobianType> { 
00086     typedef FadType type; };
00087   template <> struct EvaluationTraits::apply<TangentType> { 
00088     typedef FadType type; };
00089 #if SG_ACTIVE
00090   template <> struct EvaluationTraits::apply<SGResidualType> { 
00091     typedef SGType type; };
00092   template <> struct EvaluationTraits::apply<SGJacobianType> { 
00093     typedef SGFadType  type; };
00094 #endif
00095 }
00096 
00097 // Synonym for the ScalarParameterLibrary/Vector on our traits
00098 typedef Sacado::ScalarParameterLibrary<FEApp::EvaluationTraits> ParamLib;
00099 typedef Sacado::ScalarParameterVector<FEApp::EvaluationTraits> ParamVec;
00100 
00101 // Build the MPL vector containing our valid evaluation types
00102 typedef Sacado::mpl::vector<> EvalTypes0;
00103 typedef Sacado::mpl::push_back<EvalTypes0, FEApp::ResidualType>::type EvalTypes1;
00104 typedef Sacado::mpl::push_back<EvalTypes1, FEApp::JacobianType>::type EvalTypes2;
00105 typedef Sacado::mpl::push_back<EvalTypes2, FEApp::TangentType>::type EvalTypes3;
00106 #if SG_ACTIVE
00107 typedef Sacado::mpl::push_back<EvalTypes3, FEApp::SGResidualType>::type EvalTypes4;
00108 typedef Sacado::mpl::push_back<EvalTypes4, FEApp::SGJacobianType>::type EvalTypes5;
00109 #else
00110 typedef EvalTypes3 EvalTypes5;
00111 #endif
00112 typedef EvalTypes5 EvalTypes;
00113 
00114 // Turn on/off explicit template instantiation
00115 #define SACADO_ETI
00116 
00117 // Define macro for explicit template instantiation
00118 #define INSTANTIATE_TEMPLATE_CLASS_RESIDUAL(name) template class name<FEApp::ResidualType>;
00119 #define INSTANTIATE_TEMPLATE_CLASS_JACOBIAN(name) template class name<FEApp::JacobianType>;
00120 #define INSTANTIATE_TEMPLATE_CLASS_TANGENT(name) template class name<FEApp::TangentType>;
00121 #if SG_ACTIVE
00122 #define INSTANTIATE_TEMPLATE_CLASS_SGRESIDUAL(name) template class name<FEApp::SGResidualType>;
00123 #define INSTANTIATE_TEMPLATE_CLASS_SGJACOBIAN(name) template class name<FEApp::SGJacobianType>;
00124 #else
00125 #define INSTANTIATE_TEMPLATE_CLASS_SGRESIDUAL(name)
00126 #define INSTANTIATE_TEMPLATE_CLASS_SGJACOBIAN(name)
00127 #endif
00128 
00129 #define INSTANTIATE_TEMPLATE_CLASS(name)      \
00130   INSTANTIATE_TEMPLATE_CLASS_RESIDUAL(name)   \
00131   INSTANTIATE_TEMPLATE_CLASS_JACOBIAN(name)   \
00132   INSTANTIATE_TEMPLATE_CLASS_TANGENT(name)    \
00133   INSTANTIATE_TEMPLATE_CLASS_SGRESIDUAL(name) \
00134   INSTANTIATE_TEMPLATE_CLASS_SGJACOBIAN(name)
00135 
00136 #endif // FEAPP_TEMPLATETYPES_HPP

Generated on Wed May 12 21:39:33 2010 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.4.7