12 #include "Teuchos_DefaultComm.hpp" 
   14 #include "Thyra_VectorStdOps.hpp" 
   16 #include "Tempus_StepperHHTAlpha.hpp" 
   25 #include "../TestModels/SinCosModel.hpp" 
   26 #include "../TestModels/VanDerPolModel.hpp" 
   27 #include "../TestModels/HarmonicOscillatorModel.hpp" 
   28 #include "../TestUtils/Tempus_ConvergenceTestUtils.hpp" 
   33 namespace Tempus_Unit_Test {
 
   37 using Teuchos::rcp_const_cast;
 
   38 using Teuchos::rcp_dynamic_cast;
 
   40 using Teuchos::sublist;
 
   41 using Teuchos::getParametersFromXmlFile;
 
   52   stepper->setModel(model);
 
   53   stepper->initialize();
 
   61   bool useFSAL              = stepper->getUseFSAL();
 
   62   std::string ICConsistency = stepper->getICConsistency();
 
   63   bool ICConsistencyCheck   = stepper->getICConsistencyCheck();
 
   64   bool zeroInitialGuess     = stepper->getZeroInitialGuess();
 
   65   std::string schemeName    = 
"Newmark Beta User Defined";
 
   78   stepper->setICConsistency(ICConsistency);            stepper->initialize();  
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
 
   79   stepper->setICConsistencyCheck(ICConsistencyCheck);  stepper->initialize();  
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
 
   80   stepper->setZeroInitialGuess(zeroInitialGuess);      stepper->initialize();  
TEUCHOS_TEST_FOR_EXCEPT(!stepper->isInitialized());
 
   94     model, solver, useFSAL,
 
   95     ICConsistency, ICConsistencyCheck, zeroInitialGuess,
 
   96     schemeName, beta, gamma, alpha_f, alpha_m,modifier));
 
  114 class StepperHHTAlphaModifierTest
 
  120   StepperHHTAlphaModifierTest()
 
  121     : testBEGIN_STEP(false), testBEFORE_SOLVE(false),
 
  122       testAFTER_SOLVE(false), testEND_STEP(false),
 
  123       testCurrentValue(-0.99), testWorkingValue(-0.99),
 
  124       testDt(-1.5), testName(
"")
 
  128   virtual ~StepperHHTAlphaModifierTest(){}
 
  139         testBEGIN_STEP = 
true;
 
  140         auto x = sh->getCurrentState()->getX();
 
  141         testCurrentValue = get_ele(*(x), 0);
 
  146         testBEFORE_SOLVE = 
true;
 
  147         testDt = sh->getWorkingState()->getTimeStep()/10.0;
 
  148         sh->getWorkingState()->setTimeStep(testDt);
 
  153         testAFTER_SOLVE = 
true;
 
  154         testName = 
"HHT Alpha - Modifier";
 
  155         stepper->setStepperName(testName);
 
  161         auto x = sh->getWorkingState()->getX();
 
  162         testWorkingValue = get_ele(*(x), 0);
 
  167         "Error - unknown action location.\n");
 
  171   bool testBEFORE_SOLVE;
 
  172   bool testAFTER_SOLVE;
 
  174   double testCurrentValue;
 
  175   double testWorkingValue;
 
  177   std::string testName;
 
  187   stepper->setModel(model);
 
  188   auto modifier = 
rcp(
new StepperHHTAlphaModifierTest());
 
  189   stepper->setAppAction(modifier);
 
  190   stepper->initialize();
 
  196   stepper->setInitialConditions(solutionHistory);
 
  197   solutionHistory->initWorkingState();
 
  199   solutionHistory->getWorkingState()->setTimeStep(dt);
 
  200   stepper->takeStep(solutionHistory);
 
  209   auto x = solutionHistory->getCurrentState()->getX();
 
  211   x = solutionHistory->getWorkingState()->getX();
 
  213   auto Dt = solutionHistory->getWorkingState()->getTimeStep();
 
  215   TEST_COMPARE(modifier->testName, ==, 
"HHT Alpha - Modifier");
 
  220 class StepperHHTAlphaObserverTest
 
  225   StepperHHTAlphaObserverTest()
 
  226     : testBEGIN_STEP(false), testBEFORE_SOLVE(false),
 
  227       testAFTER_SOLVE(false), testEND_STEP(false),
 
  228       testCurrentValue(-0.99), testWorkingValue(-0.99),
 
  229       testDt(-1.5), testName(
"")
 
  233   virtual ~StepperHHTAlphaObserverTest(){}
 
  236   virtual void observe(
 
  244       testBEGIN_STEP = 
true;
 
  245       auto x = sh->getCurrentState()->getX();
 
  246       testCurrentValue = get_ele(*(x), 0);
 
  251       testBEFORE_SOLVE = 
true;
 
  252       testDt = sh->getWorkingState()->getTimeStep();
 
  257       testAFTER_SOLVE = 
true;
 
  258       testName = stepper->getStepperType();
 
  264       auto x = sh->getWorkingState()->getX();
 
  265       testWorkingValue = get_ele(*(x), 0);
 
  270         "Error - unknown action location.\n");
 
  275   bool testBEFORE_SOLVE;
 
  276   bool testAFTER_SOLVE;
 
  278   double testCurrentValue;
 
  279   double testWorkingValue;
 
  281   std::string testName;
 
  291   stepper->setModel(model);
 
  292   auto observer = 
rcp(
new StepperHHTAlphaObserverTest());
 
  293   stepper->setAppAction(observer);
 
  294   stepper->initialize();
 
  300   stepper->setInitialConditions(solutionHistory);
 
  301   solutionHistory->initWorkingState();
 
  303   solutionHistory->getWorkingState()->setTimeStep(dt);
 
  304   stepper->takeStep(solutionHistory);
 
  312   auto x = solutionHistory->getCurrentState()->getX();
 
  314   x = solutionHistory->getWorkingState()->getX();
 
  323 class StepperHHTAlphaModifierXTest
 
  329   StepperHHTAlphaModifierXTest()
 
  330     : testX_BEGIN_STEP(false), testX_BEFORE_SOLVE(false),
 
  331       testX_AFTER_SOLVE(false), testX_END_STEP(false),
 
  332       testXbegin(-0.99), testXend(-0.99),
 
  333       testDt(-1.5), testTime(-1.5)
 
  337   virtual ~StepperHHTAlphaModifierXTest(){}
 
  342     const double time, 
const double dt,
 
  348       testX_BEGIN_STEP = 
true;
 
  349       testXbegin = get_ele(*(x), 0);
 
  354       testX_BEFORE_SOLVE = 
true;
 
  360       testX_AFTER_SOLVE = 
true;
 
  366       testX_END_STEP = 
true;
 
  367       testXend = get_ele(*(x), 0);
 
  372       "Error - unknown action location.\n");
 
  376   bool testX_BEGIN_STEP;
 
  377   bool testX_BEFORE_SOLVE;
 
  378   bool testX_AFTER_SOLVE;
 
  393   stepper->setModel(model);
 
  394   auto modifierX = 
rcp(
new StepperHHTAlphaModifierXTest());
 
  395   stepper->setAppAction(modifierX);
 
  396   stepper->initialize();
 
  401   stepper->setInitialConditions(solutionHistory);
 
  402   solutionHistory->initWorkingState();
 
  404   solutionHistory->getWorkingState()->setTimeStep(dt);
 
  405   stepper->takeStep(solutionHistory);
 
  414   auto xbegin = solutionHistory->getCurrentState()->getX();
 
  416   auto xend = solutionHistory->getWorkingState()->getX();
 
  418   auto Dt = solutionHistory->getWorkingState()->getTimeStep();
 
  420   auto time = solutionHistory->getWorkingState()->getTime();
 
MODIFIER_TYPE
Indicates the location of application action (see algorithm). 
 
Base observer for StepperHHTAlpha. 
 
Base ModifierX for StepperHHTAlpha. 
 
Modify  at the beginning of the step. 
 
void testFactoryConstruction(std::string stepperType, const Teuchos::RCP< const Thyra::ModelEvaluator< double > > &model)
Unit test utility for Stepper construction through StepperFactory. 
 
After the implicit solve. 
 
Modify  after the implicit solve. 
 
Modify  at the end of the step. 
 
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
 
#define TEST_COMPARE(v1, comp, v2)
 
#define TEST_FLOATING_EQUALITY(v1, v2, tol)
 
Teuchos::RCP< Teuchos::ParameterList > defaultSolverParameters()
Returns the default solver ParameterList for implicit Steppers. 
 
Teuchos::RCP< SolutionHistory< Scalar > > createSolutionHistoryME(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)
Nonmember contructor from a Thyra ModelEvaluator. 
 
Consider the ODE:  where  is a constant,  is a constant damping parameter,  is a constant forcing par...
 
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
 
At the beginning of the step. 
 
Base modifier for StepperHHTAlpha. 
 
Default ModifierX for StepperHHTAlpha. 
 
virtual void modify(Teuchos::RCP< Thyra::VectorBase< double > >, const double, const double, const MODIFIER_TYPE modType)=0
Modify solution based on the MODIFIER_TYPE. 
 
Before the implicit solve. 
 
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)
 
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
 
Default modifier for StepperHHTAlpha. 
 
Default observer for StepperHHTAlpha. 
 
Modify  before the implicit solve. 
 
ACTION_LOCATION
Indicates the location of application action (see algorithm). 
 
#define TEUCHOS_ASSERT(assertion_test)
 
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)