12#include "Teuchos_XMLParameterListHelpers.hpp" 
   14#include "Tempus_StepperNewmarkExplicitAForm.hpp" 
   20#include "../TestModels/HarmonicOscillatorModel.hpp" 
   24using Teuchos::ParameterList;
 
   27using Teuchos::rcp_const_cast;
 
   28using Teuchos::rcp_dynamic_cast;
 
   29using Teuchos::sublist;
 
   33class StepperNewmarkExplicitAFormModifierTest
 
   37  StepperNewmarkExplicitAFormModifierTest()
 
   38    : testBEGIN_STEP(false),
 
   39      testBEFORE_EXPLICIT_EVAL(false),
 
   40      testAFTER_EXPLICIT_EVAL(false),
 
   42      testCurrentValue(-0.99),
 
   49  virtual ~StepperNewmarkExplicitAFormModifierTest() {}
 
   59      case StepperNewmarkExplicitAFormAppAction<double>::BEGIN_STEP: {
 
   60        testBEGIN_STEP = 
true;
 
   63      case StepperNewmarkExplicitAFormAppAction<double>::BEFORE_EXPLICIT_EVAL: {
 
   64        testBEFORE_EXPLICIT_EVAL = 
true;
 
   65        testName                 = 
"Newmark Explicit A Form - Modifier";
 
   66        stepper->setStepperName(testName);
 
   69      case StepperNewmarkExplicitAFormAppAction<double>::AFTER_EXPLICIT_EVAL: {
 
   70        testAFTER_EXPLICIT_EVAL = 
true;
 
   71        testDt                  = sh->getWorkingState()->getTimeStep();
 
   75      case StepperNewmarkExplicitAFormAppAction<double>::END_STEP: {
 
   77        auto x           = sh->getWorkingState()->getX();
 
   78        testCurrentValue = get_ele(*(x), 0);
 
   82        TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
 
   83                                   "Error - unknown action location.\n");
 
   88  bool testBEFORE_EXPLICIT_EVAL;
 
   89  bool testAFTER_EXPLICIT_EVAL;
 
   91  double testCurrentValue;
 
   98class StepperNewmarkExplicitAFormModifierXTest
 
  102  StepperNewmarkExplicitAFormModifierXTest()
 
  103    : testX_BEGIN_STEP(false),
 
  104      testX_BEFORE_EXPLICIT_EVAL(false),
 
  105      testX_AFTER_EXPLICIT_EVAL(false),
 
  106      testX_END_STEP(false),
 
  115  virtual ~StepperNewmarkExplicitAFormModifierXTest() {}
 
  125      case StepperNewmarkExplicitAFormModifierXBase<double>::X_BEGIN_STEP: {
 
  126        testX_BEGIN_STEP = 
true;
 
  128        testX            = get_ele(*(x), 0);
 
  131      case StepperNewmarkExplicitAFormModifierXBase<
 
  133        testX_BEFORE_EXPLICIT_EVAL = 
true;
 
  135        testX                      = get_ele(*(x), 0);
 
  138      case StepperNewmarkExplicitAFormModifierXBase<
 
  140        testX_AFTER_EXPLICIT_EVAL = 
true;
 
  141        testX                     = get_ele(*(x), 0);
 
  144      case StepperNewmarkExplicitAFormModifierXBase<double>::X_END_STEP: {
 
  145        testX_END_STEP = 
true;
 
  147        testX          = get_ele(*(x), 0);
 
  151        TEUCHOS_TEST_FOR_EXCEPTION(
true, std::logic_error,
 
  152                                   "Error - unknown action location.\n");
 
  156  bool testX_BEGIN_STEP;
 
  157  bool testX_BEFORE_EXPLICIT_EVAL;
 
  158  bool testX_AFTER_EXPLICIT_EVAL;
 
  168  using Teuchos::ParameterList;
 
  170  using Teuchos::sublist;
 
  172  RCP<Tempus::IntegratorBasic<double>> integrator;
 
  173  std::vector<RCP<Thyra::VectorBase<double>>> solutions;
 
  174  std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
 
  177  RCP<ParameterList> pList = Teuchos::getParametersFromXmlFile(
 
  178      "Tempus_NewmarkExplicitAForm_HarmonicOscillator_Damped.xml");
 
  181  RCP<ParameterList> hom_pl = sublist(pList, 
"HarmonicOscillatorModel", 
true);
 
  182  RCP<Tempus_Test::HarmonicOscillatorModel<double>> model =
 
  186  RCP<ParameterList> pl        = sublist(pList, 
"Tempus", 
true);
 
  187  RCP<ParameterList> stepperPL = sublist(pl, 
"Default Stepper", 
true);
 
  188  stepperPL->remove(
"Zero Initial Guess");
 
  190  double dt = pl->sublist(
"Default Integrator")
 
  191                  .sublist(
"Time Step Control")
 
  192                  .get<
double>(
"Initial Time Step");
 
  195  pl->sublist(
"Default Integrator")
 
  196      .sublist(
"Time Step Control")
 
  197      .set(
"Initial Time Step", dt);
 
  198  integrator = Tempus::createIntegratorBasic<double>(pl, model);
 
  200  RCP<Tempus::StepperNewmarkExplicitAForm<double>> stepper =
 
  201      Teuchos::rcp_dynamic_cast<Tempus::StepperNewmarkExplicitAForm<double>>(
 
  202          integrator->getStepper(), 
true);
 
  204  auto modifier = rcp(
new StepperNewmarkExplicitAFormModifierTest());
 
  205  stepper->setAppAction(modifier);
 
  206  stepper->initialize();
 
  207  integrator->initialize();
 
  210  bool integratorStatus = integrator->advanceTime();
 
  211  TEST_ASSERT(integratorStatus)
 
  214  TEST_COMPARE(modifier->testBEGIN_STEP, ==, 
true);
 
  215  TEST_COMPARE(modifier->testBEFORE_EXPLICIT_EVAL, ==, 
true);
 
  216  TEST_COMPARE(modifier->testAFTER_EXPLICIT_EVAL, ==, 
true);
 
  217  TEST_COMPARE(modifier->testEND_STEP, ==, 
true);
 
  220  auto x  = integrator->getX();
 
  221  auto Dt = integrator->getTime();
 
  222  TEST_FLOATING_EQUALITY(modifier->testDt, Dt, 1.0e-14);
 
  223  TEST_FLOATING_EQUALITY(modifier->testCurrentValue, get_ele(*(x), 0), 1.0e-14);
 
  224  TEST_COMPARE(modifier->testName, ==, stepper->getStepperName());
 
 
  229  using Teuchos::ParameterList;
 
  231  using Teuchos::sublist;
 
  233  RCP<Tempus::IntegratorBasic<double>> integrator;
 
  234  std::vector<RCP<Thyra::VectorBase<double>>> solutions;
 
  235  std::vector<RCP<Thyra::VectorBase<double>>> solutionsDot;
 
  238  RCP<ParameterList> pList = Teuchos::getParametersFromXmlFile(
 
  239      "Tempus_NewmarkExplicitAForm_HarmonicOscillator_Damped.xml");
 
  242  RCP<ParameterList> hom_pl = sublist(pList, 
"HarmonicOscillatorModel", 
true);
 
  243  RCP<Tempus_Test::HarmonicOscillatorModel<double>> model =
 
  247  RCP<ParameterList> pl        = sublist(pList, 
"Tempus", 
true);
 
  248  RCP<ParameterList> stepperPL = sublist(pl, 
"Default Stepper", 
true);
 
  249  stepperPL->remove(
"Zero Initial Guess");
 
  251  double dt = pl->sublist(
"Default Integrator")
 
  252                  .sublist(
"Time Step Control")
 
  253                  .get<
double>(
"Initial Time Step");
 
  256  pl->sublist(
"Default Integrator")
 
  257      .sublist(
"Time Step Control")
 
  258      .set(
"Initial Time Step", dt);
 
  259  integrator = Tempus::createIntegratorBasic<double>(pl, model);
 
  261  RCP<Tempus::StepperNewmarkExplicitAForm<double>> stepper =
 
  262      Teuchos::rcp_dynamic_cast<Tempus::StepperNewmarkExplicitAForm<double>>(
 
  263          integrator->getStepper(), 
true);
 
  265  auto modifierX = rcp(
new StepperNewmarkExplicitAFormModifierXTest());
 
  266  stepper->setAppAction(modifierX);
 
  267  stepper->initialize();
 
  268  integrator->initialize();
 
  271  bool integratorStatus = integrator->advanceTime();
 
  272  TEST_ASSERT(integratorStatus)
 
  275  TEST_COMPARE(modifierX->testX_BEGIN_STEP, ==, 
true);
 
  276  TEST_COMPARE(modifierX->testX_BEFORE_EXPLICIT_EVAL, ==, 
true);
 
  277  TEST_COMPARE(modifierX->testX_AFTER_EXPLICIT_EVAL, ==, 
true);
 
  278  TEST_COMPARE(modifierX->testX_END_STEP, ==, 
true);
 
  281  auto Dt = integrator->getTime();
 
  282  TEST_FLOATING_EQUALITY(modifierX->testDt, Dt, 1.0e-14);
 
  284  const auto x = integrator->getX();
 
  285  TEST_FLOATING_EQUALITY(modifierX->testX, get_ele(*(x), 0), 1.0e-14);
 
 
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
 
TEUCHOS_UNIT_TEST(BackwardEuler, Default_Construction)