|
Rythmos - Transient Integration for Differential Equations
Version of the Day
|
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00023 // USA 00024 // Questions? Contact Todd S. Coffey (tscoffe@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 //@HEADER 00028 00029 00030 #ifndef RYTHMOS_RK_BUTCHER_TABLEAU_BASE_HPP 00031 #define RYTHMOS_RK_BUTCHER_TABLEAU_BASE_HPP 00032 00033 #include "Rythmos_Types.hpp" 00034 #include "Teuchos_Describable.hpp" 00035 #include "Teuchos_ParameterListAcceptor.hpp" 00036 #include "Teuchos_VerboseObject.hpp" 00037 #include "Teuchos_SerialDenseMatrix.hpp" 00038 #include "Teuchos_SerialDenseVector.hpp" 00039 00040 namespace Rythmos { 00041 00042 /* \brief . */ 00043 template<class Scalar> 00044 class RKButcherTableauBase : 00045 virtual public Teuchos::Describable, 00046 virtual public Teuchos::ParameterListAcceptor, 00047 virtual public Teuchos::VerboseObject<RKButcherTableauBase<Scalar> > 00048 { 00049 public: 00051 virtual int numStages() const = 0; 00053 virtual const Teuchos::SerialDenseMatrix<int,Scalar>& A() const = 0; 00055 virtual const Teuchos::SerialDenseVector<int,Scalar>& b() const = 0; 00057 virtual const Teuchos::SerialDenseVector<int,Scalar>& c() const = 0; 00059 virtual int order() const = 0; 00061 virtual bool operator== (const RKButcherTableauBase<Scalar>& rkbt) const; 00063 virtual void setDescription(std::string longDescription) = 0; 00064 }; 00065 00066 00067 /* \brief . */ 00068 template<class Scalar> 00069 bool RKButcherTableauBase<Scalar>::operator== (const RKButcherTableauBase<Scalar>& rkbt) const 00070 { 00071 if (this->numStages() != rkbt.numStages()) { 00072 return false; 00073 } 00074 if (this->order() != rkbt.order()) { 00075 return false; 00076 } 00077 int N = rkbt.numStages(); 00078 // Check b and c first: 00079 const Teuchos::SerialDenseVector<int,Scalar> b_ = this->b(); 00080 const Teuchos::SerialDenseVector<int,Scalar> c_ = this->c(); 00081 const Teuchos::SerialDenseVector<int,Scalar> other_b = rkbt.b(); 00082 const Teuchos::SerialDenseVector<int,Scalar> other_c = rkbt.c(); 00083 for (int i=0 ; i<N ; ++i) { 00084 if (b_(i) != other_b(i)) { 00085 return false; 00086 } 00087 if (c_(i) != other_c(i)) { 00088 return false; 00089 } 00090 } 00091 // Then check A: 00092 const Teuchos::SerialDenseMatrix<int,Scalar>& A_ = this->A(); 00093 const Teuchos::SerialDenseMatrix<int,Scalar>& other_A = rkbt.A(); 00094 for (int i=0 ; i<N ; ++i) { 00095 for (int j=0 ; j<N ; ++j) { 00096 if (A_(i,j) != other_A(i,j)) { 00097 return false; 00098 } 00099 } 00100 } 00101 return true; 00102 } 00103 00104 } // namespace Rythmos 00105 00106 00107 #endif // RYTHMOS_RK_BUTCHER_TABLEAU_BASE_HPP
1.7.6.1