1DfemInterface.H

Go to the documentation of this file.
00001 //@HEADER
00002 // ***********************************************************************
00003 //
00004 //                     Rythmos Package
00005 //                 Copyright (2006) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Todd S. Coffey (tscoffe@sandia.gov)
00025 //
00026 // ***********************************************************************
00027 //@HEADER
00028                                                                                 
00029 // Finite Element Problem Class
00030 /* Provides function (F) and Jacobian evaluations for the following equation 
00031  * via a 1D linear finite element discretization with Epetra objects.
00032  *
00033  * d2u 
00034  * --- - k * u**2 = 0
00035  * dx2
00036  *
00037  * subject to @ x=0, u=1
00038  */
00039 
00040 #ifndef TEST_EPETRA_1DFEM_INTERFACE_EPETRANEW_H
00041 #define TEST_EPETRA_1DFEM_INTERFACE_EPETRANEW_H
00042 
00043 #include "NOX_Epetra_Interface_Required.H" // base class
00044 #include "NOX_Epetra_Interface_Jacobian.H" // base class
00045 #include "NOX_Epetra_Interface_Preconditioner.H" // base class
00046 
00047 // Forward Declarations
00048 class Epetra_Comm;
00049 class Epetra_Map; 
00050 class Epetra_Vector;
00051 class Epetra_Import;
00052 class Epetra_Operator;
00053 class Epetra_CrsGraph;
00054 class Epetra_RowMatrix;
00055 class Epetra_CrsMatrix;
00056 namespace NOX {
00057   namespace Parameter {
00058     class List;
00059   }
00060 }
00061 
00062 // Finite Element Problem Class
00063 class Interface : public NOX::Epetra::Interface::Required,
00064       public NOX::Epetra::Interface::Jacobian,
00065       public NOX::Epetra::Interface::Preconditioner { 
00066 
00067 public:
00068 
00069   // Constructor
00070   Interface(int NumGlobalElements, Epetra_Comm& Comm, double xmin = 0.0,
00071             double xmax = 1.0 );
00072   
00073   // Destructor
00074   virtual ~Interface();
00075 
00076   virtual bool computeF(const Epetra_Vector& x, Epetra_Vector& FVec, 
00077     FillType fillType = Residual);
00078   virtual bool computeJacobian(const Epetra_Vector& x, Epetra_Operator& Jac);
00079   virtual bool computePrecMatrix(const Epetra_Vector& x);
00080   virtual bool computePreconditioner(const Epetra_Vector& x,
00081              Epetra_Operator& Prec,
00082              Teuchos::ParameterList* precParams = 0);
00083 
00084 
00085   // Return a reference to the Epetra_Vector with the initial guess
00086   // that is generated by the Interface class.
00087   Epetra_Vector& getSolution();
00088   
00089   // Return a reference to the Epetra_Vector holding the mesh data
00090   Epetra_Vector& getMesh();
00091   
00092   // Return a reference to the Epetra_CrsMatrix with the Jacobian
00093   // that is generated by the Interface class.
00094   Epetra_CrsMatrix& getJacobian();
00095 
00096   // Set PDE factor
00097   bool setPDEfactor(double value) { factor = value; return true; };
00098 
00099   // Return a reference to the Epetra_Map used for the Solution Epetra_Vector
00100   Epetra_Map& getMap();
00101   
00102   // Return a reference to the Epetra_Graph used for the Jacobian
00103   Epetra_CrsGraph& getGraph();
00104 
00105 protected:
00106 
00107   // Evaluates the function (F) and/or the Jacobian using the solution 
00108   // values in solnVector.
00109   virtual bool evaluate(FillType f, const Epetra_Vector *solnVector, 
00110     Epetra_Vector *rhsVector, Epetra_RowMatrix *matrix);
00111 
00112   // Inserts the global column indices into the Graph
00113   virtual bool createGraph();
00114 
00115   // Set initial condition for solution vector
00116   virtual bool initializeSoln();
00117 
00118 protected:
00119 
00120   enum TargetObjectType {FUNCTION, JACOBIAN};
00121 
00122   int NumGlobalElements;  // Total Number of elements
00123   int NumMyElements;      // Number of elements owned by this process
00124   int MyPID;              // Process number
00125   int NumProc;            // Total number of processes
00126 
00127   double xmin;
00128   double xmax;
00129   double factor;    // PDE factor
00130 
00131   Epetra_Comm* Comm;
00132   Epetra_Map* StandardMap; 
00133   Epetra_Map* OverlapMap;
00134   Epetra_Import* Importer;
00135   Epetra_Vector* initialSolution;
00136   Epetra_Vector* rhs;
00137   Epetra_CrsGraph* Graph;
00138   Epetra_CrsMatrix* jacobian;
00139   Epetra_Vector* xptr;
00140 
00141 };
00142 
00143 //==================================================================
00144 // Finite Element Basis Object
00145 class Basis {
00146 
00147  public:
00148   // Constructor
00149   Basis();
00150 
00151   // Destructor
00152   ~Basis();
00153 
00154   // Calculates the values of u and x at the specified gauss point
00155   void computeBasis(int gp, double *x, double *u, double *uold = 0);
00156 
00157  public:
00158   // Variables that are calculated at the gauss point
00159   double *phi, *dphide; 
00160   double uu, xx, duu, eta, wt;
00161   double dx;
00162   // These are only needed for transient
00163   double uuold, duuold;
00164 };
00165 
00166 #endif
00167 
00168 
00169 
00170 

Generated on Thu Sep 18 12:30:04 2008 for Rythmos - Transient Integration for Differential Equations by doxygen 1.3.9.1