|
Rythmos - Transient Integration for Differential Equations Version of the Day
|
00001 //@HEADER 00002 // *********************************************************************** 00003 // 00004 // Rythmos Package 00005 // Copyright (2009) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Todd S. Coffey (tscoffe@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 //@HEADER 00028 00029 #ifndef RYTHMOS_STACKED_STEPPER_HPP 00030 #define RYTHMOS_STACKED_STEPPER_HPP 00031 00032 00033 #include "Rythmos_StepperBase.hpp" 00034 #include "Thyra_ModelEvaluatorHelpers.hpp" 00035 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp" 00036 #include "Teuchos_VerboseObjectParameterListHelpers.hpp" 00037 #include "Teuchos_Assert.hpp" 00038 #include "Teuchos_as.hpp" 00039 00040 // Includes for ForwardSensitivityStackedStepper 00041 #include "Rythmos_ForwardSensitivityModelEvaluatorBase.hpp" 00042 00043 namespace Rythmos { 00044 00045 template<class Scalar> 00046 class StackedStepperStepStrategyBase 00047 { 00048 public: 00049 virtual ~StackedStepperStepStrategyBase() {} 00050 virtual void setupNextStepper( 00051 int i, 00052 Array<RCP<StepperBase<Scalar> > > &stepperArray 00053 ) = 0; 00054 virtual Scalar evaluateStep( 00055 Scalar local_dt_taken, 00056 int i, 00057 Array<RCP<StepperBase<Scalar> > > &stepperArray 00058 ) = 0; 00059 }; 00060 00061 template<class Scalar> 00062 class DefaultStackedStepperStepStrategy 00063 : virtual public StackedStepperStepStrategyBase<Scalar> 00064 { 00065 public: 00066 DefaultStackedStepperStepStrategy(); 00067 virtual ~DefaultStackedStepperStepStrategy(); 00068 void setupNextStepper( 00069 int i, 00070 Array<RCP<StepperBase<Scalar> > > &stepperArray 00071 ); 00072 Scalar evaluateStep( 00073 Scalar local_dt_taken, 00074 int i, 00075 Array<RCP<StepperBase<Scalar> > > &stepperArray 00076 ); 00077 private: 00078 Scalar dt_taken_; 00079 }; 00080 00081 // Nonmember constructor declaration 00082 template<class Scalar> 00083 RCP<DefaultStackedStepperStepStrategy<Scalar> > 00084 defaultStackedStepperStepStrategy(); 00085 00086 // Nonmember constructor definition 00087 template<class Scalar> 00088 RCP<DefaultStackedStepperStepStrategy<Scalar> > 00089 defaultStackedStepperStepStrategy() 00090 { 00091 return Teuchos::rcp(new DefaultStackedStepperStepStrategy<Scalar>()); 00092 } 00093 00094 template<class Scalar> 00095 DefaultStackedStepperStepStrategy<Scalar>::DefaultStackedStepperStepStrategy() 00096 { 00097 typedef Teuchos::ScalarTraits<Scalar> ST; 00098 dt_taken_ = ST::nan(); 00099 } 00100 00101 00102 template<class Scalar> 00103 DefaultStackedStepperStepStrategy<Scalar>::~DefaultStackedStepperStepStrategy() 00104 { 00105 } 00106 00107 00108 template<class Scalar> 00109 void DefaultStackedStepperStepStrategy<Scalar>::setupNextStepper( 00110 int i, 00111 Array<RCP<StepperBase<Scalar> > > &stepperArray 00112 ) 00113 { 00114 if (i > 0) { 00115 RCP<StepperBase<Scalar> > baseStepper = stepperArray[0]; 00116 stepperArray[i]->setStepControlData(*baseStepper); 00117 } 00118 } 00119 00120 00121 template<class Scalar> 00122 Scalar DefaultStackedStepperStepStrategy<Scalar>::evaluateStep( 00123 Scalar local_dt_taken, 00124 int i, 00125 Array<RCP<StepperBase<Scalar> > > &stepperArray 00126 ) 00127 { 00128 if (i == 0) { 00129 dt_taken_ = local_dt_taken; 00130 } 00131 else { 00132 TEST_FOR_EXCEPTION( local_dt_taken != dt_taken_, std::logic_error, 00133 "Error! sub-stepper["<<i<<"] did not take the same " 00134 "size step as the base stepper!" 00135 ); 00136 } 00137 return dt_taken_; 00138 } 00139 00140 00141 00142 template<class Scalar> 00143 class ForwardSensitivityStackedStepperStepStrategy 00144 : virtual public StackedStepperStepStrategyBase<Scalar> 00145 { 00146 public: 00147 ForwardSensitivityStackedStepperStepStrategy(); 00148 virtual ~ForwardSensitivityStackedStepperStepStrategy(); 00149 void setupNextStepper( 00150 int i, 00151 Array<RCP<StepperBase<Scalar> > > &stepperArray 00152 ); 00153 Scalar evaluateStep( 00154 Scalar local_dt_taken, 00155 int i, 00156 Array<RCP<StepperBase<Scalar> > > &stepperArray 00157 ); 00158 void setStateBasePoint( 00159 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &stateBasePoint 00160 ); 00161 private: 00162 Scalar dt_taken_; 00163 Thyra::ModelEvaluatorBase::InArgs<Scalar> stateBasePoint_; 00164 }; 00165 00166 // Nonmember constructor declaration 00167 template<class Scalar> 00168 RCP<ForwardSensitivityStackedStepperStepStrategy<Scalar> > 00169 forwardSensitivityStackedStepperStepStrategy(); 00170 00171 // Nonmember constructor definition 00172 template<class Scalar> 00173 RCP<ForwardSensitivityStackedStepperStepStrategy<Scalar> > 00174 forwardSensitivityStackedStepperStepStrategy() 00175 { 00176 return Teuchos::rcp(new ForwardSensitivityStackedStepperStepStrategy<Scalar>()); 00177 } 00178 00179 template<class Scalar> 00180 ForwardSensitivityStackedStepperStepStrategy<Scalar>::ForwardSensitivityStackedStepperStepStrategy() 00181 { 00182 typedef Teuchos::ScalarTraits<Scalar> ST; 00183 dt_taken_ = ST::nan(); 00184 } 00185 00186 00187 template<class Scalar> 00188 ForwardSensitivityStackedStepperStepStrategy<Scalar>::~ForwardSensitivityStackedStepperStepStrategy() 00189 { 00190 } 00191 00192 00193 template<class Scalar> 00194 void ForwardSensitivityStackedStepperStepStrategy<Scalar>::setupNextStepper( 00195 int i, 00196 Array<RCP<StepperBase<Scalar> > > &stepperArray 00197 ) 00198 { 00199 typedef Thyra::ModelEvaluatorBase MEB; 00200 if (i > 0) { 00201 RCP<StepperBase<Scalar> > baseStepper = stepperArray[0]; 00202 RCP<Thyra::ModelEvaluator<Scalar> > modelI = 00203 // TODO: 09/09/09 tscoffe: This should be replaced by 00204 // getNonconstModel() when it is implemented correctly. 00205 Teuchos::rcp_const_cast<Thyra::ModelEvaluator<Scalar> >( 00206 stepperArray[i]->getModel() 00207 ); 00208 RCP<ForwardSensitivityModelEvaluatorBase<Scalar> > fwdSensME = 00209 Teuchos::rcp_dynamic_cast<ForwardSensitivityModelEvaluatorBase<Scalar> > ( 00210 modelI,false 00211 ); 00212 if (Teuchos::nonnull(fwdSensME)) { 00213 bool forceUpToDateW = true; 00214 fwdSensME->initializePointState( Teuchos::inOutArg(*baseStepper), forceUpToDateW); 00215 } 00216 stepperArray[i]->setStepControlData(*baseStepper); 00217 } 00218 } 00219 00220 00221 template<class Scalar> 00222 Scalar ForwardSensitivityStackedStepperStepStrategy<Scalar>::evaluateStep( 00223 Scalar local_dt_taken, 00224 int i, 00225 Array<RCP<StepperBase<Scalar> > > &stepperArray 00226 ) 00227 { 00228 if (i == 0) { 00229 dt_taken_ = local_dt_taken; 00230 } 00231 else { 00232 TEST_FOR_EXCEPTION( local_dt_taken != dt_taken_, std::logic_error, 00233 "Error! sub-stepper["<<i<<"] did not take the same " 00234 "size step as the base stepper!" 00235 ); 00236 } 00237 return dt_taken_; 00238 } 00239 00240 00241 template<class Scalar> 00242 void ForwardSensitivityStackedStepperStepStrategy<Scalar>::setStateBasePoint( 00243 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &stateBasePoint 00244 ) 00245 { 00246 stateBasePoint_ = stateBasePoint; 00247 } 00248 00249 00250 template<class Scalar> 00251 class StackedStepper 00252 : virtual public StepperBase<Scalar>, 00253 virtual public Teuchos::ParameterListAcceptorDefaultBase 00254 { 00255 public: 00256 00258 typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag; 00259 00262 00264 StackedStepper(); 00265 00268 void addStepper(const RCP<StepperBase<Scalar> >& stepper); 00269 00272 ArrayView<const RCP<StepperBase<Scalar> > > getNonconstSteppers() const; 00273 00276 void setStackedStepperStepControlStrategy( 00277 const RCP<StackedStepperStepStrategyBase<Scalar> >& stepControl 00278 ); 00279 00282 RCP<const StackedStepperStepStrategyBase<Scalar> > 00283 getStackedStepperStepCongrolStrategy() const; 00284 00286 00289 00291 void setParameterList(RCP<Teuchos::ParameterList> const& paramList); 00293 RCP<const Teuchos::ParameterList> getValidParameters() const; 00294 00296 00299 00301 bool acceptsModel() const; 00302 00304 void setModel( 00305 const RCP<const Thyra::ModelEvaluator<Scalar> >& model 00306 ); 00307 00309 void setNonconstModel( 00310 const RCP<Thyra::ModelEvaluator<Scalar> >& model 00311 ); 00312 00319 RCP<const Thyra::ModelEvaluator<Scalar> > getModel() const; 00320 00322 RCP<Thyra::ModelEvaluator<Scalar> > getNonconstModel(); 00323 00336 void setInitialCondition( 00337 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &stacked_ic 00338 ); 00339 00340 /* \brief Get the initial condigion 00341 */ 00342 Thyra::ModelEvaluatorBase::InArgs<Scalar> getInitialCondition() const; 00343 00345 Scalar takeStep( Scalar dt, StepSizeType stepType ); 00346 00348 const StepStatus<Scalar> getStepStatus() const; 00349 00351 00354 00361 RCP<const Thyra::VectorSpaceBase<Scalar> > 00362 get_x_space() const; 00363 00365 void addPoints( 00366 const Array<Scalar>& time_vec, 00367 const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > >& x_vec, 00368 const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec 00369 ); 00370 00372 TimeRange<Scalar> getTimeRange() const; 00373 00375 void getPoints( 00376 const Array<Scalar>& time_vec, 00377 Array<RCP<const Thyra::VectorBase<Scalar> > >* x_vec, 00378 Array<RCP<const Thyra::VectorBase<Scalar> > >* xdot_vec, 00379 Array<ScalarMag>* accuracy_vec 00380 ) const; 00381 00383 void getNodes(Array<Scalar>* time_vec) const; 00384 00386 void removeNodes(Array<Scalar>& time_vec); 00387 00389 int getOrder() const; 00390 00392 00393 private: 00394 00395 mutable bool isInitialized_; 00396 00397 Array<RCP<StepperBase<Scalar> > > stepperArray_; 00398 00399 mutable Array<RCP<const Thyra::VectorSpaceBase<Scalar> > > xSpaceArray_; 00400 //Array<RCP<const Thyra::VectorSpaceBase<Scalar> > > fSpaceArray_; 00401 00402 mutable Teuchos::RCP<const Thyra::ProductVectorSpaceBase<Scalar> > 00403 x_bar_space_; 00404 //Teuchos::RCP<const Thyra::ProductVectorSpaceBase<Scalar> > 00405 // f_bar_space_; 00406 00407 RCP<StackedStepperStepStrategyBase<Scalar> > stackedStepperStepStrategy_; 00408 00409 // Private functions: 00410 void setupSpaces_() const; 00411 00412 }; 00413 00414 00419 template<class Scalar> 00420 inline 00421 RCP<StackedStepper<Scalar> > 00422 stackedStepper() 00423 { 00424 return Teuchos::rcp(new StackedStepper<Scalar>()); 00425 } 00426 00427 00428 // Constructors, Intializers, Misc. 00429 00430 00431 template<class Scalar> 00432 StackedStepper<Scalar>::StackedStepper() 00433 : isInitialized_(false) 00434 {} 00435 00436 template<class Scalar> 00437 void StackedStepper<Scalar>::setupSpaces_() const 00438 { 00439 using Teuchos::as; 00440 if (!isInitialized_) { 00441 for (int i=0 ; i < as<int>(stepperArray_.size()) ; ++i) { 00442 xSpaceArray_.push_back(stepperArray_[i]->get_x_space()); 00443 //fSpaceArray_.push_back(stepperArray_[i]->get_f_space()); 00444 } 00445 00446 x_bar_space_ = Thyra::productVectorSpace<Scalar>(xSpaceArray_); 00447 //f_bar_space_ = Thyra::productVectorSpace<Scalar>(fSpaceArray_); 00448 00449 isInitialized_ = true; 00450 } 00451 } 00452 00453 template<class Scalar> 00454 void StackedStepper<Scalar>::addStepper( 00455 const RCP<StepperBase<Scalar> >& stepper 00456 ) 00457 { 00458 TEUCHOS_ASSERT(!is_null(stepper)); 00459 stepperArray_.push_back(stepper); 00460 isInitialized_ = false; 00461 } 00462 00463 00464 00465 template<class Scalar> 00466 ArrayView<const RCP<StepperBase<Scalar> > > 00467 StackedStepper<Scalar>::getNonconstSteppers() const 00468 { 00469 return stepperArray_(); 00470 } 00471 00472 00473 template<class Scalar> 00474 void StackedStepper<Scalar>::setStackedStepperStepControlStrategy( 00475 const RCP<StackedStepperStepStrategyBase<Scalar> >& stepControl 00476 ) 00477 { 00478 TEUCHOS_ASSERT( Teuchos::nonnull(stepControl) ); 00479 stackedStepperStepStrategy_ = stepControl; 00480 } 00481 00482 00483 template<class Scalar> 00484 RCP<const StackedStepperStepStrategyBase<Scalar> > 00485 StackedStepper<Scalar>::getStackedStepperStepCongrolStrategy() const 00486 { 00487 return stackedStepperStepStrategy_; 00488 } 00489 00490 00491 template<class Scalar> 00492 void StackedStepper<Scalar>::setParameterList( 00493 RCP<Teuchos::ParameterList> const& paramList 00494 ) 00495 { 00496 TEST_FOR_EXCEPT(is_null(paramList)); 00497 paramList->validateParameters(*getValidParameters()); 00498 this->setMyParamList(paramList); 00499 Teuchos::readVerboseObjectSublist(&*paramList,this); 00500 } 00501 00502 00503 template<class Scalar> 00504 RCP<const Teuchos::ParameterList> 00505 StackedStepper<Scalar>::getValidParameters() const 00506 { 00507 static RCP<const ParameterList> validPL; 00508 if (is_null(validPL) ) { 00509 RCP<ParameterList> pl = Teuchos::parameterList(); 00510 Teuchos::setupVerboseObjectSublist(&*pl); 00511 validPL = pl; 00512 } 00513 return validPL; 00514 } 00515 00516 00517 // Overridden from StepperBase 00518 00519 template<class Scalar> 00520 bool StackedStepper<Scalar>::acceptsModel() const 00521 { 00522 return false; 00523 } 00524 00525 template<class Scalar> 00526 void StackedStepper<Scalar>::setModel( 00527 const RCP<const Thyra::ModelEvaluator<Scalar> >& model 00528 ) 00529 { 00530 TEST_FOR_EXCEPT_MSG( true, 00531 "Error, this stepper subclass does not accept a model" 00532 " as defined by the StepperBase interface!"); 00533 } 00534 00535 00536 template<class Scalar> 00537 void StackedStepper<Scalar>::setNonconstModel( 00538 const RCP<Thyra::ModelEvaluator<Scalar> >& model 00539 ) 00540 { 00541 TEST_FOR_EXCEPT_MSG( true, 00542 "Error, this stepper subclass does not accept a model" 00543 " as defined by the StepperBase interface!"); 00544 } 00545 00546 00547 template<class Scalar> 00548 RCP<const Thyra::ModelEvaluator<Scalar> > 00549 StackedStepper<Scalar>::getModel() const 00550 { 00551 TEST_FOR_EXCEPT(true); 00552 return Teuchos::null; 00553 } 00554 00555 00556 template<class Scalar> 00557 RCP<Thyra::ModelEvaluator<Scalar> > 00558 StackedStepper<Scalar>::getNonconstModel() 00559 { 00560 TEST_FOR_EXCEPT(true); 00561 return Teuchos::null; 00562 } 00563 00564 00565 template<class Scalar> 00566 void StackedStepper<Scalar>::setInitialCondition( 00567 const Thyra::ModelEvaluatorBase::InArgs<Scalar> &stacked_ic 00568 ) 00569 { 00570 TEST_FOR_EXCEPT(true); 00571 } 00572 00573 00574 template<class Scalar> 00575 Thyra::ModelEvaluatorBase::InArgs<Scalar> 00576 StackedStepper<Scalar>::getInitialCondition() const 00577 { 00578 TEST_FOR_EXCEPT(true); 00579 Thyra::ModelEvaluatorBase::InArgs<Scalar> inArgs; 00580 return inArgs; 00581 } 00582 00583 00584 template<class Scalar> 00585 Scalar 00586 StackedStepper<Scalar>::takeStep( 00587 Scalar dt, StepSizeType stepType 00588 ) 00589 { 00590 typedef Teuchos::ScalarTraits<Scalar> ST; 00591 00592 TEST_FOR_EXCEPTION( stepperArray_.size() == 0, std::logic_error, 00593 "Error! Rythmos::StackedStepper::takeStep: " 00594 "addStepper must be called at least once before takeStep!" 00595 ); 00596 this->setupSpaces_(); 00597 00598 #ifdef ENABLE_RYTHMOS_TIMERS 00599 TEUCHOS_FUNC_TIME_MONITOR("Rythmos:StackedStepper::takeStep"); 00600 #endif 00601 00602 if (Teuchos::is_null(stackedStepperStepStrategy_)) { 00603 stackedStepperStepStrategy_ = defaultStackedStepperStepStrategy<Scalar>(); 00604 } 00605 00606 Scalar dt_taken = Scalar(-ST::one()); 00607 for (int i=0 ; i<Teuchos::as<int>(stepperArray_.size()) ; ++i) { 00608 stackedStepperStepStrategy_->setupNextStepper(i,stepperArray_); 00609 Scalar local_dt_taken = stepperArray_[i]->takeStep(dt,stepType); 00610 dt_taken = stackedStepperStepStrategy_->evaluateStep( 00611 local_dt_taken, 00612 i, 00613 stepperArray_ 00614 ); 00615 } 00617 //RCP<StepperBase<Scalar> > baseStepper = stepperArray_[0]; 00618 //Scalar dt_taken = baseStepper->takeStep(dt,stepType); 00619 //for (int i=1 ; i<Teuchos::as<int>(stepperArray_.size()) ; ++i) { 00620 // // 07/27/09 tscoffe: This line should be handled by a strategy object 00621 // stepperArray_[i]->setStepControlData(*baseStepper); 00622 // Scalar local_dt_taken = stepperArray_[i]->takeStep(dt,stepType); 00623 // TEST_FOR_EXCEPTION( local_dt_taken != dt_taken, std::logic_error, 00624 // "Error! sub-stepper["<<i<<"] did not take the same " 00625 // "size step as the base stepper!" 00626 // ); 00627 //} 00628 return dt_taken; 00629 } 00630 00631 00632 template<class Scalar> 00633 const StepStatus<Scalar> 00634 StackedStepper<Scalar>::getStepStatus() const 00635 { 00636 TEST_FOR_EXCEPT(true); 00637 const StepStatus<Scalar> stepStatus; 00638 return stepStatus; 00639 00640 } 00641 00642 00643 // Overridden from InterpolationBufferBase 00644 00645 00646 template<class Scalar> 00647 RCP<const Thyra::VectorSpaceBase<Scalar> > 00648 StackedStepper<Scalar>::get_x_space() const 00649 { 00650 this->setupSpaces_(); 00651 TEST_FOR_EXCEPTION( is_null(x_bar_space_), std::logic_error, 00652 "Rythmos::StackedStepper::get_x_space(): " 00653 "addStepper must be called at least once before get_x_space()!" 00654 ); 00655 return(x_bar_space_); 00656 } 00657 00658 00659 template<class Scalar> 00660 void StackedStepper<Scalar>::addPoints( 00661 const Array<Scalar>& time_vec, 00662 const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > >& x_vec, 00663 const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec 00664 ) 00665 { 00666 TEST_FOR_EXCEPT( 00667 "Not implemented addPoints(...) yet but we could if we wanted!" 00668 ); 00669 } 00670 00671 00672 template<class Scalar> 00673 TimeRange<Scalar> 00674 StackedStepper<Scalar>::getTimeRange() const 00675 { 00676 TEST_FOR_EXCEPT(true); 00677 TimeRange<Scalar> tr; 00678 return tr; 00679 } 00680 00681 00682 template<class Scalar> 00683 void StackedStepper<Scalar>::getPoints( 00684 const Array<Scalar>& time_vec, 00685 Array<RCP<const Thyra::VectorBase<Scalar> > >* x_bar_vec, 00686 Array<RCP<const Thyra::VectorBase<Scalar> > >* x_bar_dot_vec, 00687 Array<ScalarMag>* accuracy_vec 00688 ) const 00689 { 00690 using Teuchos::as; 00691 this->setupSpaces_(); 00692 TEST_FOR_EXCEPTION( stepperArray_.size() == 0, std::logic_error, 00693 "Rythmos::StackedStepper:getPoints: Error! " 00694 "addStepper must be called at least once before getPoints!" 00695 ); 00696 int numSteppers = as<int>(stepperArray_.size()); 00697 int numTimePoints = as<int>(time_vec.size()); 00698 00699 // Set up local x_bar_vec for filling: 00700 Array<RCP<Thyra::VectorBase<Scalar> > > x_bar_vec_local; 00701 if (x_bar_vec != NULL) { 00702 x_bar_vec_local.clear(); 00703 x_bar_vec->clear(); 00704 for (int n = 0 ; n < numTimePoints ; ++n) { 00705 x_bar_vec_local.push_back(Thyra::createMember(this->get_x_space())); 00706 x_bar_vec->push_back(x_bar_vec_local[n]); 00707 } 00708 } 00709 00710 // Set up local x_bar_dot_vec for filling: 00711 Array<RCP<Thyra::VectorBase<Scalar> > > x_bar_dot_vec_local; 00712 if (x_bar_dot_vec != NULL) { 00713 x_bar_dot_vec_local.clear(); 00714 x_bar_dot_vec->clear(); 00715 for (int n = 0 ; n < numTimePoints ; ++n) { 00716 x_bar_dot_vec_local.push_back(Thyra::createMember(this->get_x_space())); 00717 x_bar_dot_vec->push_back(x_bar_dot_vec_local[n]); 00718 } 00719 } 00720 00721 // Set up accuracy_vec 00722 if (accuracy_vec) { 00723 accuracy_vec->clear(); 00724 accuracy_vec->resize(numTimePoints); 00725 } 00726 00727 for (int i=0 ; i < numSteppers; ++i) { 00728 Array<RCP<const Thyra::VectorBase<Scalar> > > sub_x_bar_vec; 00729 Array<RCP<const Thyra::VectorBase<Scalar> > > sub_x_bar_dot_vec; 00730 Array<ScalarMag> sub_accuracy_vec; 00731 stepperArray_[i]->getPoints( 00732 time_vec, 00733 x_bar_vec ? &sub_x_bar_vec : 0, 00734 x_bar_dot_vec ? &sub_x_bar_dot_vec : 0, 00735 accuracy_vec ? &sub_accuracy_vec: 0 00736 ); 00737 // Copy vectors into the sub-blocks of the 00738 // x_bar_vec, x_bar_dot_vec, and accuracy_vec vectors. 00739 for (int n=0; n < numTimePoints ; ++n ) { 00740 if (x_bar_vec) { 00741 RCP<Thyra::ProductVectorBase<Scalar> > x_bar_pv = 00742 Teuchos::rcp_dynamic_cast<Thyra::ProductVectorBase<Scalar> >( 00743 x_bar_vec_local[n], 00744 true 00745 ); 00746 RCP<Thyra::VectorBase<Scalar> > xi = 00747 x_bar_pv->getNonconstVectorBlock(i); 00748 V_V(Teuchos::outArg(*xi),*sub_x_bar_vec[n]); 00749 } 00750 if (x_bar_dot_vec) { 00751 RCP<Thyra::ProductVectorBase<Scalar> > x_bar_dot_pv = 00752 Teuchos::rcp_dynamic_cast<Thyra::ProductVectorBase<Scalar> >( 00753 x_bar_dot_vec_local[n], 00754 true 00755 ); 00756 RCP<Thyra::VectorBase<Scalar> > xdoti = 00757 x_bar_dot_pv->getNonconstVectorBlock(i); 00758 V_V(Teuchos::outArg(*xdoti),*sub_x_bar_dot_vec[n]); 00759 } 00760 // Just copy the accuracy from the first stepper: 00761 if ( (i == 0) && accuracy_vec) { 00762 (*accuracy_vec)[n] = sub_accuracy_vec[n]; 00763 } 00764 } 00765 } 00766 } 00767 00768 00769 template<class Scalar> 00770 void StackedStepper<Scalar>::getNodes( 00771 Array<Scalar>* time_vec 00772 ) const 00773 { 00774 TEST_FOR_EXCEPT(true); 00775 } 00776 00777 00778 template<class Scalar> 00779 void StackedStepper<Scalar>::removeNodes( 00780 Array<Scalar>& time_vec 00781 ) 00782 { 00783 TEST_FOR_EXCEPT("Not implemented yet but we can!"); 00784 } 00785 00786 00787 template<class Scalar> 00788 int StackedStepper<Scalar>::getOrder() const 00789 { 00790 TEST_FOR_EXCEPT(true); 00791 return -1; 00792 } 00793 00794 00795 // private 00796 00797 00798 } // namespace Rythmos 00799 00800 00801 #endif //RYTHMOS_STACKED_STEPPER_HPP
1.7.4