# basis.cc

Go to the documentation of this file.
```00001 //@HEADER
00002 /*
00003 ************************************************************************
00004
00005               Epetra: Linear Algebra Services Package
00007
00008 Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00009 license for use of this work by or on behalf of the U.S. Government.
00010
00011 This library is free software; you can redistribute it and/or modify
00012 it under the terms of the GNU Lesser General Public License as
00013 published by the Free Software Foundation; either version 2.1 of the
00015
00016 This library is distributed in the hope that it will be useful, but
00017 WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 Lesser General Public License for more details.
00020
00021 You should have received a copy of the GNU Lesser General Public
00022 License along with this library; if not, write to the Free Software
00023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 USA
00025 Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00026
00027 ************************************************************************
00028 */
00030
00031 #include<iostream.h>
00032 #include<math.h>
00033 #include "basis.h"
00034
00035 // Constructor
00036 Basis::Basis() {
00037   phi = new double[2];
00038   dphide = new double[2];
00039 }
00040
00041 // Destructor
00042 Basis::~Basis() {
00043   delete [] phi;
00044   delete [] dphide;
00045 }
00046
00047 // Calculates a linear 1D basis
00048 void Basis::getBasis(int gp, double *x, double *u) {
00049   int N = 2;
00050   if (gp==0) {eta=-sqrt(3)/sqrt(5); wt=5.0/9.0;}
00051   if (gp==1) {eta=0.0; wt=8.0/9.0;}
00052   if (gp==2) {eta=sqrt(3)/sqrt(5); wt=5.0/9.0;}
00053
00054   // Calculate basis function and derivatives at nodel pts
00055   phi[0]=(1.0-eta)/2.0;
00056   phi[1]=(1.0+eta)/2.0;
00057   dphide[0]=-0.5;
00058   dphide[1]=0.5;
00059
00060   // Caculate basis function and derivative at GP.
00061   dx=x[1]-x[0];
00062   xx=0.0;
00063   uu=0.0;
00064   duu=0.0;
00065   for (int i=0; i < N; i++) {
00066     xx += x[i] * phi[i];
00067     uu += u[i] * phi[i];
00068     duu += u[i] * dphide[i];
00069   }
00070
00071   return;
00072 }
```

Generated on Thu Sep 18 12:37:56 2008 for Epetra Package Browser (Single Doxygen Collection) by  1.3.9.1