/usr/include/trilinos/Rythmos_StackedStepper.hpp is in libtrilinos-rythmos-dev 12.10.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 | //@HEADER
// ***********************************************************************
//
// Rythmos Package
// Copyright (2009) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
// USA
// Questions? Contact Todd S. Coffey (tscoffe@sandia.gov)
//
// ***********************************************************************
//@HEADER
#ifndef RYTHMOS_STACKED_STEPPER_HPP
#define RYTHMOS_STACKED_STEPPER_HPP
#include "Rythmos_StepperBase.hpp"
#include "Thyra_ModelEvaluatorHelpers.hpp"
#include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
#include "Teuchos_VerboseObjectParameterListHelpers.hpp"
#include "Teuchos_Assert.hpp"
#include "Teuchos_as.hpp"
// Includes for ForwardSensitivityStackedStepper
#include "Rythmos_ForwardSensitivityModelEvaluatorBase.hpp"
namespace Rythmos {
template<class Scalar>
class StackedStepperStepStrategyBase
{
public:
virtual ~StackedStepperStepStrategyBase() {}
virtual void setupNextStepper(
int i,
Array<RCP<StepperBase<Scalar> > > &stepperArray
) = 0;
virtual Scalar evaluateStep(
Scalar local_dt_taken,
int i,
Array<RCP<StepperBase<Scalar> > > &stepperArray
) = 0;
};
template<class Scalar>
class DefaultStackedStepperStepStrategy
: virtual public StackedStepperStepStrategyBase<Scalar>
{
public:
DefaultStackedStepperStepStrategy();
virtual ~DefaultStackedStepperStepStrategy();
void setupNextStepper(
int i,
Array<RCP<StepperBase<Scalar> > > &stepperArray
);
Scalar evaluateStep(
Scalar local_dt_taken,
int i,
Array<RCP<StepperBase<Scalar> > > &stepperArray
);
private:
Scalar dt_taken_;
};
// Nonmember constructor declaration
template<class Scalar>
RCP<DefaultStackedStepperStepStrategy<Scalar> >
defaultStackedStepperStepStrategy();
// Nonmember constructor definition
template<class Scalar>
RCP<DefaultStackedStepperStepStrategy<Scalar> >
defaultStackedStepperStepStrategy()
{
return Teuchos::rcp(new DefaultStackedStepperStepStrategy<Scalar>());
}
template<class Scalar>
DefaultStackedStepperStepStrategy<Scalar>::DefaultStackedStepperStepStrategy()
{
typedef Teuchos::ScalarTraits<Scalar> ST;
dt_taken_ = ST::nan();
}
template<class Scalar>
DefaultStackedStepperStepStrategy<Scalar>::~DefaultStackedStepperStepStrategy()
{
}
template<class Scalar>
void DefaultStackedStepperStepStrategy<Scalar>::setupNextStepper(
int i,
Array<RCP<StepperBase<Scalar> > > &stepperArray
)
{
if (i > 0) {
RCP<StepperBase<Scalar> > baseStepper = stepperArray[0];
stepperArray[i]->setStepControlData(*baseStepper);
}
}
template<class Scalar>
Scalar DefaultStackedStepperStepStrategy<Scalar>::evaluateStep(
Scalar local_dt_taken,
int i,
Array<RCP<StepperBase<Scalar> > > &stepperArray
)
{
if (i == 0) {
dt_taken_ = local_dt_taken;
}
else {
TEUCHOS_TEST_FOR_EXCEPTION( local_dt_taken != dt_taken_, std::logic_error,
"Error! sub-stepper["<<i<<"] did not take the same "
"size step as the base stepper!"
);
}
return dt_taken_;
}
template<class Scalar>
class ForwardSensitivityStackedStepperStepStrategy
: virtual public StackedStepperStepStrategyBase<Scalar>
{
public:
ForwardSensitivityStackedStepperStepStrategy();
virtual ~ForwardSensitivityStackedStepperStepStrategy();
void setupNextStepper(
int i,
Array<RCP<StepperBase<Scalar> > > &stepperArray
);
Scalar evaluateStep(
Scalar local_dt_taken,
int i,
Array<RCP<StepperBase<Scalar> > > &stepperArray
);
void setStateBasePoint(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> &stateBasePoint
);
private:
Scalar dt_taken_;
Thyra::ModelEvaluatorBase::InArgs<Scalar> stateBasePoint_;
};
// Nonmember constructor declaration
template<class Scalar>
RCP<ForwardSensitivityStackedStepperStepStrategy<Scalar> >
forwardSensitivityStackedStepperStepStrategy();
// Nonmember constructor definition
template<class Scalar>
RCP<ForwardSensitivityStackedStepperStepStrategy<Scalar> >
forwardSensitivityStackedStepperStepStrategy()
{
return Teuchos::rcp(new ForwardSensitivityStackedStepperStepStrategy<Scalar>());
}
template<class Scalar>
ForwardSensitivityStackedStepperStepStrategy<Scalar>::ForwardSensitivityStackedStepperStepStrategy()
{
typedef Teuchos::ScalarTraits<Scalar> ST;
dt_taken_ = ST::nan();
}
template<class Scalar>
ForwardSensitivityStackedStepperStepStrategy<Scalar>::~ForwardSensitivityStackedStepperStepStrategy()
{
}
template<class Scalar>
void ForwardSensitivityStackedStepperStepStrategy<Scalar>::setupNextStepper(
int i,
Array<RCP<StepperBase<Scalar> > > &stepperArray
)
{
typedef Thyra::ModelEvaluatorBase MEB;
if (i > 0) {
RCP<StepperBase<Scalar> > baseStepper = stepperArray[0];
RCP<Thyra::ModelEvaluator<Scalar> > modelI =
// TODO: 09/09/09 tscoffe: This should be replaced by
// getNonconstModel() when it is implemented correctly.
Teuchos::rcp_const_cast<Thyra::ModelEvaluator<Scalar> >(
stepperArray[i]->getModel()
);
RCP<ForwardSensitivityModelEvaluatorBase<Scalar> > fwdSensME =
Teuchos::rcp_dynamic_cast<ForwardSensitivityModelEvaluatorBase<Scalar> > (
modelI,false
);
if (Teuchos::nonnull(fwdSensME)) {
bool forceUpToDateW = true;
fwdSensME->initializePointState( Teuchos::inOutArg(*baseStepper), forceUpToDateW);
}
stepperArray[i]->setStepControlData(*baseStepper);
}
}
template<class Scalar>
Scalar ForwardSensitivityStackedStepperStepStrategy<Scalar>::evaluateStep(
Scalar local_dt_taken,
int i,
Array<RCP<StepperBase<Scalar> > > &stepperArray
)
{
if (i == 0) {
dt_taken_ = local_dt_taken;
}
else {
TEUCHOS_TEST_FOR_EXCEPTION( local_dt_taken != dt_taken_, std::logic_error,
"Error! sub-stepper["<<i<<"] did not take the same "
"size step as the base stepper!"
);
}
return dt_taken_;
}
template<class Scalar>
void ForwardSensitivityStackedStepperStepStrategy<Scalar>::setStateBasePoint(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> &stateBasePoint
)
{
stateBasePoint_ = stateBasePoint;
}
template<class Scalar>
class StackedStepper
: virtual public StepperBase<Scalar>,
virtual public Teuchos::ParameterListAcceptorDefaultBase
{
public:
/** \brief . */
typedef typename Teuchos::ScalarTraits<Scalar>::magnitudeType ScalarMag;
/** \name Constructors, Intializers, Misc. */
//@{
/** \brief Constructs to uninitialized. */
StackedStepper();
/** \brief Add a stepper to the stack
*/
void addStepper(const RCP<StepperBase<Scalar> >& stepper);
/** \brief Return the steppers that were passed into addStepper
*/
ArrayView<const RCP<StepperBase<Scalar> > > getNonconstSteppers() const;
/** \brief Add a Step Control Strategy
*/
void setStackedStepperStepControlStrategy(
const RCP<StackedStepperStepStrategyBase<Scalar> >& stepControl
);
/** \brief Get the Step Control Strategy
*/
RCP<const StackedStepperStepStrategyBase<Scalar> >
getStackedStepperStepCongrolStrategy() const;
//@}
/** \name Overridden from Teuchos::ParameterListAcceptor */
//@{
/** \brief . */
void setParameterList(RCP<Teuchos::ParameterList> const& paramList);
/** \brief . */
RCP<const Teuchos::ParameterList> getValidParameters() const;
//@}
/** \name Overridden from StepperBase */
//@{
/** \brief Returns false. */
bool acceptsModel() const;
/** \brief Throws exception. */
void setModel(
const RCP<const Thyra::ModelEvaluator<Scalar> >& model
);
/** \brief Throws exception. */
void setNonconstModel(
const RCP<Thyra::ModelEvaluator<Scalar> >& model
);
/** \brief Returns <tt>getStateAndFwdSensModel()</tt>.
*
* Warning, currently the returned model does not implement evalModel(...)
* or define a W object. It is just used for getting the spaces and for
* creating an InArgs object for setting the initial condition.
*/
RCP<const Thyra::ModelEvaluator<Scalar> > getModel() const;
/** \brief . */
RCP<Thyra::ModelEvaluator<Scalar> > getNonconstModel();
/** \brief Sets the full initial condition for
* <tt>x_bar = [ x^{N} ]_{N=0..numSteppers} </tt>
*
* The InArgs object must be created using
* <tt>this->getModel()->createInArgs()</tt> and then populated with the
* initial values. The product vectors for <tt>x_bar</tt> and
* <tt>x_bar_dot</tt> can be created using
* <tt>this->getModel()->create_x_bar_vec(...)</tt>. All of
* the input objects in <tt>state_ic</tt> will be cloned and
* therefore no memory of the objects in <tt>state_ic</tt> will be
* retained after calling this function.
*/
void setInitialCondition(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> &stacked_ic
);
/* \brief Get the initial condigion
*/
Thyra::ModelEvaluatorBase::InArgs<Scalar> getInitialCondition() const;
/** \brief . */
Scalar takeStep( Scalar dt, StepSizeType stepType );
/** \brief . */
const StepStatus<Scalar> getStepStatus() const;
//@}
/** \name Overridden from InterpolationBufferBase */
//@{
/** \brief Returns the space for <tt>x_bar</tt> and <tt>x_bar_dot</tt>.
*
* This space is a nested product vector space as described above. Dynamic
* casting is required to get at the <tt>ProductVectorSpaceBase</tt> and
* <tt>ProductVectorBase</tt> intefaces.
*/
RCP<const Thyra::VectorSpaceBase<Scalar> >
get_x_space() const;
/** \brief . */
void addPoints(
const Array<Scalar>& time_vec,
const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > >& x_vec,
const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec
);
/** \brief . */
TimeRange<Scalar> getTimeRange() const;
/** \brief . */
void getPoints(
const Array<Scalar>& time_vec,
Array<RCP<const Thyra::VectorBase<Scalar> > >* x_vec,
Array<RCP<const Thyra::VectorBase<Scalar> > >* xdot_vec,
Array<ScalarMag>* accuracy_vec
) const;
/** \brief . */
void getNodes(Array<Scalar>* time_vec) const;
/** \brief . */
void removeNodes(Array<Scalar>& time_vec);
/** \brief . */
int getOrder() const;
//@}
private:
mutable bool isInitialized_;
Array<RCP<StepperBase<Scalar> > > stepperArray_;
mutable Array<RCP<const Thyra::VectorSpaceBase<Scalar> > > xSpaceArray_;
//Array<RCP<const Thyra::VectorSpaceBase<Scalar> > > fSpaceArray_;
mutable Teuchos::RCP<const Thyra::ProductVectorSpaceBase<Scalar> >
x_bar_space_;
//Teuchos::RCP<const Thyra::ProductVectorSpaceBase<Scalar> >
// f_bar_space_;
RCP<StackedStepperStepStrategyBase<Scalar> > stackedStepperStepStrategy_;
// Private functions:
void setupSpaces_() const;
};
/** \brief Nonmember constructor.
*
* \relates StackedStepper
*/
template<class Scalar>
inline
RCP<StackedStepper<Scalar> >
stackedStepper()
{
return Teuchos::rcp(new StackedStepper<Scalar>());
}
// Constructors, Intializers, Misc.
template<class Scalar>
StackedStepper<Scalar>::StackedStepper()
: isInitialized_(false)
{}
template<class Scalar>
void StackedStepper<Scalar>::setupSpaces_() const
{
using Teuchos::as;
if (!isInitialized_) {
for (int i=0 ; i < as<int>(stepperArray_.size()) ; ++i) {
xSpaceArray_.push_back(stepperArray_[i]->get_x_space());
//fSpaceArray_.push_back(stepperArray_[i]->get_f_space());
}
x_bar_space_ = Thyra::productVectorSpace<Scalar>(xSpaceArray_);
//f_bar_space_ = Thyra::productVectorSpace<Scalar>(fSpaceArray_);
isInitialized_ = true;
}
}
template<class Scalar>
void StackedStepper<Scalar>::addStepper(
const RCP<StepperBase<Scalar> >& stepper
)
{
TEUCHOS_ASSERT(!is_null(stepper));
stepperArray_.push_back(stepper);
isInitialized_ = false;
}
template<class Scalar>
ArrayView<const RCP<StepperBase<Scalar> > >
StackedStepper<Scalar>::getNonconstSteppers() const
{
return stepperArray_();
}
template<class Scalar>
void StackedStepper<Scalar>::setStackedStepperStepControlStrategy(
const RCP<StackedStepperStepStrategyBase<Scalar> >& stepControl
)
{
TEUCHOS_ASSERT( Teuchos::nonnull(stepControl) );
stackedStepperStepStrategy_ = stepControl;
}
template<class Scalar>
RCP<const StackedStepperStepStrategyBase<Scalar> >
StackedStepper<Scalar>::getStackedStepperStepCongrolStrategy() const
{
return stackedStepperStepStrategy_;
}
template<class Scalar>
void StackedStepper<Scalar>::setParameterList(
RCP<Teuchos::ParameterList> const& paramList
)
{
TEUCHOS_TEST_FOR_EXCEPT(is_null(paramList));
paramList->validateParameters(*getValidParameters());
this->setMyParamList(paramList);
Teuchos::readVerboseObjectSublist(&*paramList,this);
}
template<class Scalar>
RCP<const Teuchos::ParameterList>
StackedStepper<Scalar>::getValidParameters() const
{
static RCP<const ParameterList> validPL;
if (is_null(validPL) ) {
RCP<ParameterList> pl = Teuchos::parameterList();
Teuchos::setupVerboseObjectSublist(&*pl);
validPL = pl;
}
return validPL;
}
// Overridden from StepperBase
template<class Scalar>
bool StackedStepper<Scalar>::acceptsModel() const
{
return false;
}
template<class Scalar>
void StackedStepper<Scalar>::setModel(
const RCP<const Thyra::ModelEvaluator<Scalar> >& model
)
{
TEUCHOS_TEST_FOR_EXCEPT_MSG( true,
"Error, this stepper subclass does not accept a model"
" as defined by the StepperBase interface!");
}
template<class Scalar>
void StackedStepper<Scalar>::setNonconstModel(
const RCP<Thyra::ModelEvaluator<Scalar> >& model
)
{
TEUCHOS_TEST_FOR_EXCEPT_MSG( true,
"Error, this stepper subclass does not accept a model"
" as defined by the StepperBase interface!");
}
template<class Scalar>
RCP<const Thyra::ModelEvaluator<Scalar> >
StackedStepper<Scalar>::getModel() const
{
TEUCHOS_TEST_FOR_EXCEPT(true);
return Teuchos::null;
}
template<class Scalar>
RCP<Thyra::ModelEvaluator<Scalar> >
StackedStepper<Scalar>::getNonconstModel()
{
TEUCHOS_TEST_FOR_EXCEPT(true);
return Teuchos::null;
}
template<class Scalar>
void StackedStepper<Scalar>::setInitialCondition(
const Thyra::ModelEvaluatorBase::InArgs<Scalar> &stacked_ic
)
{
TEUCHOS_TEST_FOR_EXCEPT(true);
}
template<class Scalar>
Thyra::ModelEvaluatorBase::InArgs<Scalar>
StackedStepper<Scalar>::getInitialCondition() const
{
TEUCHOS_TEST_FOR_EXCEPT(true);
Thyra::ModelEvaluatorBase::InArgs<Scalar> inArgs;
return inArgs;
}
template<class Scalar>
Scalar
StackedStepper<Scalar>::takeStep(
Scalar dt, StepSizeType stepType
)
{
typedef Teuchos::ScalarTraits<Scalar> ST;
TEUCHOS_TEST_FOR_EXCEPTION( stepperArray_.size() == 0, std::logic_error,
"Error! Rythmos::StackedStepper::takeStep: "
"addStepper must be called at least once before takeStep!"
);
this->setupSpaces_();
RYTHMOS_FUNC_TIME_MONITOR("Rythmos:StackedStepper::takeStep");
if (Teuchos::is_null(stackedStepperStepStrategy_)) {
stackedStepperStepStrategy_ = defaultStackedStepperStepStrategy<Scalar>();
}
Scalar dt_taken = Scalar(-ST::one());
for (int i=0 ; i<Teuchos::as<int>(stepperArray_.size()) ; ++i) {
stackedStepperStepStrategy_->setupNextStepper(i,stepperArray_);
Scalar local_dt_taken = stepperArray_[i]->takeStep(dt,stepType);
dt_taken = stackedStepperStepStrategy_->evaluateStep(
local_dt_taken,
i,
stepperArray_
);
}
//// We cascade information from the first stepper to all the other steppers.
//RCP<StepperBase<Scalar> > baseStepper = stepperArray_[0];
//Scalar dt_taken = baseStepper->takeStep(dt,stepType);
//for (int i=1 ; i<Teuchos::as<int>(stepperArray_.size()) ; ++i) {
// // 07/27/09 tscoffe: This line should be handled by a strategy object
// stepperArray_[i]->setStepControlData(*baseStepper);
// Scalar local_dt_taken = stepperArray_[i]->takeStep(dt,stepType);
// TEUCHOS_TEST_FOR_EXCEPTION( local_dt_taken != dt_taken, std::logic_error,
// "Error! sub-stepper["<<i<<"] did not take the same "
// "size step as the base stepper!"
// );
//}
return dt_taken;
}
template<class Scalar>
const StepStatus<Scalar>
StackedStepper<Scalar>::getStepStatus() const
{
TEUCHOS_TEST_FOR_EXCEPT(true);
const StepStatus<Scalar> stepStatus;
return stepStatus;
}
// Overridden from InterpolationBufferBase
template<class Scalar>
RCP<const Thyra::VectorSpaceBase<Scalar> >
StackedStepper<Scalar>::get_x_space() const
{
this->setupSpaces_();
TEUCHOS_TEST_FOR_EXCEPTION( is_null(x_bar_space_), std::logic_error,
"Rythmos::StackedStepper::get_x_space(): "
"addStepper must be called at least once before get_x_space()!"
);
return(x_bar_space_);
}
template<class Scalar>
void StackedStepper<Scalar>::addPoints(
const Array<Scalar>& time_vec,
const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > >& x_vec,
const Array<Teuchos::RCP<const Thyra::VectorBase<Scalar> > >& xdot_vec
)
{
TEUCHOS_TEST_FOR_EXCEPT(
"Not implemented addPoints(...) yet but we could if we wanted!"
);
}
template<class Scalar>
TimeRange<Scalar>
StackedStepper<Scalar>::getTimeRange() const
{
TEUCHOS_TEST_FOR_EXCEPT(true);
TimeRange<Scalar> tr;
return tr;
}
template<class Scalar>
void StackedStepper<Scalar>::getPoints(
const Array<Scalar>& time_vec,
Array<RCP<const Thyra::VectorBase<Scalar> > >* x_bar_vec,
Array<RCP<const Thyra::VectorBase<Scalar> > >* x_bar_dot_vec,
Array<ScalarMag>* accuracy_vec
) const
{
using Teuchos::as;
this->setupSpaces_();
TEUCHOS_TEST_FOR_EXCEPTION( stepperArray_.size() == 0, std::logic_error,
"Rythmos::StackedStepper:getPoints: Error! "
"addStepper must be called at least once before getPoints!"
);
int numSteppers = as<int>(stepperArray_.size());
int numTimePoints = as<int>(time_vec.size());
// Set up local x_bar_vec for filling:
Array<RCP<Thyra::VectorBase<Scalar> > > x_bar_vec_local;
if (x_bar_vec != NULL) {
x_bar_vec_local.clear();
x_bar_vec->clear();
for (int n = 0 ; n < numTimePoints ; ++n) {
x_bar_vec_local.push_back(Thyra::createMember(this->get_x_space()));
x_bar_vec->push_back(x_bar_vec_local[n]);
}
}
// Set up local x_bar_dot_vec for filling:
Array<RCP<Thyra::VectorBase<Scalar> > > x_bar_dot_vec_local;
if (x_bar_dot_vec != NULL) {
x_bar_dot_vec_local.clear();
x_bar_dot_vec->clear();
for (int n = 0 ; n < numTimePoints ; ++n) {
x_bar_dot_vec_local.push_back(Thyra::createMember(this->get_x_space()));
x_bar_dot_vec->push_back(x_bar_dot_vec_local[n]);
}
}
// Set up accuracy_vec
if (accuracy_vec) {
accuracy_vec->clear();
accuracy_vec->resize(numTimePoints);
}
for (int i=0 ; i < numSteppers; ++i) {
Array<RCP<const Thyra::VectorBase<Scalar> > > sub_x_bar_vec;
Array<RCP<const Thyra::VectorBase<Scalar> > > sub_x_bar_dot_vec;
Array<ScalarMag> sub_accuracy_vec;
stepperArray_[i]->getPoints(
time_vec,
x_bar_vec ? &sub_x_bar_vec : 0,
x_bar_dot_vec ? &sub_x_bar_dot_vec : 0,
accuracy_vec ? &sub_accuracy_vec: 0
);
// Copy vectors into the sub-blocks of the
// x_bar_vec, x_bar_dot_vec, and accuracy_vec vectors.
for (int n=0; n < numTimePoints ; ++n ) {
if (x_bar_vec) {
RCP<Thyra::ProductVectorBase<Scalar> > x_bar_pv =
Teuchos::rcp_dynamic_cast<Thyra::ProductVectorBase<Scalar> >(
x_bar_vec_local[n],
true
);
RCP<Thyra::VectorBase<Scalar> > xi =
x_bar_pv->getNonconstVectorBlock(i);
V_V(Teuchos::outArg(*xi),*sub_x_bar_vec[n]);
}
if (x_bar_dot_vec) {
RCP<Thyra::ProductVectorBase<Scalar> > x_bar_dot_pv =
Teuchos::rcp_dynamic_cast<Thyra::ProductVectorBase<Scalar> >(
x_bar_dot_vec_local[n],
true
);
RCP<Thyra::VectorBase<Scalar> > xdoti =
x_bar_dot_pv->getNonconstVectorBlock(i);
V_V(Teuchos::outArg(*xdoti),*sub_x_bar_dot_vec[n]);
}
// Just copy the accuracy from the first stepper:
if ( (i == 0) && accuracy_vec) {
(*accuracy_vec)[n] = sub_accuracy_vec[n];
}
}
}
}
template<class Scalar>
void StackedStepper<Scalar>::getNodes(
Array<Scalar>* time_vec
) const
{
TEUCHOS_TEST_FOR_EXCEPT(true);
}
template<class Scalar>
void StackedStepper<Scalar>::removeNodes(
Array<Scalar>& time_vec
)
{
TEUCHOS_TEST_FOR_EXCEPT("Not implemented yet but we can!");
}
template<class Scalar>
int StackedStepper<Scalar>::getOrder() const
{
TEUCHOS_TEST_FOR_EXCEPT(true);
return -1;
}
// private
} // namespace Rythmos
#endif //RYTHMOS_STACKED_STEPPER_HPP
|