9 #ifndef Tempus_RKButcherTableau_hpp
10 #define Tempus_RKButcherTableau_hpp
14 #pragma clang system_header
19 #include "Teuchos_Assert.hpp"
20 #include "Teuchos_as.hpp"
21 #include "Teuchos_Describable.hpp"
22 #include "Teuchos_VerboseObject.hpp"
23 #include "Teuchos_VerboseObjectParameterListHelpers.hpp"
24 #include "Teuchos_SerialDenseMatrix.hpp"
25 #include "Teuchos_SerialDenseVector.hpp"
26 #include "Thyra_MultiVectorStdOps.hpp"
49 template<
class Scalar>
51 virtual public Teuchos::Describable,
52 virtual public Teuchos::VerboseObject<RKButcherTableau<Scalar> >
57 std::string stepperType,
58 const Teuchos::SerialDenseMatrix<int,Scalar>&
A,
59 const Teuchos::SerialDenseVector<int,Scalar>&
b,
60 const Teuchos::SerialDenseVector<int,Scalar>&
c,
64 const Teuchos::SerialDenseVector<int,Scalar>&
65 bstar = Teuchos::SerialDenseVector<int,Scalar>(),
70 TEUCHOS_ASSERT_EQUALITY( A.numCols(),
numStages );
71 TEUCHOS_ASSERT_EQUALITY( b.length(),
numStages );
72 TEUCHOS_ASSERT_EQUALITY( c.length(),
numStages );
73 TEUCHOS_ASSERT( order > 0 );
84 typedef Teuchos::ScalarTraits<Scalar> ST;
85 Scalar sumb = ST::zero();
86 for (
size_t i = 0; i < this->
numStages(); i++) sumb +=
b_(i);
87 TEUCHOS_TEST_FOR_EXCEPTION( std::abs(ST::one()-sumb) > 1.0e-08,
89 "Error - Butcher Tableau b fails to satisfy Sum(b_i) = 1.\n"
90 <<
" Sum(b_i) = " << sumb <<
"\n");
94 for (
size_t i = 0; i < this->
numStages(); i++) {
95 Scalar sumai = ST::zero();
96 for (
size_t j = 0; j < this->
numStages(); j++) sumai +=
A_(i,j);
98 if (std::abs(sumai) > 1.0e-08)
99 failed = (std::abs((sumai-
c_(i))/sumai) > 1.0e-08);
101 failed = (std::abs(
c_(i)) > 1.0e-08);
103 TEUCHOS_TEST_FOR_EXCEPTION( failed, std::runtime_error,
104 "Error - Butcher Tableau fails to satisfy c_i = Sum_j(a_ij).\n"
105 <<
" Stage i = " << i <<
"\n"
106 <<
" c_i = " <<
c_(i) <<
"\n"
107 <<
" Sum_j(a_ij) = " << sumai <<
"\n"
108 <<
" This may be OK as some valid tableaus do not satisfy\n"
109 <<
" this condition. If so, construct this RKButcherTableau\n"
110 <<
" with checkC = false.\n");
114 if (
bstar.length() > 0 ) {
126 virtual const Teuchos::SerialDenseMatrix<int,Scalar>&
A()
const
129 virtual const Teuchos::SerialDenseVector<int,Scalar>&
b()
const
132 virtual const Teuchos::SerialDenseVector<int,Scalar>&
bstar()
const
135 virtual const Teuchos::SerialDenseVector<int,Scalar>&
c()
const
155 const Teuchos::EVerbosityLevel verbLevel)
const
157 if (verbLevel != Teuchos::VERB_NONE) {
159 out <<
"number of Stages = " << this->
numStages() << std::endl;
160 out <<
"A = " << printMat(this->
A()) << std::endl;
161 out <<
"b = " << printMat(this->
b()) << std::endl;
162 out <<
"c = " << printMat(this->
c()) << std::endl;
163 out <<
"bstar = " << printMat(this->
bstar()) << std::endl;
164 out <<
"order = " << this->
order() << std::endl;
165 out <<
"orderMin = " << this->
orderMin() << std::endl;
166 out <<
"orderMax = " << this->
orderMax() << std::endl;
167 out <<
"isImplicit = " << this->
isImplicit() << std::endl;
168 out <<
"isDIRK = " << this->
isDIRK() << std::endl;
169 out <<
"isEmbedded = " << this->
isEmbedded() << std::endl;
182 for (
size_t i = 0; i < this->
numStages(); i++)
183 for (
size_t j = i; j < this->
numStages(); j++)
190 bool nonZero =
false;
191 for (
size_t i = 0; i < this->
numStages(); i++) {
192 if (
A_(i,i) != 0.0) nonZero =
true;
193 for (
size_t j = i+1; j < this->
numStages(); j++)
196 if (nonZero ==
false)
isDIRK_ =
false;
201 Teuchos::SerialDenseMatrix<int,Scalar>
A_;
202 Teuchos::SerialDenseVector<int,Scalar>
b_;
203 Teuchos::SerialDenseVector<int,Scalar>
c_;
210 Teuchos::SerialDenseVector<int,Scalar>
bstar_;
217 #endif // Tempus_RKButcherTableau_hpp
Teuchos::SerialDenseMatrix< int, Scalar > A_
virtual const Teuchos::SerialDenseVector< int, Scalar > & b() const
Return the vector of quadrature weights.
virtual const Teuchos::SerialDenseVector< int, Scalar > & c() const
Return the vector of stage positions.
RKButcherTableau(std::string stepperType, const Teuchos::SerialDenseMatrix< int, Scalar > &A, const Teuchos::SerialDenseVector< int, Scalar > &b, const Teuchos::SerialDenseVector< int, Scalar > &c, const int order, const int orderMin, const int orderMax, const Teuchos::SerialDenseVector< int, Scalar > &bstar=Teuchos::SerialDenseVector< int, Scalar >(), bool checkC=true)
virtual const Teuchos::SerialDenseVector< int, Scalar > & bstar() const
Return the vector of quadrature weights for embedded methods.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
Teuchos::SerialDenseVector< int, Scalar > bstar_
virtual bool isImplicit() const
Return true if the RK method is implicit.
virtual bool isEmbedded() const
Return true if the RK method has embedded capabilities.
virtual bool isDIRK() const
Return true if the RK method is Diagonally Implicit.
virtual int orderMax() const
Return the maximum order.
void set_isDIRK()
DIRK is defined as if a_ij = 0 for j>i and a_ii != 0 for at least one i.
Teuchos::SerialDenseVector< int, Scalar > b_
virtual std::string description() const
virtual std::size_t numStages() const
Return the number of stages.
Teuchos::SerialDenseVector< int, Scalar > c_
virtual const Teuchos::SerialDenseMatrix< int, Scalar > & A() const
Return the matrix coefficients.
virtual int order() const
Return the order.
virtual int orderMin() const
Return the minimum order.