9 #ifndef Tempus_RKButcherTableau_hpp
10 #define Tempus_RKButcherTableau_hpp
14 #pragma clang system_header
20 #include "Tempus_config.hpp"
42 template <
class Scalar>
73 Scalar sumb = ST::zero();
74 for (
size_t i = 0; i < this->
numStages(); i++) sumb +=
b_(i);
76 std::abs(ST::one() - sumb) > 1.0e-08, std::runtime_error,
77 "Error - Butcher Tableau b fails to satisfy Sum(b_i) = 1.\n"
78 <<
" Sum(b_i) = " << sumb <<
"\n");
82 for (
size_t i = 0; i < this->
numStages(); i++) {
83 Scalar sumai = ST::zero();
84 for (
size_t j = 0; j < this->
numStages(); j++) sumai +=
A_(i, j);
86 if (std::abs(sumai) > 1.0e-08)
87 failed = (std::abs((sumai -
c_(i)) / sumai) > 1.0e-08);
89 failed = (std::abs(
c_(i)) > 1.0e-08);
92 failed, std::runtime_error,
93 "Error - Butcher Tableau fails to satisfy c_i = Sum_j(a_ij).\n"
94 <<
" Stage i = " << i <<
"\n"
95 <<
" c_i = " <<
c_(i) <<
"\n"
96 <<
" Sum_j(a_ij) = " << sumai <<
"\n"
97 <<
" This may be OK as some valid tableaus do not satisfy\n"
98 <<
" this condition. If so, construct this RKButcherTableau\n"
99 <<
" with checkC = false.\n");
167 out <<
"number of Stages = " << this->
numStages() << std::endl;
168 out <<
"A = " <<
printMat(this->
A()) << std::endl;
169 out <<
"b = " <<
printMat(this->
b()) << std::endl;
170 out <<
"c = " <<
printMat(this->
c()) << std::endl;
172 out <<
"order = " << this->
order() << std::endl;
173 out <<
"orderMin = " << this->
orderMin() << std::endl;
174 out <<
"orderMax = " << this->
orderMax() << std::endl;
175 out <<
"isImplicit = " << this->
isImplicit() << std::endl;
176 out <<
"isDIRK = " << this->
isDIRK() << std::endl;
177 out <<
"isEmbedded = " << this->
isEmbedded() << std::endl;
179 out <<
"TVD Coeff = " << this->
getTVDCoeff() << std::endl;
186 const Scalar relTol = 1.0e-15;
194 if (std::abs((t.
A_(i, j) -
A_(i, j)) /
A_(i, j)) > relTol)
207 if (std::abs((t.
b_(i) -
b_(i)) /
b_(i)) > relTol)
return false;
208 if (std::abs((t.
c_(i) -
c_(i)) /
c_(i)) > relTol)
return false;
225 for (
size_t i = 0; i < this->
numStages(); i++)
226 for (
size_t j = i; j < this->
numStages(); j++)
234 bool nonZero =
false;
235 for (
size_t i = 0; i < this->
numStages(); i++) {
236 if (
A_(i, i) != 0.0) nonZero =
true;
237 for (
size_t j = i + 1; j < this->
numStages(); j++)
240 if (nonZero ==
false)
isDIRK_ =
false;
261 #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