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