FEApp_HeatNonlinearSourcePDEImpl.hpp

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

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