Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Tempus_UnitTest_TimeEventBase.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ****************************************************************************
3 // Tempus: Copyright (2017) Sandia Corporation
4 //
5 // Distributed under BSD 3-clause license (See accompanying file Copyright.txt)
6 // ****************************************************************************
7 // @HEADER
8 
9 #include "Teuchos_UnitTestHarness.hpp"
10 #include "Teuchos_XMLParameterListHelpers.hpp"
11 #include "Teuchos_TimeMonitor.hpp"
12 #include "Teuchos_DefaultComm.hpp"
13 
14 #include "Tempus_TimeEventBase.hpp"
15 
16 #include "../TestUtils/Tempus_ConvergenceTestUtils.hpp"
17 
18 
19 namespace Tempus_Unit_Test {
20 
21 using Teuchos::RCP;
22 using Teuchos::rcp;
23 using Teuchos::rcp_const_cast;
24 using Teuchos::rcp_dynamic_cast;
25 
26 
27 // ************************************************************
28 // ************************************************************
29 TEUCHOS_UNIT_TEST(TimeEventBase, Default_Construction)
30 {
31  auto te = rcp(new Tempus::TimeEventBase<double>());
32 
33  TEST_COMPARE(te->getName(), ==, "TimeEventBase");
34  te->setName("TestName");
35  TEST_COMPARE(te->getName(), ==, "TestName");
36 
37  TEST_COMPARE(te->isTime(0.0), ==, false);
38  TEST_FLOATING_EQUALITY(te->timeToNextEvent(0.0), te->getDefaultTime(), 1.0e-14);
39  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(0.0), te->getDefaultTime(), 1.0e-14);
40  TEST_COMPARE(te->eventInRange(0.0, 1.0), ==, false);
41 
42  TEST_COMPARE(te->isIndex(0), ==, false);
43  TEST_COMPARE(te->indexToNextEvent(0), ==, te->getDefaultIndex());
44  TEST_COMPARE(te->indexOfNextEvent(0), ==, te->getDefaultIndex());
45  TEST_COMPARE(te->eventInRange(0, 10), ==, false);
46 
47  // Check base class defaults (functions not implemented in TimeEventRange).
48  TEST_COMPARE(te->isIndex(1), ==, false);
49  TEST_COMPARE(te->indexToNextEvent(1), ==, te->getDefaultIndex());
50  TEST_COMPARE(te->indexOfNextEvent(1), ==, te->getDefaultIndex());
51  TEST_COMPARE(te->eventInRangeIndex(1,4), ==, false);
52 }
53 
54 
55 } // namespace Tempus_Test
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
This class defines time events which can be used to &quot;trigger&quot; an action. Time events are points in ti...