SundanceLocalMatrixContainer.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
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
00014 // License, or (at your option) any later version.
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 Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
00030 
00031 #ifndef SUNDANCE_LOCALMATRIXCONTAINER_H
00032 #define SUNDANCE_LOCALMATRIXCONTAINER_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceDOFMapBuilder.hpp"
00036 
00037 namespace Sundance
00038 {
00039 /** 
00040  * LocalMatrixContainer is a container for local matrix and vector values.
00041  * Local matrices and vectors are stored in identical ways: as 1D arrays
00042  * of doubles. toi
00043  *
00044  * Each integrator gets its own LocalMatrixContainer object, with information on
00045  * term grouping specific to the terms handled by that integrator. To conserve
00046  * memory, all LocalMatrixContainer objects share a common pool of data vectors. After 
00047  * insertion, the common pool can be reused in the next integration. It is the 
00048  * responsibility of the integrator to zero out and resize each data vector
00049  * as needed.
00050  *   
00051  * To leave the system as flexible as possible, this class does not specify
00052  * anything about the ordering of elements in the matrix. It is the
00053  * responsibility of the integrator and inserter classes to use a consistent
00054  * ordering. Different integrator-inserter combinations may well use different
00055  * orderings.
00056  *
00057  * It is often the case that several terms in a PDE will yield local 
00058  * matrices that have the same values, perhaps differing by a constant, 
00059  * but which are associated with different test and unknown functions. For this reason,
00060  * each batch of local matrix values has associated with it arrays
00061  * of (test, unk) pairs and coefficients.  
00062  */
00063 class LocalMatrixContainer
00064 {
00065 public:
00066   /** */
00067   LocalMatrixContainer(const Array<int>& isTwoForm,
00068     const Array<Array<int> >& testID,
00069     const Array<Array<int> >& unkID,
00070     const Array<Array<double> >& coeffs);
00071 
00072   /** Return the data vector for the i-th batch */
00073   const RCP<Array<double> >& dataVector(int i) const 
00074     {return workspace()[i];}
00075 
00076   /** Indicate whether the i-th batch is a two form */
00077   bool isTwoForm(int i) const {return isTwoForm_[i];}
00078 
00079   /** Return the array of testIDs whose local matrix values are grouped int
00080    * the i-th batch */
00081   const Array<int>& testID(int i) const {return testID_[i];}
00082 
00083   /** Return the array of unkIDs whose local matrix values are grouped int
00084    * the i-th batch */
00085   const Array<int>& unkID(int i) const {return unkID_[i];}
00086 
00087   /** Return the array of coefficients to be used with the i-th batch */
00088   const Array<double>& coeffs(int i) const {return coeffs_[i];}
00089 
00090 private:
00091       
00092   /** */
00093   static Array<RCP<Array<double> > >& workspace() 
00094     {static Array<RCP<Array<double> > > rtn; return rtn;}
00095 
00096   /** */
00097   Array<int> isTwoForm_;
00098 
00099   /** */
00100   Array<Array<int> > testID_;
00101 
00102   /** */
00103   Array<Array<int> > unkID_;
00104 
00105   /** */
00106   Array<Array<double> > coeffs_;
00107 };
00108 }
00109 
00110 
00111 
00112 #endif

Site Contact