FEApp_ConstantNodeBCStrategy.hpp

Go to the documentation of this file.
00001 // $Id: FEApp_ConstantNodeBCStrategy.hpp,v 1.2.2.2 2007/08/14 00:19:05 etphipp Exp $ 
00002 // $Source: /space/CVS/Trilinos/packages/sacado/example/FEApp/FEApp_ConstantNodeBCStrategy.hpp,v $ 
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 ScalarT>
00041   class ConstantNodeBCStrategy : 
00042     public FEApp::AbstractNodeBCStrategy<ScalarT> {
00043   public:
00044 
00046     ConstantNodeBCStrategy(
00047     unsigned int solution_index, 
00048     unsigned int residual_index,
00049     const ScalarT& value,
00050     unsigned int bc_id,
00051     const Teuchos::RCP<Sacado::ScalarParameterLibrary>& paramLib);
00052 
00054     virtual ~ConstantNodeBCStrategy();
00055 
00057     const std::vector<unsigned int>& getOffsets() const;
00058 
00060     virtual void evaluateResidual(const std::vector<ScalarT>* dot,
00061           const std::vector<ScalarT>& solution,
00062           std::vector<ScalarT>& residual) const;
00063 
00065     void setValue(const ScalarT& value, bool mark_constant);
00066 
00068     const ScalarT& getValue() const;
00069 
00070   private:
00071     
00073     ConstantNodeBCStrategy(const ConstantNodeBCStrategy&);
00074 
00076     ConstantNodeBCStrategy& operator=(const ConstantNodeBCStrategy&);
00077 
00078   protected:
00079     
00081     unsigned int sol_index;
00082 
00084     unsigned int res_index;
00085 
00087     ScalarT val;
00088 
00090     std::vector<unsigned int> offsets;
00091 
00092   };
00093 
00094   class ConstantNodeBCStrategy_TemplateBuilder {
00095   public:
00096     ConstantNodeBCStrategy_TemplateBuilder(
00097          unsigned int solution_index, 
00098          unsigned int residual_index,
00099          double value,
00100          unsigned int bc_id,
00101          const Teuchos::RCP<Sacado::ScalarParameterLibrary>& paramLib) :
00102       sol_index(solution_index), res_index(residual_index), val(value),
00103       bcid(bc_id), pl(paramLib) {}
00104     template <typename T>
00105     Teuchos::RCP<FEApp::AbstractNodeBCStrategy_NTBase> build() const {
00106       return Teuchos::rcp( new ConstantNodeBCStrategy<T>(sol_index, 
00107                res_index, 
00108                val,
00109                bcid,
00110                pl));
00111     }
00112   protected:
00113     unsigned int sol_index;
00114     unsigned int res_index;
00115     double val;
00116     unsigned int bcid;
00117     Teuchos::RCP<Sacado::ScalarParameterLibrary> pl;
00118   };
00119 
00124   template <typename ScalarT>
00125   class ConstantNodeBCParameter : 
00126     public Sacado::ScalarParameterEntry<ScalarT> {
00127 
00128   public:
00129 
00131     ConstantNodeBCParameter(
00132        const Teuchos::RCP< ConstantNodeBCStrategy<ScalarT> >& s) : 
00133       bc(s) {}
00134 
00136     virtual ~ConstantNodeBCParameter() {}
00137 
00139     virtual void setRealValue(double value) { 
00140       setValueAsConstant(ScalarT(value)); }
00141 
00143     virtual void setValueAsConstant(const ScalarT& value) { 
00144       bc->setValue(value, true); }
00145     
00147     virtual void setValueAsIndependent(const ScalarT& value) { 
00148       bc->setValue(value, false); }
00149     
00151     virtual const ScalarT& getValue() const { return bc->getValue(); }
00152     
00153   protected:  
00154     
00156     Teuchos::RCP< ConstantNodeBCStrategy<ScalarT> > bc;
00157 
00158   };
00159 
00160 }
00161 
00162 // Include implementation
00163 #ifndef SACADO_ETI
00164 #include "FEApp_ConstantNodeBCStrategyImpl.hpp"
00165 #endif 
00166 
00167 #endif // FEAPP_CONSTANTNODEBCSTRATEGY_HPP

Generated on Tue Oct 20 12:55:02 2009 for Sacado Package Browser (Single Doxygen Collection) by doxygen 1.4.7