Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 
10 
11 #include "Tempus_TimeEventBase.hpp"
12 
13 
14 namespace Tempus_Unit_Test {
15 
16 using Teuchos::RCP;
17 using Teuchos::rcp;
18 using Teuchos::rcp_const_cast;
19 using Teuchos::rcp_dynamic_cast;
20 
21 
22 // ************************************************************
23 // ************************************************************
24 TEUCHOS_UNIT_TEST(TimeEventBase, Default_Construction)
25 {
26  auto te = rcp(new Tempus::TimeEventBase<double>());
27 
28  TEST_COMPARE(te->getType(), ==, "Base");
29 
30  TEST_COMPARE(te->getName(), ==, "TimeEventBase");
31  te->setName("TestName");
32  TEST_COMPARE(te->getName(), ==, "TestName");
33 
34  TEST_COMPARE(te->isTime(0.0), ==, false);
35  TEST_FLOATING_EQUALITY(te->getAbsTol(), std::numeric_limits<double>::epsilon()*100.0, 1.0e-14);
36  TEST_FLOATING_EQUALITY(te->timeToNextEvent(0.0), te->getDefaultTime(), 1.0e-14);
37  TEST_FLOATING_EQUALITY(te->timeOfNextEvent(0.0), te->getDefaultTime(), 1.0e-14);
38  TEST_FLOATING_EQUALITY(te->getDefaultTol(), te->getAbsTol(), 1.0e-14);
39  TEST_COMPARE(te->eventInRange(0.0, 1.0), ==, false);
40 
41  TEST_COMPARE(te->isIndex(0), ==, false);
42  TEST_COMPARE(te->indexToNextEvent(0), ==, te->getDefaultIndex());
43  TEST_COMPARE(te->indexOfNextEvent(0), ==, te->getDefaultIndex());
44  TEST_COMPARE(te->eventInRange(0, 10), ==, false);
45 
46  // Check base class defaults.
47  TEST_COMPARE(te->isIndex(1), ==, false);
48  TEST_COMPARE(te->indexToNextEvent(1), ==, te->getDefaultIndex());
49  TEST_COMPARE(te->indexOfNextEvent(1), ==, te->getDefaultIndex());
50  TEST_COMPARE(te->eventInRangeIndex(1,4), ==, false);
51 
52 }
53 
54 
55 // ************************************************************
56 // ************************************************************
57 TEUCHOS_UNIT_TEST(TimeEventBase, getValidParameters)
58 {
59  auto teb = rcp(new Tempus::TimeEventBase<double>());
60 
61  auto pl = teb->getValidParameters();
62 
63  TEST_COMPARE (pl->get<std::string>("Type"), ==, "Base");
64  TEST_COMPARE (pl->get<std::string>("Name"), ==, "TimeEventBase");
65 
66  { // Ensure that parameters are "used", excluding sublists.
67  std::ostringstream unusedParameters;
68  pl->unused(unusedParameters);
69  TEST_COMPARE ( unusedParameters.str(), ==, "");
70  }
71 }
72 
73 
74 } // namespace Tempus_Unit_Test
#define TEST_COMPARE(v1, comp, v2)
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
This class defines time events which can be used to &quot;trigger&quot; an action.