-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tempus: Fix Failing Tests Due to FPE
Investigated failing tests from Tempus_*_MPI_1 failing in Trilinos-atdm-ats1-knl_intel-19.0.4_mpich-7.7.15_openmp_static_opt build starting 2021-10-15 #9881 * Excluded the Intel compiler for FPE testing. * Fixed an FPE divide-by-zero in Stepper_ErrorNorm - Added unit test to cover it * Added some doxygen on Stepper_ErrorNorm
- Loading branch information
Showing
5 changed files
with
154 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
packages/tempus/unit_test/Tempus_UnitTest_Stepper_ErrorNorm.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// @HEADER | ||
// **************************************************************************** | ||
// Tempus: Copyright (2017) Sandia Corporation | ||
// | ||
// Distributed under BSD 3-clause license (See accompanying file Copyright.txt) | ||
// **************************************************************************** | ||
// @HEADER | ||
|
||
#include "Tempus_UnitTest_Utils.hpp" | ||
|
||
#include "Thyra_DefaultSpmdVectorSpace.hpp" | ||
|
||
#include "Tempus_NumericalUtils.hpp" | ||
#include "Tempus_Stepper_ErrorNorm.hpp" | ||
|
||
#include "../TestModels/DahlquistTestModel.hpp" | ||
|
||
|
||
namespace Tempus_Unit_Test { | ||
|
||
// ************************************************************ | ||
// ************************************************************ | ||
TEUCHOS_UNIT_TEST(Stepper_ErrorNorm, computeWRMSNorm) | ||
{ | ||
|
||
int N = 3; | ||
Teuchos::RCP<const Thyra::VectorSpaceBase<double> > xSpace = | ||
Thyra::defaultSpmdVectorSpace<double>(N); | ||
auto x = Thyra::createMember(xSpace); | ||
auto xNext = Thyra::createMember(xSpace); | ||
auto eVec = Thyra::createMember(xSpace); | ||
|
||
auto tol = Tempus::numericalTol<double>(); | ||
auto eNorm = Teuchos::rcp(new Tempus::Stepper_ErrorNorm<double>(tol, 0.0)); | ||
|
||
Thyra::assign(x.ptr(), 0.0); | ||
Thyra::assign(xNext.ptr(), 0.0); | ||
Thyra::assign(eVec.ptr(), 0.0); | ||
double rmsNorm = eNorm->computeWRMSNorm(x, xNext, eVec); | ||
TEST_FLOATING_EQUALITY(rmsNorm, 0.0, 1.0e-12); | ||
|
||
Thyra::assign(x.ptr(), 1.0); | ||
Thyra::assign(xNext.ptr(), 1.0+tol); | ||
Thyra::assign(eVec.ptr(), tol); | ||
rmsNorm = eNorm->computeWRMSNorm(x, xNext, eVec); | ||
TEST_FLOATING_EQUALITY(rmsNorm, 1.0/std::sqrt(N), 1.0e-12); | ||
} | ||
|
||
|
||
// ************************************************************ | ||
// ************************************************************ | ||
TEUCHOS_UNIT_TEST(Stepper_ErrorNorm, errorNorm) | ||
{ | ||
|
||
Teuchos::RCP<const Thyra::VectorSpaceBase<double> > xSpace = | ||
Thyra::defaultSpmdVectorSpace<double>(3); | ||
auto x = Thyra::createMember(xSpace); | ||
|
||
auto tol = Tempus::numericalTol<double>(); | ||
auto eNorm = Teuchos::rcp(new Tempus::Stepper_ErrorNorm<double>(tol, tol)); | ||
|
||
Thyra::assign(x.ptr(), 0.0); | ||
double norm = eNorm->errorNorm(x); | ||
TEST_FLOATING_EQUALITY(norm, tol, 1.0e-12); | ||
|
||
Thyra::assign(x.ptr(), 1.0); | ||
norm = eNorm->errorNorm(x); | ||
TEST_FLOATING_EQUALITY(norm, 1.0/(2.0*tol), 1.0e-12); | ||
} | ||
|
||
|
||
} // namespace Tempus_Test |