FEApp_HeatNonlinearSourcePDEImpl.hpp

Go to the documentation of this file.
00001 // $Id: FEApp_HeatNonlinearSourcePDEImpl.hpp,v 1.5 2008/08/01 22:57:12 etphipp Exp $ 
00002 // $Source: /space/CVS/Trilinos/packages/sacado/example/FEApp/FEApp_HeatNonlinearSourcePDEImpl.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 template <typename ScalarT>
00033 FEApp::HeatNonlinearSourcePDE<ScalarT>::
00034 HeatNonlinearSourcePDE(const Teuchos::RCP< const FEApp::AbstractFunction<ScalarT> >& mat_func,
00035            const Teuchos::RCP< const FEApp::AbstractSourceFunction<ScalarT> >& src_func) :
00036   mat(mat_func),
00037   source(src_func),
00038   num_qp(0),
00039   num_nodes(0),
00040   phi(),
00041   dphi(),
00042   jac(),
00043   u(),
00044   du(),
00045   udot(),
00046   a(),
00047   f()
00048 {
00049 }
00050 
00051 template <typename ScalarT>
00052 FEApp::HeatNonlinearSourcePDE<ScalarT>::
00053 ~HeatNonlinearSourcePDE()
00054 {
00055 }
00056 
00057 template <typename ScalarT>
00058 unsigned int 
00059 FEApp::HeatNonlinearSourcePDE<ScalarT>::
00060 numEquations() const
00061 {
00062   return 1;
00063 }
00064 
00065 template <typename ScalarT>
00066 void
00067 FEApp::HeatNonlinearSourcePDE<ScalarT>::
00068 init(unsigned int numQuadPoints, unsigned int numNodes)
00069 {
00070   num_qp = numQuadPoints;
00071   num_nodes = numNodes;
00072 
00073   phi.resize(num_qp);
00074   dphi.resize(num_qp);
00075   jac.resize(num_qp);
00076   u.resize(num_qp);
00077   du.resize(num_qp);
00078   udot.resize(num_qp);
00079   a.resize(num_qp);
00080   f.resize(num_qp);
00081 
00082   for (unsigned int i=0; i<num_qp; i++) {
00083     phi[i].resize(num_nodes);
00084     dphi[i].resize(num_nodes);
00085   }
00086 }
00087 
00088 template <typename ScalarT>
00089 void
00090 FEApp::HeatNonlinearSourcePDE<ScalarT>::
00091 evaluateElementResidual(const FEApp::AbstractQuadrature& quadRule,
00092       const FEApp::AbstractElement& element,
00093       const std::vector<ScalarT>* dot,
00094       const std::vector<ScalarT>& solution,
00095       std::vector<ScalarT>& residual)
00096  {
00097   
00098   // Quadrature points
00099   const std::vector<double>& xi = quadRule.quadPoints();
00100 
00101   // Weights
00102   const std::vector<double>& w = quadRule.weights();
00103 
00104   // Evaluate shape functions
00105   element.evaluateShapes(xi, phi);
00106 
00107   // Evaluate shape function derivatives
00108   element.evaluateShapeDerivs(xi, dphi);
00109 
00110   // Evaluate Jacobian of transformation to standard element
00111   element.evaluateJacobian(xi, jac);
00112 
00113   // Evaluate material values
00114   mat->evaluate(xi, a);
00115 
00116   // Compute u
00117   for (unsigned int qp=0; qp<num_qp; qp++) {
00118     u[qp] = 0.0;
00119     du[qp] = 0.0;
00120     udot[qp] = 0.0;
00121     for (unsigned int node=0; node<num_nodes; node++) {
00122       u[qp] += solution[node] * phi[qp][node];
00123       du[qp] += solution[node] * dphi[qp][node];
00124       if (dot != NULL)
00125   udot[qp] += (*dot)[node] * phi[qp][node];
00126     }
00127   }
00128 
00129   // Evaluate source function
00130   source->evaluate(u, f);
00131 
00132   // Evaluate residual
00133   for (unsigned int node=0; node<num_nodes; node++) {
00134     residual[node] = 0.0;
00135     for (unsigned int qp=0; qp<num_qp; qp++) {
00136       residual[node] += 
00137   w[qp]*jac[qp]*(-(1.0/(jac[qp]*jac[qp]))*a[qp]*du[qp]*dphi[qp][node] + 
00138            phi[qp][node]*(f[qp] - udot[qp]));
00139     }
00140   }
00141 
00142 }

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