$extrastylesheet
sum_shell_matrix.C
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 
00020 // Local includes
00021 #include "libmesh/sum_shell_matrix.h"
00022 #include "libmesh/numeric_vector.h"
00023 
00024 namespace libMesh
00025 {
00026 
00027 template <typename T>
00028 numeric_index_type SumShellMatrix<T>::m () const
00029 {
00030   libmesh_assert(!matrices.empty());
00031   const numeric_index_type result = matrices[0]->m();
00032 #ifndef NDEBUG
00033   for(std::size_t i=matrices.size(); i-->1; )
00034     {
00035       libmesh_assert_equal_to (matrices[i]->m(), result);
00036     }
00037 #endif
00038   return result;
00039 }
00040 
00041 
00042 
00043 template <typename T>
00044 numeric_index_type SumShellMatrix<T>::n () const
00045 {
00046   libmesh_assert(!matrices.empty());
00047   const numeric_index_type result = matrices[0]->n();
00048 #ifndef NDEBUG
00049   for(std::size_t i=matrices.size(); i-->1; )
00050     {
00051       libmesh_assert_equal_to (matrices[i]->n(), result);
00052     }
00053 #endif
00054   return result;
00055 }
00056 
00057 
00058 
00059 template <typename T>
00060 void SumShellMatrix<T>::vector_mult (NumericVector<T>& dest,
00061                                      const NumericVector<T>& arg) const
00062 {
00063   dest.zero();
00064   this->vector_mult_add(dest,arg);
00065 }
00066 
00067 
00068 
00069 template <typename T>
00070 void SumShellMatrix<T>::vector_mult_add (NumericVector<T>& dest,
00071                                          const NumericVector<T>& arg) const
00072 {
00073   for(std::size_t i=matrices.size(); i-->0; )
00074     {
00075       matrices[i]->vector_mult_add(dest,arg);
00076     }
00077 }
00078 
00079 
00080 
00081 template <typename T>
00082 void SumShellMatrix<T>::get_diagonal (NumericVector<T>& dest) const
00083 {
00084   UniquePtr<NumericVector<T> > a = dest.clone();
00085   dest.zero();
00086   for(std::size_t i=matrices.size(); i-->0; )
00087     {
00088       matrices[i]->get_diagonal(*a);
00089       dest += *a;
00090     }
00091 }
00092 
00093 
00094 
00095 //------------------------------------------------------------------
00096 // Explicit instantiations
00097 template class SumShellMatrix<Number>;
00098 
00099 } // namespace libMesh