FEApp_HeatNonlinearSourcePDEImpl.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 template <typename EvalT>
00033 FEApp::HeatNonlinearSourcePDE<EvalT>::
00034 HeatNonlinearSourcePDE(
00035   const Teuchos::RCP< const FEApp::AbstractFunction<EvalT> >& mat_func,
00036   const Teuchos::RCP< const FEApp::AbstractSourceFunction<EvalT> >& src_func) :
00037   mat(mat_func),
00038   source(src_func),
00039   num_qp(0),
00040   num_nodes(0),
00041   phi(),
00042   dphi(),
00043   jac(),
00044   u(),
00045   du(),
00046   udot(),
00047   a(),
00048   f()
00049 {
00050 }
00051 
00052 template <typename EvalT>
00053 FEApp::HeatNonlinearSourcePDE<EvalT>::
00054 ~HeatNonlinearSourcePDE()
00055 {
00056 }
00057 
00058 template <typename EvalT>
00059 unsigned int 
00060 FEApp::HeatNonlinearSourcePDE<EvalT>::
00061 numEquations() const
00062 {
00063   return 1;
00064 }
00065 
00066 template <typename EvalT>
00067 void
00068 FEApp::HeatNonlinearSourcePDE<EvalT>::
00069 init(unsigned int numQuadPoints, unsigned int numNodes)
00070 {
00071   num_qp = numQuadPoints;
00072   num_nodes = numNodes;
00073 
00074   phi.resize(num_qp);
00075   dphi.resize(num_qp);
00076   jac.resize(num_qp);
00077   u.resize(num_qp);
00078   du.resize(num_qp);
00079   udot.resize(num_qp);
00080   a.resize(num_qp);
00081   f.resize(num_qp);
00082 
00083   for (unsigned int i=0; i<num_qp; i++) {
00084     phi[i].resize(num_nodes);
00085     dphi[i].resize(num_nodes);
00086   }
00087 }
00088 
00089 template <typename EvalT>
00090 void
00091 FEApp::HeatNonlinearSourcePDE<EvalT>::
00092 evaluateElementResidual(const FEApp::AbstractQuadrature& quadRule,
00093                         const FEApp::AbstractElement& element,
00094                         const std::vector<ScalarT>* dot,
00095                         const std::vector<ScalarT>& solution,
00096                         std::vector<ScalarT>& residual)
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:39:33 2010 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.4.7