FEApp_ConstantNodeBCStrategy.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_CONSTANTNODEBCSTRATEGY_HPP
00033 #define FEAPP_CONSTANTNODEBCSTRATEGY_HPP
00034 
00035 #include "FEApp_AbstractNodeBCStrategy.hpp"
00036 #include "Sacado_ScalarParameterLibrary.hpp"
00037 
00038 namespace FEApp {
00039 
00040   template <typename EvalT>
00041   class ConstantNodeBCStrategy : 
00042     public FEApp::AbstractNodeBCStrategy<EvalT> {
00043   public:
00044 
00046     typedef typename FEApp::AbstractNodeBCStrategy<EvalT>::ScalarT ScalarT;
00047 
00049     ConstantNodeBCStrategy(
00050                  unsigned int solution_index, 
00051                  unsigned int residual_index,
00052                  const ScalarT& value,
00053                  unsigned int bc_id,
00054                  const Teuchos::RCP<ParamLib>& paramLib);
00055 
00057     virtual ~ConstantNodeBCStrategy();
00058 
00060     const std::vector<unsigned int>& getOffsets() const;
00061 
00063     virtual void evaluateResidual(const std::vector<ScalarT>* dot,
00064                                   const std::vector<ScalarT>& solution,
00065                                   std::vector<ScalarT>& residual) const;
00066 
00068     void setValue(const ScalarT& value, bool mark_constant);
00069 
00071     const ScalarT& getValue() const { return val; }
00072 
00073   private:
00074     
00076     ConstantNodeBCStrategy(const ConstantNodeBCStrategy&);
00077 
00079     ConstantNodeBCStrategy& operator=(const ConstantNodeBCStrategy&);
00080 
00081   protected:
00082     
00084     unsigned int sol_index;
00085 
00087     unsigned int res_index;
00088 
00090     ScalarT val;
00091 
00093     std::vector<unsigned int> offsets;
00094 
00095   };
00096 
00097   class ConstantNodeBCStrategy_TemplateBuilder {
00098   public:
00099     ConstantNodeBCStrategy_TemplateBuilder(
00100          unsigned int solution_index, 
00101          unsigned int residual_index,
00102          double value,
00103          unsigned int bc_id,
00104          const Teuchos::RCP<ParamLib>& paramLib) :
00105       sol_index(solution_index), res_index(residual_index), val(value),
00106       bcid(bc_id), pl(paramLib) {}
00107     template <typename T>
00108     Teuchos::RCP<FEApp::AbstractNodeBCStrategy_NTBase> build() const {
00109       return Teuchos::rcp( new ConstantNodeBCStrategy<T>(sol_index, 
00110                                                          res_index, 
00111                                                          val,
00112                                                          bcid,
00113                                                          pl));
00114     }
00115   protected:
00116     unsigned int sol_index;
00117     unsigned int res_index;
00118     double val;
00119     unsigned int bcid;
00120     Teuchos::RCP<ParamLib> pl;
00121   };
00122 
00127   template <typename EvalT>
00128   class ConstantNodeBCParameter : 
00129     public Sacado::ScalarParameterEntry<EvalT,EvaluationTraits> {
00130 
00131   public:
00132 
00134     typedef typename Sacado::ScalarParameterEntry<EvalT,EvaluationTraits>::ScalarT ScalarT;
00135 
00137     ConstantNodeBCParameter(
00138        const Teuchos::RCP< ConstantNodeBCStrategy<EvalT> >& s) : 
00139       bc(s) {}
00140 
00142     virtual ~ConstantNodeBCParameter() {}
00143 
00145     virtual void setRealValue(double value) { 
00146       bc->setValue(value, true); }
00147     
00149     virtual void setValue(const ScalarT& value) { 
00150       bc->setValue(value, false); }
00151 
00153     virtual double getRealValue() const {
00154       return Sacado::ScalarValue<ScalarT>::eval(bc->getValue()); }
00155     
00157     virtual const ScalarT& getValue() const { return bc->getValue(); }
00158     
00159   protected:  
00160     
00162     Teuchos::RCP< ConstantNodeBCStrategy<EvalT> > bc;
00163 
00164   };
00165 
00166 }
00167 
00168 // Include implementation
00169 #ifndef SACADO_ETI
00170 #include "FEApp_ConstantNodeBCStrategyImpl.hpp"
00171 #endif 
00172 
00173 #endif // FEAPP_CONSTANTNODEBCSTRATEGY_HPP

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