Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
Tempus_StepperNewmarkImplicitAForm_impl.hpp
Go to the documentation of this file.
1//@HEADER
2// *****************************************************************************
3// Tempus: Time Integration and Sensitivity Analysis Package
4//
5// Copyright 2017 NTESS and the Tempus contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8//@HEADER
9
10#ifndef Tempus_StepperNewmarkImplicitAForm_impl_hpp
11#define Tempus_StepperNewmarkImplicitAForm_impl_hpp
12
14
15//#define VERBOSE_DEBUG_OUTPUT
16//#define DEBUG_OUTPUT
17
18namespace Tempus {
19
20template <class Scalar>
23 const Thyra::VectorBase<Scalar>& a, const Scalar dt) const
24{
25#ifdef VERBOSE_DEBUG_OUTPUT
26 *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
27#endif
28 // vPred = v + dt*(1.0-gamma_)*a
29 Thyra::V_StVpStV(Teuchos::ptrFromRef(vPred), 1.0, v, dt * (1.0 - gamma_), a);
30}
31
32template <class Scalar>
36 const Scalar dt) const
37{
38#ifdef VERBOSE_DEBUG_OUTPUT
39 *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
40#endif
41 Teuchos::RCP<const Thyra::VectorBase<Scalar> > tmp =
42 Thyra::createMember<Scalar>(dPred.space());
43 // dPred = dt*v + dt*dt/2.0*(1.0-2.0*beta_)*a
44 Scalar aConst = dt * dt / 2.0 * (1.0 - 2.0 * beta_);
45 Thyra::V_StVpStV(Teuchos::ptrFromRef(dPred), dt, v, aConst, a);
46 // dPred += d;
47 Thyra::Vp_V(Teuchos::ptrFromRef(dPred), d, 1.0);
48}
49
50template <class Scalar>
53 const Thyra::VectorBase<Scalar>& a, const Scalar dt) const
54{
55#ifdef VERBOSE_DEBUG_OUTPUT
56 *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
57#endif
58 // v = vPred + dt*gamma_*a
59 Thyra::V_StVpStV(Teuchos::ptrFromRef(v), 1.0, vPred, dt * gamma_, a);
60}
61
62template <class Scalar>
65 const Thyra::VectorBase<Scalar>& a, const Scalar dt) const
66{
67#ifdef VERBOSE_DEBUG_OUTPUT
68 *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
69#endif
70 // d = dPred + beta_*dt*dt*a
71 Thyra::V_StVpStV(Teuchos::ptrFromRef(d), 1.0, dPred, beta_ * dt * dt, a);
72}
73
74template <class Scalar>
76{
77 if (schemeName_ != "User Defined") {
78 *out_ << "\nWARNING: schemeName != 'User Defined' (=" << schemeName_
79 << ").\n"
80 << " Not setting beta, and leaving as beta = " << beta_ << "!\n";
81 return;
82 }
83
84 beta_ = beta;
85
86 if (beta_ == 0.0) {
87 *out_ << "\nWARNING: Running (implicit implementation of) Newmark "
88 << "Implicit a-Form Stepper with Beta = 0.0, which \n"
89 << "specifies an explicit scheme. Mass lumping is not possible, "
90 << "so this will be slow! To run explicit \n"
91 << "implementation of Newmark Implicit a-Form Stepper, please "
92 << "re-run with 'Stepper Type' = 'Newmark Explicit a-Form'.\n"
93 << "This stepper allows for mass lumping when called through "
94 << "Piro::TempusSolver.\n";
95 }
96
97 TEUCHOS_TEST_FOR_EXCEPTION(
98 (beta_ > 1.0) || (beta_ < 0.0), std::logic_error,
99 "\nError in 'Newmark Implicit a-Form' stepper: invalid value of Beta = "
100 << beta_ << ". Please select Beta >= 0 and <= 1. \n");
101}
102
103template <class Scalar>
105{
106 if (schemeName_ != "User Defined") {
107 *out_ << "\nWARNING: schemeName != 'User Defined' (=" << schemeName_
108 << ").\n"
109 << " Not setting gamma, and leaving as gamma = " << gamma_ << "!\n";
110 return;
111 }
112
113 gamma_ = gamma;
114
115 TEUCHOS_TEST_FOR_EXCEPTION(
116 (gamma_ > 1.0) || (gamma_ < 0.0), std::logic_error,
117 "\nError in 'Newmark Implicit a-Form' stepper: invalid value of Gamma ="
118 << gamma_ << ". Please select Gamma >= 0 and <= 1. \n");
119}
120
121template <class Scalar>
123{
124 schemeName_ = schemeName;
125
126 if (schemeName_ == "Average Acceleration") {
127 beta_ = 0.25;
128 gamma_ = 0.5;
129 }
130 else if (schemeName_ == "Linear Acceleration") {
131 beta_ = 0.25;
132 gamma_ = 1.0 / 6.0;
133 }
134 else if (schemeName_ == "Central Difference") {
135 beta_ = 0.0;
136 gamma_ = 0.5;
137 }
138 else if (schemeName_ == "User Defined") {
139 beta_ = 0.25;
140 gamma_ = 0.5; // Use defaults until setBeta and setGamma calls.
141 }
142 else {
143 TEUCHOS_TEST_FOR_EXCEPTION(
144 true, std::logic_error,
145 "\nError in Tempus::StepperNewmarkImplicitAForm! "
146 << "Invalid Scheme Name = " << schemeName_ << ". \n"
147 << "Valid Scheme Names are: 'Average Acceleration', "
148 << "'Linear Acceleration', \n"
149 << "'Central Difference' and 'User Defined'.\n");
150 }
151
152 this->isInitialized_ = false;
153}
154
155template <class Scalar>
157 Teuchos::RCP<StepperNewmarkImplicitAFormAppAction<Scalar> > appAction)
158{
159 if (appAction == Teuchos::null) {
160 // Create default appAction
161 stepperNewmarkImpAppAction_ =
163 }
164 else {
165 stepperNewmarkImpAppAction_ = appAction;
166 }
167
168 this->isInitialized_ = false;
169}
170
171template <class Scalar>
173 : out_(Teuchos::VerboseObjectBase::getDefaultOStream())
174{
175#ifdef VERBOSE_DEBUG_OUTPUT
176 *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
177#endif
178
179 this->setStepperName("Newmark Implicit a-Form");
180 this->setStepperType("Newmark Implicit a-Form");
181 this->setUseFSAL(true);
182 this->setICConsistency("Consistent");
183 this->setICConsistencyCheck(false);
184 this->setZeroInitialGuess(false);
185 this->setSchemeName("Average Acceleration");
186
187 this->setAppAction(Teuchos::null);
188 this->setDefaultSolver();
189}
190
191template <class Scalar>
193 const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel,
194 const Teuchos::RCP<Thyra::NonlinearSolverBase<Scalar> >& solver,
195 bool useFSAL, std::string ICConsistency, bool ICConsistencyCheck,
196 bool zeroInitialGuess, std::string schemeName, Scalar beta, Scalar gamma,
198 stepperAppAction)
199 : out_(Teuchos::VerboseObjectBase::getDefaultOStream())
200{
201 this->setStepperName("Newmark Implicit a-Form");
202 this->setStepperType("Newmark Implicit a-Form");
203 this->setUseFSAL(useFSAL);
204 this->setICConsistency(ICConsistency);
205 this->setICConsistencyCheck(ICConsistencyCheck);
206 this->setZeroInitialGuess(zeroInitialGuess);
207 this->setSchemeName(schemeName);
208 this->setBeta(beta);
209 this->setGamma(gamma);
210 this->setAppAction(stepperAppAction);
211 this->setSolver(solver);
212
213 if (appModel != Teuchos::null) {
214 this->setModel(appModel);
215 this->initialize();
216 }
217}
218
219template <class Scalar>
221 const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& appModel)
222{
223#ifdef VERBOSE_DEBUG_OUTPUT
224 *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
225#endif
226 validSecondOrderODE_DAE(appModel);
227 this->wrapperModel_ =
229 appModel, "Newmark Implicit a-Form"));
230
231 TEUCHOS_TEST_FOR_EXCEPTION(this->getSolver() == Teuchos::null,
232 std::logic_error, "Error - Solver is not set!\n");
233 this->getSolver()->setModel(this->wrapperModel_);
234
235 this->isInitialized_ = false;
236}
237
238template <class Scalar>
240 const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory)
241{
242 using Teuchos::RCP;
243
244 int numStates = solutionHistory->getNumStates();
245
246 TEUCHOS_TEST_FOR_EXCEPTION(
247 numStates < 1, std::logic_error,
248 "Error - setInitialConditions() needs at least one SolutionState\n"
249 " to set the initial condition. Number of States = "
250 << numStates);
251
252 if (numStates > 1) {
253 RCP<Teuchos::FancyOStream> out = this->getOStream();
254 out->setOutputToRootOnly(0);
255 Teuchos::OSTab ostab(out, 1,
256 "StepperNewmarkImplicitAForm::setInitialConditions()");
257 *out << "Warning -- SolutionHistory has more than one state!\n"
258 << "Setting the initial conditions on the currentState.\n"
259 << std::endl;
260 }
261
262 RCP<SolutionState<Scalar> > initialState = solutionHistory->getCurrentState();
263 RCP<Thyra::VectorBase<Scalar> > x = initialState->getX();
264 RCP<Thyra::VectorBase<Scalar> > xDot = initialState->getXDot();
265
266 auto inArgs = this->wrapperModel_->getNominalValues();
267 TEUCHOS_TEST_FOR_EXCEPTION(
268 !((x != Teuchos::null && xDot != Teuchos::null) ||
269 (inArgs.get_x() != Teuchos::null &&
270 inArgs.get_x_dot() != Teuchos::null)),
271 std::logic_error,
272 "Error - We need to set the initial conditions for x and xDot from\n"
273 " either initialState or appModel_->getNominalValues::InArgs\n"
274 " (but not from a mixture of the two).\n");
275
276 // Use x and xDot from inArgs as ICs, if needed.
277 if (x == Teuchos::null || xDot == Teuchos::null) {
278 using Teuchos::rcp_const_cast;
279 TEUCHOS_TEST_FOR_EXCEPTION(
280 (inArgs.get_x() == Teuchos::null) ||
281 (inArgs.get_x_dot() == Teuchos::null),
282 std::logic_error,
283 "Error - setInitialConditions() needs the ICs from the initialState\n"
284 " or getNominalValues()!\n");
285 x = rcp_const_cast<Thyra::VectorBase<Scalar> >(inArgs.get_x());
286 initialState->setX(x);
287 xDot = rcp_const_cast<Thyra::VectorBase<Scalar> >(inArgs.get_x_dot());
288 initialState->setXDot(xDot);
289 }
290
291 // Check if we need Stepper storage for xDotDot
292 if (initialState->getXDotDot() == Teuchos::null)
293 initialState->setXDotDot(initialState->getX()->clone_v());
294 else
295 this->setStepperXDotDot(initialState->getXDotDot());
296
297 // Perform IC Consistency
298 std::string icConsistency = this->getICConsistency();
299 if (icConsistency == "None") {
300 if (initialState->getXDotDot() == Teuchos::null) {
301 RCP<Teuchos::FancyOStream> out = this->getOStream();
302 out->setOutputToRootOnly(0);
303 Teuchos::OSTab ostab(
304 out, 1, "StepperNewmarkImplicitAForm::setInitialConditions()");
305 *out << "Warning -- Requested IC consistency of 'None' but\n"
306 << " initialState does not have an xDot.\n"
307 << " Setting a 'Zero' xDot!\n"
308 << std::endl;
309
310 Thyra::assign(this->getStepperXDotDot(initialState).ptr(), Scalar(0.0));
311 }
312 }
313 else if (icConsistency == "Zero")
314 Thyra::assign(this->getStepperXDotDot(initialState).ptr(), Scalar(0.0));
315 else if (icConsistency == "App") {
316 auto xDotDot = Teuchos::rcp_const_cast<Thyra::VectorBase<Scalar> >(
317 inArgs.get_x_dot_dot());
318 TEUCHOS_TEST_FOR_EXCEPTION(
319 xDotDot == Teuchos::null, std::logic_error,
320 "Error - setInitialConditions() requested 'App' for IC consistency,\n"
321 " but 'App' returned a null pointer for xDotDot!\n");
322 Thyra::assign(this->getStepperXDotDot(initialState).ptr(), *xDotDot);
323 }
324 else if (icConsistency == "Consistent") {
325 // Solve f(x, xDot, xDotDot, t) = 0.
326 const Scalar time = initialState->getTime();
327 auto xDotDot = this->getStepperXDotDot(initialState);
328
329 // Compute initial acceleration using initial displacement
330 // and initial velocity.
331 if (this->initialGuess_ != Teuchos::null) {
332 TEUCHOS_TEST_FOR_EXCEPTION(
333 !((xDotDot->space())->isCompatible(*this->initialGuess_->space())),
334 std::logic_error,
335 "Error - User-provided initial guess for Newton is not compatible\n"
336 " with solution vector!\n");
337 Thyra::copy(*this->initialGuess_, xDotDot.ptr());
338 }
339 else {
340 Thyra::put_scalar(0.0, xDotDot.ptr());
341 }
342
343 auto wrapperModel =
344 Teuchos::rcp_dynamic_cast<WrapperModelEvaluatorSecondOrder<Scalar> >(
345 this->wrapperModel_);
346
347 wrapperModel->initializeNewmark(xDot, x, 0.0, time, beta_, gamma_);
348 const Thyra::SolveStatus<Scalar> sStatus =
349 (*(this->solver_)).solve(&*xDotDot);
350
351 TEUCHOS_TEST_FOR_EXCEPTION(
352 sStatus.solveStatus != Thyra::SOLVE_STATUS_CONVERGED, std::logic_error,
353 "Error - Solver failed while determining the initial conditions.\n"
354 " Solver status is "
355 << Thyra::toString(sStatus.solveStatus) << ".\n");
356 }
357 else {
358 TEUCHOS_TEST_FOR_EXCEPTION(
359 true, std::logic_error,
360 "Error - setInitialConditions() invalid IC consistency, "
361 << icConsistency << ".\n");
362 }
363
364 // At this point, x, xDot and xDotDot are sync'ed or consistent
365 // at the same time level for the initialState.
366 initialState->setIsSynced(true);
367
368 // Test for consistency.
369 if (this->getICConsistencyCheck()) {
370 auto f = initialState->getX()->clone_v();
371 auto xDotDot = this->getStepperXDotDot(initialState);
372
373 typedef Thyra::ModelEvaluatorBase MEB;
374 MEB::InArgs<Scalar> appInArgs =
375 this->wrapperModel_->getAppModel()->createInArgs();
376 MEB::OutArgs<Scalar> appOutArgs =
377 this->wrapperModel_->getAppModel()->createOutArgs();
378
379 appInArgs.set_x(x);
380 appInArgs.set_x_dot(xDot);
381 appInArgs.set_x_dot_dot(xDotDot);
382
383 appOutArgs.set_f(appOutArgs.get_f());
384
385 appInArgs.set_W_x_dot_dot_coeff(Scalar(0.0)); // da/da
386 appInArgs.set_alpha(Scalar(0.0)); // dv/da
387 appInArgs.set_beta(Scalar(0.0)); // dd/da
388
389 appInArgs.set_t(initialState->getTime());
390
391 this->wrapperModel_->getAppModel()->evalModel(appInArgs, appOutArgs);
392
393 Scalar reldiff = Thyra::norm(*f);
394 Scalar normx = Thyra::norm(*x);
395 Scalar eps = Scalar(100.0) * std::abs(Teuchos::ScalarTraits<Scalar>::eps());
396 if (normx > eps * reldiff) reldiff /= normx;
397
398 if (reldiff > eps) {
399 RCP<Teuchos::FancyOStream> out = this->getOStream();
400 out->setOutputToRootOnly(0);
401 Teuchos::OSTab ostab(
402 out, 1, "StepperNewmarkImplicitAForm::setInitialConditions()");
403 *out << "Warning -- Failed consistency check but continuing!\n"
404 << " ||f(x,xDot,xDotDot,t)||/||x|| > eps" << std::endl
405 << " ||f(x,xDot,xDotDot,t)|| = " << Thyra::norm(*f)
406 << std::endl
407 << " ||x|| = " << Thyra::norm(*x)
408 << std::endl
409 << " ||f(x,xDot,xDotDot,t)||/||x|| = " << reldiff << std::endl
410 << " eps = " << eps << std::endl;
411 }
412 }
413
414 if (!(this->getUseFSAL())) {
415 RCP<Teuchos::FancyOStream> out = this->getOStream();
416 out->setOutputToRootOnly(0);
417 Teuchos::OSTab ostab(out, 1,
418 "StepperNewmarkImplicitAForm::setInitialConditions()");
419 *out << "\nWarning -- The First-Same-As-Last (FSAL) principle is "
420 << "part of the Newmark Implicit A-Form. The default is to "
421 << "set useFSAL=true, and useFSAL=false will be ignored." << std::endl;
422 }
423}
424
425template <class Scalar>
427 const Teuchos::RCP<SolutionHistory<Scalar> >& solutionHistory)
428{
429#ifdef VERBOSE_DEBUG_OUTPUT
430 *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
431#endif
432 this->checkInitialized();
433
434 using Teuchos::RCP;
435
436 TEMPUS_FUNC_TIME_MONITOR("Tempus::StepperNewmarkImplicitAForm::takeStep()");
437 {
438 TEUCHOS_TEST_FOR_EXCEPTION(
439 solutionHistory->getNumStates() < 2, std::logic_error,
440 "Error - StepperNewmarkImplicitAForm<Scalar>::takeStep(...)\n"
441 << "Need at least two SolutionStates for NewmarkImplicitAForm.\n"
442 << " Number of States = " << solutionHistory->getNumStates()
443 << "\nTry setting in \"Solution History\" \"Storage Type\" = "
444 << "\"Undo\"\n"
445 << " or \"Storage Type\" = \"Static\" and \"Storage Limit\" = "
446 << "\"2\"\n");
447
448 auto thisStepper = Teuchos::rcpFromRef(*this);
449 stepperNewmarkImpAppAction_->execute(
450 solutionHistory, thisStepper,
452 Scalar>::ACTION_LOCATION::BEGIN_STEP);
453
454 RCP<SolutionState<Scalar> > workingState =
455 solutionHistory->getWorkingState();
456 RCP<SolutionState<Scalar> > currentState =
457 solutionHistory->getCurrentState();
458
459 auto wrapperModel =
460 Teuchos::rcp_dynamic_cast<WrapperModelEvaluatorSecondOrder<Scalar> >(
461 this->wrapperModel_);
462
463 // Get values of d, v and a from previous step
464 RCP<const Thyra::VectorBase<Scalar> > d_old = currentState->getX();
465 RCP<const Thyra::VectorBase<Scalar> > v_old = currentState->getXDot();
466 RCP<Thyra::VectorBase<Scalar> > a_old = currentState->getXDotDot();
467
468 // Get new values of d, v and a from workingState
469 RCP<Thyra::VectorBase<Scalar> > d_new = workingState->getX();
470 RCP<Thyra::VectorBase<Scalar> > v_new = workingState->getXDot();
471 RCP<Thyra::VectorBase<Scalar> > a_new = workingState->getXDotDot();
472
473 // Get time and dt
474 const Scalar time = currentState->getTime();
475 const Scalar dt = workingState->getTimeStep();
476 Scalar t = time + dt;
477
478 // Compute displacement and velocity predictors
479 predictDisplacement(*d_new, *d_old, *v_old, *a_old, dt);
480 predictVelocity(*v_new, *v_old, *a_old, dt);
481
482 // Inject d_new, v_new, a and other relevant data into wrapperModel
483 wrapperModel->initializeNewmark(v_new, d_new, dt, t, beta_, gamma_);
484
485 stepperNewmarkImpAppAction_->execute(
486 solutionHistory, thisStepper,
488 Scalar>::ACTION_LOCATION::BEFORE_SOLVE);
489
490 if (this->getZeroInitialGuess())
491 Thyra::assign(a_new.ptr(), Teuchos::ScalarTraits<Scalar>::zero());
492
493 // Solve nonlinear system with a_new as initial guess
494 const Thyra::SolveStatus<Scalar> sStatus =
495 (*(this->solver_)).solve(&*a_new);
496
497 stepperNewmarkImpAppAction_->execute(
498 solutionHistory, thisStepper,
500 Scalar>::ACTION_LOCATION::AFTER_SOLVE);
501
502 // Correct velocity, displacement.
503 correctVelocity(*v_new, *v_new, *a_new, dt);
504 correctDisplacement(*d_new, *d_new, *a_new, dt);
505
506 workingState->setSolutionStatus(sStatus); // Converged --> pass.
507 workingState->setOrder(this->getOrder());
508 workingState->computeNorms(currentState);
509
510 stepperNewmarkImpAppAction_->execute(
511 solutionHistory, thisStepper,
513 Scalar>::ACTION_LOCATION::END_STEP);
514 }
515 return;
516}
517
524template <class Scalar>
525Teuchos::RCP<Tempus::StepperState<Scalar> >
527{
528#ifdef VERBOSE_DEBUG_OUTPUT
529 *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
530#endif
531 Teuchos::RCP<Tempus::StepperState<Scalar> > stepperState =
532 rcp(new StepperState<Scalar>(this->getStepperType()));
533 return stepperState;
534}
535
536template <class Scalar>
538 Teuchos::FancyOStream& out, const Teuchos::EVerbosityLevel verbLevel) const
539{
540 out.setOutputToRootOnly(0);
541#ifdef VERBOSE_DEBUG_OUTPUT
542 *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
543#endif
544
545 out << std::endl;
546 Stepper<Scalar>::describe(out, verbLevel);
547 StepperImplicit<Scalar>::describe(out, verbLevel);
548
549 out << "--- StepperNewmarkImplicitAForm ---\n";
550 out << " schemeName_ = " << schemeName_ << std::endl;
551 out << " beta_ = " << beta_ << std::endl;
552 out << " gamma_ = " << gamma_ << std::endl;
553 out << "-----------------------------------" << std::endl;
554}
555
556template <class Scalar>
558 Teuchos::FancyOStream& out) const
559{
560 out.setOutputToRootOnly(0);
561 bool isValidSetup = true;
562 out.setOutputToRootOnly(0);
563
564 if (!Stepper<Scalar>::isValidSetup(out)) isValidSetup = false;
565
566 // if ( !StepperImplicit<Scalar>::isValidSetup(out) ) isValidSetup = false;
567 if (this->wrapperModel_->getAppModel() == Teuchos::null) {
568 isValidSetup = false;
569 out << "The application ModelEvaluator is not set!\n";
570 }
571
572 if (this->wrapperModel_ == Teuchos::null) {
573 isValidSetup = false;
574 out << "The wrapper ModelEvaluator is not set!\n";
575 }
576
577 if (this->solver_ == Teuchos::null) {
578 isValidSetup = false;
579 out << "The solver is not set!\n";
580 }
581
582 if (this->stepperNewmarkImpAppAction_ == Teuchos::null) {
583 isValidSetup = false;
584 out << "The Newmark Implicit A-Form AppAction is not set!\n";
585 }
586
587 return isValidSetup;
588}
589
590template <class Scalar>
591Teuchos::RCP<const Teuchos::ParameterList>
593{
594#ifdef VERBOSE_DEBUG_OUTPUT
595 *out_ << "DEBUG: " << __PRETTY_FUNCTION__ << "\n";
596#endif
597 auto pl = this->getValidParametersBasicImplicit();
598
599 auto newmarkPL = Teuchos::parameterList("Newmark Parameters");
600 newmarkPL->set<std::string>("Scheme Name", schemeName_);
601 newmarkPL->set<double>("Beta", beta_);
602 newmarkPL->set<double>("Gamma", gamma_);
603 pl->set("Newmark Parameters", *newmarkPL);
604
605 return pl;
606}
607
608// Nonmember constructor - ModelEvaluator and ParameterList
609// ------------------------------------------------------------------------
610template <class Scalar>
611Teuchos::RCP<StepperNewmarkImplicitAForm<Scalar> >
613 const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
614 Teuchos::RCP<Teuchos::ParameterList> pl)
615{
616 auto stepper = Teuchos::rcp(new StepperNewmarkImplicitAForm<Scalar>());
617 stepper->setStepperImplicitValues(pl);
618
619 if (pl != Teuchos::null) {
620 if (pl->isSublist("Newmark Parameters")) {
621 auto newmarkPL = pl->sublist("Newmark Parameters", true);
622 std::string schemeName =
623 newmarkPL.get<std::string>("Scheme Name", "Average Acceleration");
624 stepper->setSchemeName(schemeName);
625 if (schemeName == "User Defined") {
626 stepper->setBeta(newmarkPL.get<double>("Beta", 0.25));
627 stepper->setGamma(newmarkPL.get<double>("Gamma", 0.5));
628 }
629 }
630 else {
631 stepper->setSchemeName("Average Acceleration");
632 }
633 }
634
635 if (model != Teuchos::null) {
636 stepper->setModel(model);
637 stepper->initialize();
638 }
639
640 return stepper;
641}
642
643} // namespace Tempus
644#endif // Tempus_StepperNewmarkImplicitAForm_impl_hpp
SolutionHistory is basically a container of SolutionStates. SolutionHistory maintains a collection of...
virtual void setSolver(Teuchos::RCP< Thyra::NonlinearSolverBase< Scalar > > solver) override
Set solver.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const override
virtual void setZeroInitialGuess(bool zIG)
Newmark time stepper in acceleration form (a-form).
void predictDisplacement(Thyra::VectorBase< Scalar > &dPred, const Thyra::VectorBase< Scalar > &d, const Thyra::VectorBase< Scalar > &v, const Thyra::VectorBase< Scalar > &a, const Scalar dt) const
void correctVelocity(Thyra::VectorBase< Scalar > &v, const Thyra::VectorBase< Scalar > &vPred, const Thyra::VectorBase< Scalar > &a, const Scalar dt) const
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
void predictVelocity(Thyra::VectorBase< Scalar > &vPred, const Thyra::VectorBase< Scalar > &v, const Thyra::VectorBase< Scalar > &a, const Scalar dt) const
virtual Teuchos::RCP< Tempus::StepperState< Scalar > > getDefaultStepperState()
Get a default (initial) StepperState.
virtual void setAppAction(Teuchos::RCP< StepperNewmarkImplicitAFormAppAction< Scalar > > appAction)
virtual void setModel(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &appModel)
Set the model.
void correctDisplacement(Thyra::VectorBase< Scalar > &d, const Thyra::VectorBase< Scalar > &dPred, const Thyra::VectorBase< Scalar > &a, const Scalar dt) const
virtual void takeStep(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Take the specified timestep, dt, and return true if successful.
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
virtual bool isValidSetup(Teuchos::FancyOStream &out) const
virtual void setInitialConditions(const Teuchos::RCP< SolutionHistory< Scalar > > &solutionHistory)
Set the initial conditions and make them consistent.
StepperState is a simple class to hold state information about the stepper.
Thyra Base interface for time steppers.
void setICConsistencyCheck(bool c)
void setStepperName(std::string s)
Set the stepper name.
virtual void initialize()
Initialize after construction and changing input parameters.
void setStepperType(std::string s)
Set the stepper type.
void setICConsistency(std::string s)
virtual void describe(Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel) const
A ModelEvaluator for residual evaluations given a state. This ModelEvaluator takes a state,...
Teuchos::RCP< StepperNewmarkImplicitAForm< Scalar > > createStepperNewmarkImplicitAForm(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, Teuchos::RCP< Teuchos::ParameterList > pl)
Nonmember constructor - ModelEvaluator and ParameterList.
void validSecondOrderODE_DAE(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model)