TSF_NVector.hpp
Go to the documentation of this file.
00001 /* ***********************************************************************
00002 // 
00003 //           TSFExtended: Trilinos Solver Framework Extended
00004 //                 Copyright (2004) Sandia Corporation
00005 // 
00006 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00007 // license for use of this work by or on behalf of the U.S. Government.
00008 // 
00009 // This library is free software; you can redistribute it and/or modify
00010 // it under the terms of the GNU Lesser General Public License as
00011 // published by the Free Software Foundation; either version 2.1 of the
00012 // License, or (at your option) any later version.
00013 //  
00014 // This library is distributed in the hope that it will be useful, but
00015 // WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 // Lesser General Public License for more details.
00018 //  
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022 // USA
00023 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00024 // 
00025 // **********************************************************************/
00026 
00027 #ifndef TSF_NVECTOR_HPP
00028 #define TSF_NVECTOR_HPP
00029 
00030 #include "SundanceDefs.hpp"
00031 #include "TSFVectorDecl.hpp"
00032 #include "TSFVectorSpaceDecl.hpp"
00033 
00034 #ifdef HAVE_SUNDIALS
00035 #include "nvector.h"
00036 #include "sundialstypes.h"
00037 
00038  /*
00039   * TSF implementation of SUNDIALS NVector interface
00040   */
00041 
00042 class _TrilinosVectorContent
00043 {
00044 public:
00045   _TrilinosVectorContent() : data() {;}
00046   TSFExtended::Vector<realtype> data;
00047 };
00048 
00049 typedef struct _TrilinosVectorContent* TrilinosVectorContent;
00050 
00051 
00052 extern "C"
00053 {
00054 
00055 #define NV_CONTENT_Trilinos(v)  ( (TrilinosVectorContent)(v->content) );
00056 
00057   /*
00058    *
00059    */
00060   inline Vector<realtype>& toTrilinos(N_Vector x)
00061   {
00062     TrilinosVectorContent xPtr = reinterpret_cast<TrilinosVectorContent>(x->content);
00063 
00064     return xPtr->data;
00065   }
00066 
00067   /*
00068    * -----------------------------------------------------------------
00069    * Function : N_VNew_Serial
00070    * -----------------------------------------------------------------
00071    * This function creates and allocates memory for a serial vector.
00072    * -----------------------------------------------------------------
00073    */
00074 
00075   N_Vector N_VNew_Trilinos(const VectorSpace<realtype>& space);
00076 
00077   /*
00078    * -----------------------------------------------------------------
00079    * Function : N_VPrint_Trilinos
00080    * -----------------------------------------------------------------
00081    * This function prints the content of a Trilinos vector to stdout.
00082    * -----------------------------------------------------------------
00083    */
00084 
00085   void N_VPrint_Trilinos(N_Vector v);
00086 
00087   /*
00088    * -----------------------------------------------------------------
00089    * Trilinos implementations of various useful vector operations
00090    * -----------------------------------------------------------------
00091    */
00092 
00093   N_Vector N_VCloneEmpty_Trilinos(N_Vector w);
00094   N_Vector N_VClone_Trilinos(N_Vector w);
00095   void N_VDestroy_Trilinos(N_Vector v);
00096   void N_VSpace_Trilinos(N_Vector v, long int *lrw, long int *liw);
00097   realtype *N_VGetArrayPointer_Trilinos(N_Vector v);
00098   void N_VSetArrayPointer_Trilinos(realtype *v_data, N_Vector v);
00099   void N_VLinearSum_Trilinos(realtype a, N_Vector x, realtype b, 
00100                              N_Vector y, N_Vector z);
00101   void N_VConst_Trilinos(realtype c, N_Vector z);
00102   void N_VProd_Trilinos(N_Vector x, N_Vector y, N_Vector z);
00103   void N_VDiv_Trilinos(N_Vector x, N_Vector y, N_Vector z);
00104   void N_VScale_Trilinos(realtype c, N_Vector x, N_Vector z);
00105   void N_VAbs_Trilinos(N_Vector x, N_Vector z);
00106   void N_VInv_Trilinos(N_Vector x, N_Vector z);
00107   void N_VAddConst_Trilinos(N_Vector x, realtype b, N_Vector z);
00108   realtype N_VDotProd_Trilinos(N_Vector x, N_Vector y);
00109   realtype N_VMaxNorm_Trilinos(N_Vector x);
00110   realtype N_VWrmsNorm_Trilinos(N_Vector x, N_Vector w);
00111   realtype N_VWrmsNormMask_Trilinos(N_Vector x, N_Vector w, N_Vector id);
00112   realtype N_VMin_Trilinos(N_Vector x);
00113   realtype N_VWL2Norm_Trilinos(N_Vector x, N_Vector w);
00114   realtype N_VL1Norm_Trilinos(N_Vector x);
00115   void N_VCompare_Trilinos(realtype c, N_Vector x, N_Vector z);
00116   booleantype N_VInvTest_Trilinos(N_Vector x, N_Vector z);
00117   booleantype N_VConstrMask_Trilinos(N_Vector c, N_Vector x, N_Vector m);
00118   realtype N_VMinQuotient_Trilinos(N_Vector num, N_Vector denom);
00119 }
00120   
00121 #endif // HAVE_SUNDIALS
00122 
00123 #endif

Site Contact