FEApp_GlobalFillImpl.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::GlobalFill<EvalT>::
00034 GlobalFill(
00035       const Teuchos::RCP<const FEApp::Mesh>& elementMesh,
00036       const Teuchos::RCP<const FEApp::AbstractQuadrature>& quadRule,
00037       const Teuchos::RCP< FEApp::AbstractPDE<EvalT> >& pdeEquations,
00038       const std::vector< Teuchos::RCP<FEApp::NodeBC> >& nodeBCs,
00039       bool is_transient):
00040   mesh(elementMesh),
00041   quad(quadRule),
00042   pde(pdeEquations),
00043   bc(nodeBCs),
00044   transient(is_transient),
00045   nnode(0),
00046   neqn(pde->numEquations()),
00047   ndof(0),
00048   elem_x(),
00049   elem_xdot(NULL),
00050   elem_f(),
00051   node_x(),
00052   node_xdot(NULL),
00053   node_f()
00054 {
00055   Teuchos::RCP<const FEApp::AbstractElement> e0 = *(mesh->begin());
00056   nnode = e0->numNodes();
00057   ndof = nnode*neqn;
00058   elem_x.resize(ndof);
00059   if (transient)
00060     elem_xdot = new std::vector<ScalarT>(ndof);
00061   elem_f.resize(ndof);
00062 
00063   node_x.resize(neqn);
00064   if (transient)
00065     node_xdot = new std::vector<ScalarT>(neqn);
00066   node_f.resize(neqn);
00067 }
00068 
00069 template <typename EvalT>
00070 FEApp::GlobalFill<EvalT>::
00071 ~GlobalFill()
00072 {
00073   if (transient) {
00074     delete elem_xdot;
00075     delete node_xdot;
00076   }
00077 }
00078 
00079 template <typename EvalT>
00080 void
00081 FEApp::GlobalFill<EvalT>::
00082 computeGlobalFill(FEApp::AbstractInitPostOp<EvalT>& initPostOp)
00083 {
00084   // Loop over elements
00085   Teuchos::RCP<const FEApp::AbstractElement> e;
00086   for (FEApp::Mesh::const_iterator eit=mesh->begin(); eit!=mesh->end(); ++eit){
00087     e = *eit;
00088 
00089     // Zero out element residual
00090     for (unsigned int i=0; i<ndof; i++)
00091       elem_f[i] = 0.0;
00092 
00093     // Initialize element solution
00094     initPostOp.elementInit(*e, neqn, elem_xdot, elem_x);
00095 
00096     // Compute element residual
00097     pde->evaluateElementResidual(*quad, *e, elem_xdot, elem_x, elem_f);
00098 
00099     // Post-process element residual
00100     initPostOp.elementPost(*e, neqn, elem_f);
00101 
00102   }
00103 
00104   // Loop over boundary conditions
00105   for (std::size_t i=0; i<bc.size(); i++) {
00106 
00107     if (bc[i]->isOwned() || bc[i]->isShared()) {
00108 
00109       // Zero out node residual
00110       for (unsigned int j=0; j<neqn; j++)
00111         node_f[j] = 0.0;
00112 
00113       // Initialize node solution
00114       initPostOp.nodeInit(*bc[i], neqn, node_xdot, node_x);
00115 
00116       // Compute node residual
00117       bc[i]->getStrategy<EvalT>()->evaluateResidual(node_xdot, node_x, 
00118                                                     node_f);
00119 
00120       // Post-process node residual
00121       initPostOp.nodePost(*bc[i], neqn, node_f);
00122 
00123     }
00124     
00125   }
00126 
00127   // Finalize fill
00128   initPostOp.finalizeFill();
00129 
00130 }

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