10 #ifndef Tempus_RKButcherTableau_hpp
11 #define Tempus_RKButcherTableau_hpp
15 #pragma clang system_header
21 #include "Tempus_config.hpp"
43 template <
class Scalar>
74 Scalar sumb = ST::zero();
75 for (
size_t i = 0; i < this->
numStages(); i++) sumb +=
b_(i);
77 std::abs(ST::one() - sumb) > 1.0e-08, std::runtime_error,
78 "Error - Butcher Tableau b fails to satisfy Sum(b_i) = 1.\n"
79 <<
" Sum(b_i) = " << sumb <<
"\n");
83 for (
size_t i = 0; i < this->
numStages(); i++) {
84 Scalar sumai = ST::zero();
85 for (
size_t j = 0; j < this->
numStages(); j++) sumai +=
A_(i, j);
87 if (std::abs(sumai) > 1.0e-08)
88 failed = (std::abs((sumai -
c_(i)) / sumai) > 1.0e-08);
90 failed = (std::abs(
c_(i)) > 1.0e-08);
93 failed, std::runtime_error,
94 "Error - Butcher Tableau fails to satisfy c_i = Sum_j(a_ij).\n"
95 <<
" Stage i = " << i <<
"\n"
96 <<
" c_i = " <<
c_(i) <<
"\n"
97 <<
" Sum_j(a_ij) = " << sumai <<
"\n"
98 <<
" This may be OK as some valid tableaus do not satisfy\n"
99 <<
" this condition. If so, construct this RKButcherTableau\n"
100 <<
" with checkC = false.\n");
168 out <<
"number of Stages = " << this->
numStages() << std::endl;
169 out <<
"A = " <<
printMat(this->
A()) << std::endl;
170 out <<
"b = " <<
printMat(this->
b()) << std::endl;
171 out <<
"c = " <<
printMat(this->
c()) << std::endl;
173 out <<
"order = " << this->
order() << std::endl;
174 out <<
"orderMin = " << this->
orderMin() << std::endl;
175 out <<
"orderMax = " << this->
orderMax() << std::endl;
176 out <<
"isImplicit = " << this->
isImplicit() << std::endl;
177 out <<
"isDIRK = " << this->
isDIRK() << std::endl;
178 out <<
"isEmbedded = " << this->
isEmbedded() << std::endl;
180 out <<
"TVD Coeff = " << this->
getTVDCoeff() << std::endl;
187 const Scalar relTol = 1.0e-15;
195 if (std::abs((t.
A_(i, j) -
A_(i, j)) /
A_(i, j)) > relTol)
208 if (std::abs((t.
b_(i) -
b_(i)) /
b_(i)) > relTol)
return false;
209 if (std::abs((t.
c_(i) -
c_(i)) /
c_(i)) > relTol)
return false;
226 for (
size_t i = 0; i < this->
numStages(); i++)
227 for (
size_t j = i; j < this->
numStages(); j++)
235 bool nonZero =
false;
236 for (
size_t i = 0; i < this->
numStages(); i++) {
237 if (
A_(i, i) != 0.0) nonZero =
true;
238 for (
size_t j = i + 1; j < this->
numStages(); j++)
241 if (nonZero ==
false)
isDIRK_ =
false;
262 #endif // Tempus_RKButcherTableau_hpp
virtual void setEmbedded(bool a)
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)
bool operator!=(const RKButcherTableau &t) const
SerialBandDenseMatrixPrinter< OrdinalType, ScalarType > printMat(const SerialBandDenseMatrix< OrdinalType, ScalarType > &obj)
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void setTVDCoeff(const Scalar a)
set TVD coefficient of RK method
virtual bool isTVD() const
Return true if the RK method is TVD.
Teuchos::SerialDenseVector< int, Scalar > bstar_
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual void setTVD(bool a)
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.
virtual const Teuchos::SerialDenseVector< int, Scalar > & c() const
Return the vector of stage positions.
virtual Scalar getTVDCoeff() const
Return TVD coefficient of RK method.
void set_isDIRK()
DIRK is defined as if a_ij = 0 for j>i and a_ii != 0 for at least one i.
virtual const Teuchos::SerialDenseVector< int, Scalar > & b() const
Return the vector of quadrature weights.
virtual std::string description() const
OrdinalType length() const
basic_FancyOStream & setOutputToRootOnly(const int rootRank)
OrdinalType numCols() const
virtual const Teuchos::SerialDenseMatrix< int, Scalar > & A() const
Return the matrix coefficients.
virtual std::size_t numStages() const
Return the number of stages.
Teuchos::SerialDenseVector< int, Scalar > c_
#define TEUCHOS_ASSERT(assertion_test)
Teuchos::SerialDenseMatrix< int, Scalar > A_
#define TEUCHOS_ASSERT_EQUALITY(val1, val2)
virtual const Teuchos::SerialDenseVector< int, Scalar > & bstar() const
Return the vector of quadrature weights for embedded methods.
virtual int order() const
Return the order.
Teuchos::SerialDenseVector< int, Scalar > b_
virtual int orderMin() const
Return the minimum order.
bool operator==(const RKButcherTableau &t) const
OrdinalType numRows() const