FEApp_BrusselatorNodeBCStrategyImpl.hpp

Go to the documentation of this file.
00001 // $Id: FEApp_BrusselatorNodeBCStrategyImpl.hpp,v 1.2 2007/07/09 17:04:02 etphipp Exp $ 
00002 // $Source: /space/CVS/Trilinos/packages/sacado/example/FEApp/FEApp_BrusselatorNodeBCStrategyImpl.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 #include "FEApp_BrusselatorParameters.hpp"
00033 
00034 template <typename ScalarT>
00035 FEApp::BrusselatorNodeBCStrategy<ScalarT>::
00036 BrusselatorNodeBCStrategy(
00037        const ScalarT& alpha_, const ScalarT& beta_,
00038        const Teuchos::RCP<Sacado::ScalarParameterLibrary>& paramLib) :
00039   alpha(alpha_),
00040   beta(beta_),
00041   offsets(2),
00042   pl(paramLib)
00043 {
00044   offsets[0] = 0;
00045   offsets[1] = 1;
00046 
00047   // Add "alpha" to parameter library
00048   std::string name = "Brusselator Alpha";
00049   if (!pl->isParameter(name))
00050     pl->addParameterFamily(name, true, false);
00051   if (!pl->template isParameterForType<ScalarT>(name)) {
00052     Teuchos::RCP< BrusselatorAlphaParameter<ScalarT> > tmpa = 
00053       Teuchos::rcp(new BrusselatorAlphaParameter<ScalarT>(alpha));
00054     pl->template addEntry<ScalarT>(name, tmpa);
00055   }
00056 
00057   // Add "beta" to parameter library
00058   name = "Brusselator Beta";
00059   if (!pl->isParameter(name))
00060     pl->addParameterFamily(name, true, false);
00061   if (!pl->template isParameterForType<ScalarT>(name)) {
00062     Teuchos::RCP< BrusselatorBetaParameter<ScalarT> > tmpb = 
00063       Teuchos::rcp(new BrusselatorBetaParameter<ScalarT>(beta));
00064     pl->template addEntry<ScalarT>(name, tmpb);
00065   }
00066 }
00067 
00068 template <typename ScalarT>
00069 FEApp::BrusselatorNodeBCStrategy<ScalarT>::
00070 ~BrusselatorNodeBCStrategy()
00071 {
00072 }
00073 
00074 template <typename ScalarT>
00075 const std::vector<unsigned int>&
00076 FEApp::BrusselatorNodeBCStrategy<ScalarT>::
00077 getOffsets() const
00078 {
00079   return offsets;
00080 }
00081 
00082 template <typename ScalarT>
00083 void
00084 FEApp::BrusselatorNodeBCStrategy<ScalarT>::
00085 evaluateResidual(const std::vector<ScalarT>* dot,
00086      const std::vector<ScalarT>& solution,
00087      std::vector<ScalarT>& residual) const
00088 {
00089   alpha = pl->template getValue<ScalarT>("Brusselator Alpha");
00090   beta = pl->template getValue<ScalarT>("Brusselator Beta");
00091 
00092   residual[0] = solution[0] - alpha;
00093   residual[1] = solution[1] - beta/alpha;
00094 }

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