FEApp_LinearElement.cpp

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 #include "FEApp_LinearElement.hpp"
00033 
00034 FEApp::LinearElement::
00035 LinearElement() :
00036   xl(0.0),
00037   xr(0.0),
00038   left_GID(0),
00039   right_GID(0)
00040 {
00041 }
00042 
00043 FEApp::LinearElement::
00044 ~LinearElement()
00045 {
00046 }
00047 
00048 unsigned int
00049 FEApp::LinearElement::
00050 numNodes() const
00051 {
00052   return 2;
00053 }
00054 
00055 void
00056 FEApp::LinearElement::
00057 createNodes(double x_left, double x_right, unsigned int first_node_gid)
00058 {
00059   xl = x_left;
00060   xr = x_right;
00061   left_GID = first_node_gid;
00062   right_GID = first_node_gid+1;
00063 }
00064 
00065 unsigned int
00066 FEApp::LinearElement::
00067 nodeGID(unsigned int i) const 
00068 {
00069   if (i == 0)
00070     return left_GID;
00071   else
00072     return right_GID;
00073 }
00074 
00075 void
00076 FEApp::LinearElement::
00077 evaluateShapes(const std::vector<double>& xi,
00078          std::vector< std::vector<double> >& phi) const
00079 {
00080   for (unsigned int i=0; i<xi.size(); i++) {
00081     if (phi[i].size() < 2)
00082       phi[i].resize(2);
00083 
00084     phi[i][0] = 0.5 * (1.0 - xi[i]);
00085     phi[i][1] = 0.5 * (1.0 + xi[i]);
00086   }
00087 }
00088 
00089 void
00090 FEApp::LinearElement::
00091 evaluateShapeDerivs(const std::vector<double>& xi,
00092         std::vector< std::vector<double> >& dphidxi) const
00093 {
00094   for (unsigned int i=0; i<xi.size(); i++) {
00095     if (dphidxi[i].size() < 2)
00096       dphidxi[i].resize(2);
00097 
00098     dphidxi[i][0] = -0.5;
00099     dphidxi[i][1] =  0.5;
00100   }
00101 }
00102 
00103 void
00104 FEApp::LinearElement::
00105 evaluateJacobian(const std::vector<double>& xi, std::vector<double>& jac) const
00106 {
00107   double j = 0.5 * (xr-xl);
00108   for (unsigned int i=0; i<xi.size(); i++)
00109     jac[i] = j;
00110 }

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