Rythmos - Transient Integration for Differential Equations Version of the Day
Rythmos_IntegratorBuilder_def.hpp
00001 //@HEADER
00002 // ***********************************************************************
00003 //
00004 //                           Rythmos Package
00005 //                 Copyright (2006) 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 
00030 #ifndef Rythmos_INTEGRATOR_BUILDER_DEF_H
00031 #define Rythmos_INTEGRATOR_BUILDER_DEF_H
00032 
00033 // Rythmos classes:
00034 #include "Rythmos_IntegratorBuilder_decl.hpp"
00035 #include "Rythmos_IntegrationControlStrategyAcceptingIntegratorBase.hpp"
00036 #include "Rythmos_SolverAcceptingStepperBase.hpp"
00037 
00038 // Teuchos:
00039 #include "Teuchos_as.hpp"
00040 
00041 // Specific objects to seed the builder:
00042 #include "Rythmos_DefaultIntegrator.hpp"
00043 #include "Rythmos_SimpleIntegrationControlStrategy.hpp"
00044 #include "Rythmos_RampingIntegrationControlStrategy.hpp"
00045 #include "Rythmos_FixedStepControlStrategy.hpp"
00046 #include "Rythmos_SimpleStepControlStrategy.hpp"
00047 #include "Rythmos_FirstOrderErrorStepControlStrategy.hpp"
00048 #include "Rythmos_ImplicitBDFStepperStepControl.hpp"
00049 #include "Rythmos_ImplicitBDFStepperRampingStepControl.hpp"
00050 #include "Rythmos_InterpolationBuffer.hpp"
00051 #include "Rythmos_PointwiseInterpolationBufferAppender.hpp"
00052 //#include "Rythmos_SmartInterpolationBufferAppender.hpp"
00053 #include "Rythmos_ImplicitBDFStepperErrWtVecCalc.hpp"
00054 #include "Rythmos_LinearInterpolator.hpp"
00055 #include "Rythmos_HermiteInterpolator.hpp"
00056 #include "Rythmos_CubicSplineInterpolator.hpp"
00057 
00058 // Includes for the Forward Sensitivity Integrator Builder:
00059 #include "Rythmos_ForwardSensitivityStepper.hpp"
00060 
00061 
00062 namespace {
00063 
00064   // Valid ParameterList names:
00065   static std::string integratorSettings_name = "Integrator Settings";
00066   static std::string integratorSettings_docs =
00067     "These parameters are used directly in setting up the Integrator.";
00068   static std::string integratorSelection_name = "Integrator Selection";
00069   static std::string integratorSelection_docs =
00070     "Select the Integrator to be used.";
00071   static std::string integrationControlSelection_name =
00072     "Integration Control Strategy Selection";
00073   static std::string integrationControlSelection_docs =
00074     "Note that some settings conflict between step control and integration "
00075     "control.  In general, the integration control decides which steps will "
00076     "be fixed or variable, not the stepper.  When the integration control "
00077     "decides to take variable steps, the step control is then responsible "
00078     "for choosing appropriate step-sizes.";
00079   static std::string stepperSettings_name = "Stepper Settings";
00080   static std::string stepperSettings_docs =
00081     "This parameter list sets various parameters for the Stepper.";
00082   static std::string stepperSelection_name = "Stepper Selection";
00083   static std::string stepperSelection_docs =
00084     "Selects the Stepper for the time integration.  It should be that "
00085     "some time integrators can be accessed through different Steppers, "
00086     "e.g., Backward Euler can be obtained through the `Backward Euler', "
00087     "a first-order `Implicit BDF', or a one-stage `Implicit RK' Stepper."
00088     "Special note for `Implicit RK' Stepper:  If a fully implicit RK Butcher "
00089     "tableau is chosen, then the stepper will not be fully initialized "
00090     "unless a W factory object is set on the IntegratorBuilder through "
00091     "setWFactoryObject.";
00092   static std::string ForwardEulerStepper_name = "Forward Euler";
00093   static std::string ForwardEulerStepper_docs =
00094     "This is the basic Forward Euler method: x_n = x_{n-1} + dt*x_dot_{n-1}";
00095   static std::string BackwardEulerStepper_name = "Backward Euler";
00096   static std::string BackwardEulerStepper_docs =
00097     "This is the basic Backward Euler method: x_n = x_{n-1} + dt*x_dot_n";
00098   static std::string ImplicitBDFStepper_name = "Implicit BDF";
00099   static std::string ImplicitBDFStepper_docs =
00100     "This Stepper provides a re-implementation of the algorithms in "
00101     "the LLNL Sundials code IDA. This is an implicit BDF integrator "
00102     "for DAEs which uses variable step-sizes and variable-orders "
00103     "first through fourth.";
00104   static std::string rkButcherTableauSelection_name =
00105     "Runge Kutta Butcher Tableau Selection";
00106   static std::string rkButcherTableauSelection_docs =
00107     "Only the Explicit RK Stepper and the Implicit RK Stepper accept an "
00108     "RK Butcher Tableau.";
00109   static std::string ExplicitRKStepper_name = "Explicit RK";
00110   static std::string ExplicitRKStepper_docs =
00111     "This Stepper has many explicit time-integrators using Runge-Kutta "
00112     "formulation and the Butcher Tableau specification.  See `"
00113     +rkButcherTableauSelection_name+"' ParameterList for available options.";
00114   static std::string ImplicitRKStepper_name = "Implicit RK";
00115   static std::string ImplicitRKStepper_docs =
00116     "This Stepper has many implicit time-integrators using Runge-Kutta "
00117     "formulation and the Butcher Tableau specification.  See `"
00118     +rkButcherTableauSelection_name+"' ParameterList for available options.";
00119   static std::string stepControlSettings_name = "Step Control Settings";
00120   static std::string stepControlSettings_docs =
00121     "Not all step control strategies are compatible with each stepper.  "
00122     "If the strategy has the name of a stepper in its name, then it only "
00123     "works with that stepper.";
00124   static std::string stepControlSelection_name =
00125     "Step Control Strategy Selection";
00126   static std::string stepControlSelection_docs =
00127     "Used to select the Control Strategy for the stepper.";
00128   static std::string errWtVecSelection_name =
00129     "Error Weight Vector Calculator Selection";
00130   static std::string errWtVecSelection_docs =
00131     "Not all ErrWtVec calculators are compatible with each step control "
00132     "strategy.  If the calculator has the name of a stepper or another "
00133     "step control strategy in its name, then it only works with that step "
00134     "control strategy.";
00135   static std::string interpolationBufferSettings_name =
00136     "Interpolation Buffer Settings";
00137   static std::string interpolationBufferSettings_docs =
00138     "This parameter list sets various parameters for the InterpolationBuffer.";
00139   static std::string interpolationBufferSelection_name =
00140     "Trailing Interpolation Buffer Selection";
00141   static std::string interpolationBufferSelection_docs =
00142     "Used to select the Interpolation Buffer.";
00143   static std::string interpolationBufferAppenderSelection_name =
00144    "Interpolation Buffer Appender Selection";
00145   static std::string interpolationBufferAppenderSelection_docs =
00146    "Used to select the Interpolation Buffer Appender.";
00147   static std::string initialTime_name = "Initial Time";
00148   static int initialTime_default = 0; // Should be Scalar(0.0)
00149   static std::string initialTime_docs =
00150     "The initial time to start integration.";
00151   static std::string finalTime_name = "Final Time";
00152   static int finalTime_default = 1; // Should be Scalar(1.0)
00153   static std::string finalTime_docs = "The final time to end integration.";
00154   static std::string landOnFinalTime_name = "Land On Final Time";
00155   static bool landOnFinalTime_default = true;
00156   static std::string landOnFinalTime_docs =
00157     "Exactly land on the final time; do not step past final time and "
00158     "interpolate.";
00159   static std::string interpolatorSelection_name = "Interpolator Selection";
00160   static std::string interpolatorSelection_docs =
00161     "Choose the interpolator to use.";
00162   static std::string stepperInterpolatorSelection_docs =
00163     "Note all Steppers accept an interpolator.  Currently, only the "
00164     "BackwardEuler stepper does.";
00165 
00166   // Builder names:
00167   static std::string integratorBuilder_name = "Rythmos::Integrator";
00168   static std::string integratorBuilderType_name = "Integrator Type";
00169   static std::string integrationControlBuilder_name =
00170     "Rythmos::IntegrationControlStrategy";
00171   static std::string integrationControlBuilderType_name =
00172     "Integration Control Strategy Type";
00173   static std::string stepControlBuilder_name =
00174     "Rythmos::StepControlStrategy";
00175   static std::string stepControlBuilderType_name =
00176     "Step Control Strategy Type";
00177   static std::string interpolationBufferBuilder_name =
00178     "Rythmos::InterpolationBuffer";
00179   static std::string interpolationBufferBuilderType_name =
00180     "Interpolation Buffer Type";
00181   static std::string interpolationBufferAppenderBuilder_name =
00182     "Rythmos::InterpolationBufferAppender";
00183   static std::string interpolationBufferAppenderBuilderType_name =
00184     "Interpolation Buffer Appender Type";
00185   static std::string errWtVecCalcBuilder_name = "Rythmos::ErrWtVecCalc";
00186   static std::string errWtVecCalcBuilderType_name =
00187     "Error Weight Vector Calculator Type";
00188   static std::string interpolatorBuilder_name = "Rythmos::Interpolator";
00189   static std::string interpolatorBuilderType_name = "Interpolator Type";
00190 
00191   // Specific object names:
00192   static std::string defaultIntegrator_name = "Default Integrator";
00193   static std::string defaultIntegrator_docs =
00194     "This Integrator will accept an IntergationControlStrategy, and "
00195     "can have an IntegrationObserver.  The client can specify the "
00196     "maximum number of time steps allowed.  The Integrator will loop "
00197     "over the Stepper until it reaches the requested time. For each "
00198     "step, the step size will be determined through a couple "
00199     "mechanisms/filters.  If an Integration Control Strategy has "
00200     "been specified, the step size and the step type (fixed or "
00201     "variable) will be determined by it.  Otherwise the step size "
00202     "will be set to the maximum real value and the step type will "
00203     "be variable.  Next if the step size is beyond the final time "
00204     "and the `"+landOnFinalTime_name+"' is specified, the step size is "
00205     "adjusted to advance the state to the final time.  The Stepper "
00206     "is passed this step size and type to advance the state.  The "
00207     "DefaultIntegrator determines the step size and type taken by "
00208     "the Stepper, and if the step has failed.  If the "
00209     "IntegrationControlStrategy handles failures, it can suggest "
00210     "another step size and retry with the Stepper.  Otherwise, the "
00211     "Integrator will fall through with a failure.  With a successful "
00212     "step of the Stepper, the Integrator repeats the above until it "
00213     "reaches the requested time.  Multiple requested times can be "
00214     "passed to the Integrator.";
00215   static std::string simpleIntegrationControl_name =
00216     "Simple Integration Control Strategy";
00217   static std::string simpleIntegrationControl_docs =
00218     "This Integration Control Strategy is meant to be simple with "
00219     "very few parameters controlling it.  Basically the client can "
00220     "select fixed step type (the Stepper can only take the requested "
00221     "step size) or variable step type (the Stepper can adjust the step "
00222     "size to meet accuracy, order, or other criteria).  For fixed step "
00223     "type, the client can specify the step size and number of steps. "
00224     "For variable step type, the client can set the maximum step size "
00225     "allowable.";
00226   static std::string rampingIntegrationControl_name =
00227     "Ramping Integration Control Strategy";
00228   static std::string rampingIntegrationControl_docs =
00229     "This Integration Control Strategy is very similar to `"
00230     +simpleIntegrationControl_name+"' except for handling an initial "
00231     "constant-sized steps followed by a ramped-fixed-sized steps, "
00232     "and finally variable- or fixed-sized steps.  The client needs to "
00233     "additionally set the initial step size and the maximum number of "
00234     "step failures allowed.";
00235   static std::string rampErrIntegrationControl_name =
00236     "Ramp and Error Integration Control Strategy";
00237   static std::string fixedStepControl_name = "Fixed Step Control Strategy";
00238   static std::string fixedStepControl_docs =
00239     "This Step Control Strategy can be used for Steppers setup for "
00240     "variable step type (a stepper that can adjust its step size based "
00241     "on accuracy, order or other criteria), but would like to make fixed "
00242     "step sizes or used fixed step size as its default.\n";
00243   static std::string simpleStepControl_name = "Simple Step Control Strategy";
00244   static std::string simpleStepControl_docs =
00245     "This Step Control Strategy starts with the initial step size, "
00246     "and simply increases or decreases the step size by the "
00247     "appropriate factor which is based on the change in the "
00248     "solution relative to the specified relative and absolute "
00249     "tolerances (|dx| < r*|x| + a) and if solution status from the "
00250     "solver passes.  Additionally the step size is bounded by the "
00251     "miminum and maximum step size, and the stepper will fail if "
00252     "the step size fails more than the specified value.";
00253   static std::string implicitBDFStepControl_name =
00254     "Implicit BDF Stepper Step Control Strategy";
00255   static std::string implicitBDFStepControl_docs =
00256     "This Step Control Strategy is specifically for use with the `"
00257     +ImplicitBDFStepper_name+"' Stepper.  The parameters in this list "
00258     "and sublist are directly related to those available in SUNDAILS/IDA.  "
00259     "See Hindmarsh, `The PVODE and IDA Algorithms', 2000 for more details. ";
00260   static std::string implicitBDFStepperErrWtVecCalc_name =
00261     "Implicit BDF Stepper Error Weight Vector Calculator";
00262   static std::string implicitBDFStepperErrWtVecCalc_docs =
00263     "This Error Weight Vector Calculator is specifically for use with the `"
00264     +ImplicitBDFStepper_name+"' Stepper.";
00265   static std::string firstOrderErrorStepControl_name =
00266     "First Order Error Step Control Strategy";
00267   static std::string firstOrderErrorStepControl_docs =
00268     "This Step Control Strategy produces a step size based on a first-order "
00269     "predictor (Forward Euler) and a first-order solution (Backward Euler) by "
00270     "by using a weight norm of the difference between the predicted and "
00271     "solution.  See Gresho and Sani, `Incompressible Flow and the Finite "
00272     "Element Method', Vol. 1, 1998, p. 268.";
00273   static std::string implicitBDFRampingStepControl_name =
00274     "Implicit BDF Stepper Ramping Step Control Strategy";
00275   static std::string implicitBDFRampingStepControl_docs =
00276     "This Step Control Strategy is specifically for use with the `"
00277     +ImplicitBDFStepper_name+"' Stepper, and has a two-phase approach: "
00278     "constant step sizes and followed by variable step sizes.  The step "
00279     "size is adjusted based on the WRMS, see "
00280     +implicitBDFStepperErrWtVecCalc_name;
00281   static std::string defaultInterpolationBuffer_name = "Interpolation Buffer";
00282   static std::string defaultInterpolationBuffer_docs =
00283     "Sets parameters for the Interpolation Buffer.";
00284   static std::string pointwiseInterpolationBufferAppender_name =
00285     "Pointwise Interpolation Buffer Appender";
00286   static std::string pointwiseInterpolationBufferAppender_docs =
00287     "Appender that just transfers nodes without any regard for accuracy or "
00288     "order.";
00289 //  static std::string smartInterpolationBufferAppender_name =
00290 //    "Smart Interpolation Buffer Appender";
00291   static std::string linearInterpolator_name = "Linear Interpolator";
00292   static std::string linearInterpolator_docs =
00293     "This provides a simple linear interpolation between time nodes.";
00294   static std::string hermiteInterpolator_name = "Hermite Interpolator";
00295   static std::string hermiteInterpolator_docs =
00296     "This provides a piecewise cubic Hermite interpolation on each interval "
00297     "where the data is the solution and its time derivatives at the end "
00298     "points of the interval.  It will match 3rd degree polynomials exactly "
00299     "with both function values and derivatives.";
00300   static std::string cubicSplineInterpolator_name = "Cubic Spline Interpolator";
00301   static std::string cubicSplineInterpolator_docs =
00302     "This provides a cubic spline interpolation between time nodes.";
00303 
00304 } // namespace
00305 
00306 
00307 namespace Rythmos {
00308 
00309 
00310 template<class Scalar>
00311 IntegratorBuilder<Scalar>::IntegratorBuilder()
00312 {
00313   this->initializeDefaults_();
00314 }
00315 
00316 
00317 template<class Scalar>
00318 IntegratorBuilder<Scalar>::~IntegratorBuilder()
00319 {
00320 }
00321 
00322 
00323 template<class Scalar>
00324 void IntegratorBuilder<Scalar>::setIntegratorFactory(
00325   const RCP<const Teuchos::AbstractFactory<IntegratorBase<Scalar> > > &integratorFactory,
00326   const std::string &integratorName
00327   )
00328 {
00329   integratorBuilder_->setObjectFactory(integratorFactory, integratorName);
00330   validPL_ = Teuchos::null;
00331 }
00332 
00333 
00334 template<class Scalar>
00335 void IntegratorBuilder<Scalar>::setIntegrationControlFactory(
00336   const RCP<const Teuchos::AbstractFactory<IntegrationControlStrategyBase<Scalar> > > &integrationControlFactory,
00337   const std::string &integrationControlName
00338   )
00339 {
00340   integrationControlBuilder_->setObjectFactory(integrationControlFactory,
00341                                                integrationControlName);
00342   validPL_ = Teuchos::null;
00343 }
00344 
00345 
00346 template<class Scalar>
00347 void IntegratorBuilder<Scalar>::setStepperBuilder(
00348     const RCP<StepperBuilder<Scalar> > &stepperBuilder
00349     )
00350 {
00351   TEUCHOS_TEST_FOR_EXCEPT(is_null(stepperBuilder));
00352   stepperBuilder_ = stepperBuilder;
00353   validPL_ = Teuchos::null;
00354 }
00355 
00356 
00357 template<class Scalar>
00358 RCP<StepperBuilder<Scalar> > IntegratorBuilder<Scalar>::getStepperBuilder()
00359 {
00360   return stepperBuilder_;
00361 }
00362 
00363 
00364 template<class Scalar>
00365 void IntegratorBuilder<Scalar>::setRKButcherTableauBuilder(
00366     const RCP<RKButcherTableauBuilder<Scalar> > & rkbtBuilder
00367     )
00368 {
00369   TEUCHOS_TEST_FOR_EXCEPT(is_null(rkbtBuilder));
00370   rkbtBuilder_ = rkbtBuilder;
00371   validPL_ = Teuchos::null;
00372 }
00373 
00374 
00375 template<class Scalar>
00376 void IntegratorBuilder<Scalar>::setStepControlFactory(
00377   const RCP<const Teuchos::AbstractFactory<StepControlStrategyBase<Scalar> > > &
00378     stepControlStrategyFactory,
00379   const std::string &stepControlName
00380   )
00381 {
00382   stepControlBuilder_->setObjectFactory(stepControlStrategyFactory,
00383                                         stepControlName);
00384   validPL_ = Teuchos::null;
00385 }
00386 
00387 
00388 template<class Scalar>
00389 void IntegratorBuilder<Scalar>::setInterpolationBufferFactory(
00390   const RCP<const Teuchos::AbstractFactory<InterpolationBufferBase<Scalar> > > &interpolationBufferFactory,
00391   const std::string &interpolationBufferName
00392   )
00393 {
00394   interpolationBufferBuilder_->setObjectFactory(interpolationBufferFactory, interpolationBufferName);
00395   validPL_ = Teuchos::null;
00396 }
00397 
00398 
00399 template<class Scalar>
00400 void IntegratorBuilder<Scalar>::setInterpolationBufferAppenderFactory(
00401   const RCP<const Teuchos::AbstractFactory<InterpolationBufferAppenderBase<Scalar> > > &interpolationBufferAppenderFactory,
00402   const std::string &interpolationBufferAppenderName
00403   )
00404 {
00405   interpolationBufferAppenderBuilder_->setObjectFactory(
00406     interpolationBufferAppenderFactory, interpolationBufferAppenderName);
00407   validPL_ = Teuchos::null;
00408 }
00409 
00410 
00411 template<class Scalar>
00412 void IntegratorBuilder<Scalar>::setErrWtVecCalcFactory(
00413     const RCP<const Teuchos::AbstractFactory<ErrWtVecCalcBase<Scalar> > > &
00414       errWtVecCalcFactory,
00415     const std::string &errWtVecCalcFactoryName
00416     )
00417 {
00418   errWtVecCalcBuilder_->setObjectFactory(errWtVecCalcFactory,
00419                                          errWtVecCalcFactoryName);
00420   validPL_ = Teuchos::null;
00421 }
00422 
00423 
00424 template<class Scalar>
00425 void IntegratorBuilder<Scalar>::setInterpolatorFactory(
00426     const RCP<const Teuchos::AbstractFactory<InterpolatorBase<Scalar> > > &
00427       interpolatorFactory,
00428     const std::string &interpolatorFactoryName
00429     )
00430 {
00431   interpolatorBuilder_->setObjectFactory(interpolatorFactory,
00432                                          interpolatorFactoryName);
00433   validPL_ = Teuchos::null;
00434 }
00435 
00436 
00437 template<class Scalar>
00438 void IntegratorBuilder<Scalar>::setWFactoryObject(
00439     const RCP<Thyra::LinearOpWithSolveFactoryBase<Scalar> > &wFactoryObject
00440     )
00441 {
00442   TEUCHOS_ASSERT( !is_null(wFactoryObject) );
00443   wFactoryObject_ = wFactoryObject;
00444 }
00445 
00446 
00447 template<class Scalar>
00448 void IntegratorBuilder<Scalar>::setParameterList(
00449   RCP<Teuchos::ParameterList> const& paramList
00450   )
00451 {
00452   TEUCHOS_TEST_FOR_EXCEPT(is_null(paramList));
00453   paramList->validateParameters(*this->getValidParameters());
00454   paramList_ = paramList;
00455 }
00456 
00457 
00458 template<class Scalar>
00459 RCP<const Teuchos::ParameterList>
00460 IntegratorBuilder<Scalar>::getValidParameters() const
00461 {
00462   if (is_null(validPL_)) {
00463     RCP<ParameterList> pl = Teuchos::parameterList();
00464 
00465     // Integrator Settings
00466     ParameterList& integratorSettingsPL =
00467       pl->sublist(integratorSettings_name,false,integratorSettings_docs);
00468     {
00469       // Initial Time
00470       integratorSettingsPL.set(initialTime_name,
00471                                Teuchos::as<Scalar>(initialTime_default),
00472                                initialTime_docs);
00473       // Final Time
00474       integratorSettingsPL.set(finalTime_name,
00475                                Teuchos::as<Scalar>(finalTime_default),
00476                                finalTime_docs);
00477       // Land On Final Time
00478       integratorSettingsPL.set(landOnFinalTime_name,landOnFinalTime_default,
00479                                landOnFinalTime_docs);
00480       // Integrator Selection
00481       ParameterList& integratorSelectionPL =
00482         integratorSettingsPL.sublist(integratorSelection_name,false,
00483                                      integratorSelection_docs)
00484                             .disableRecursiveValidation();
00485         // Default Integrator
00486         integratorSelectionPL.sublist(defaultIntegrator_name,false,
00487                                       defaultIntegrator_docs)
00488                               .disableRecursiveValidation();
00489       integratorSelectionPL
00490         .setParameters(*(integratorBuilder_->getValidParameters()));
00491     }
00492 
00493     // Integration Control Selection
00494     ParameterList& integrationControlSelectionPL =
00495       pl->sublist(integrationControlSelection_name,false,
00496                   integrationControlSelection_docs)
00497          .disableRecursiveValidation();
00498       // Simple Integration Control Strategy
00499       integrationControlSelectionPL.sublist(simpleIntegrationControl_name,false,
00500                                             simpleIntegrationControl_docs)
00501                                    .disableRecursiveValidation();
00502       // Ramping Integration Control Strategy
00503       integrationControlSelectionPL.sublist(rampingIntegrationControl_name,
00504                                             false,
00505                                             rampingIntegrationControl_docs)
00506                                    .disableRecursiveValidation();
00507     integrationControlSelectionPL
00508       .setParameters(*(integrationControlBuilder_->getValidParameters()));
00509 
00510     // Stepper Settings
00511     ParameterList& stepperSettingsPL = pl->sublist(stepperSettings_name, false,
00512                                                    stepperSettings_docs);
00513     {
00514       // Stepper Selection
00515       ParameterList& stepperSelectionPL =
00516         stepperSettingsPL.sublist(stepperSelection_name, false,
00517                                   stepperSelection_docs)
00518                          .disableRecursiveValidation();
00519         // Forward Euler
00520         stepperSelectionPL.sublist(ForwardEulerStepper_name, false,
00521                                    ForwardEulerStepper_docs)
00522                           .disableRecursiveValidation();
00523         // Backward Euler
00524         stepperSelectionPL.sublist(BackwardEulerStepper_name, false,
00525                                    BackwardEulerStepper_docs)
00526                           .disableRecursiveValidation();
00527         // Implicit BDF
00528         stepperSelectionPL.sublist(ImplicitBDFStepper_name, false,
00529                                    ImplicitBDFStepper_docs)
00530                           .disableRecursiveValidation();
00531         // Explicit RK
00532         stepperSelectionPL.sublist(ExplicitRKStepper_name, false,
00533                                    ExplicitRKStepper_docs)
00534                           .disableRecursiveValidation();
00535         // Implicit RK
00536         stepperSelectionPL.sublist(ImplicitRKStepper_name, false,
00537                                    ImplicitRKStepper_docs)
00538                           .disableRecursiveValidation();
00539       stepperSelectionPL
00540         .setParameters(*(stepperBuilder_->getValidParameters()));
00541       // Step Control Settings
00542       ParameterList& stepControlSettingsPL =
00543         stepperSettingsPL.sublist(stepControlSettings_name, false,
00544                                   stepControlSettings_docs);
00545       {
00546         // Step Control Selection
00547         ParameterList& stepControlSelectionPL =
00548           stepControlSettingsPL.sublist(stepControlSelection_name,false,
00549                                         stepControlSelection_docs)
00550                                .disableRecursiveValidation();
00551           // Fixed Step Control Strategy
00552           stepControlSelectionPL.sublist(fixedStepControl_name,false,
00553                                          fixedStepControl_docs)
00554                                 .disableRecursiveValidation();
00555           // Simple Step Control Strategy
00556           stepControlSelectionPL.sublist(simpleStepControl_name,false,
00557                                          simpleStepControl_docs)
00558                                 .disableRecursiveValidation();
00559           // First Order Error Step Control Strategy
00560           stepControlSelectionPL.sublist(firstOrderErrorStepControl_name,false,
00561                                          firstOrderErrorStepControl_docs)
00562                                 .disableRecursiveValidation();
00563           // Implicit BDF Stepper Step Control Strategy
00564           stepControlSelectionPL.sublist(implicitBDFStepControl_name,false,
00565                                          implicitBDFStepControl_docs)
00566                                 .disableRecursiveValidation();
00567           // Implicit BDF Stepper Ramping Step Control Strategy
00568           stepControlSelectionPL.sublist(implicitBDFRampingStepControl_name,
00569                                          false,
00570                                          implicitBDFRampingStepControl_docs)
00571                                 .disableRecursiveValidation();
00572         stepControlSelectionPL
00573           .setParameters(*(stepControlBuilder_->getValidParameters()));
00574 
00575         // ErrWtVec Selection
00576         ParameterList& errWtVecSelectionPL =
00577           stepControlSettingsPL.sublist(errWtVecSelection_name,false,
00578                                         errWtVecSelection_docs)
00579                                .disableRecursiveValidation();
00580           // Implicit BDF Stepper Error Weight Vector Calculator
00581           errWtVecSelectionPL.sublist(implicitBDFStepperErrWtVecCalc_name,
00582                                       false,
00583                                       implicitBDFStepperErrWtVecCalc_docs)
00584                              .disableRecursiveValidation();
00585         errWtVecSelectionPL
00586           .setParameters(*(errWtVecCalcBuilder_->getValidParameters()));
00587       }
00588       // Interpolator Selection
00589       ParameterList& interpolatorSelectionPL =
00590         stepperSettingsPL.sublist(interpolatorSelection_name,false,
00591                                   stepperInterpolatorSelection_docs)
00592                          .disableRecursiveValidation();
00593         // Linear Interpolator
00594         interpolatorSelectionPL.sublist(linearInterpolator_name, false,
00595                                         linearInterpolator_docs)
00596                                .disableRecursiveValidation();
00597         // Hermite Interpolator
00598         interpolatorSelectionPL.sublist(hermiteInterpolator_name, false,
00599                                         hermiteInterpolator_docs)
00600                                .disableRecursiveValidation();
00601         // Cubic Spline Interpolator
00602         interpolatorSelectionPL.sublist(cubicSplineInterpolator_name, false,
00603                                         cubicSplineInterpolator_docs)
00604                                .disableRecursiveValidation();
00605       interpolatorSelectionPL
00606         .setParameters(*(interpolatorBuilder_->getValidParameters()));
00607 
00608       // RKBT Selection
00609       ParameterList& rkbtSelectionPL =
00610         stepperSettingsPL.sublist(rkButcherTableauSelection_name,false,
00611                                   rkButcherTableauSelection_docs)
00612                          .disableRecursiveValidation();
00613       rkbtSelectionPL.setParameters(*(rkbtBuilder_->getValidParameters()));
00614       // Nonlinear Solver Selection (TODO)
00615     }
00616 
00617     // Interpolation Buffer Settings
00618     ParameterList& interpolationBufferSettingsPL =
00619       pl->sublist(interpolationBufferSettings_name,false,
00620                   interpolationBufferSettings_docs);
00621     {
00622       // Interpolation Buffer Selection
00623       ParameterList& interpolationBufferSelectionPL =
00624         interpolationBufferSettingsPL.sublist(interpolationBufferSelection_name,
00625                                               false,
00626                                               interpolationBufferSelection_docs)
00627                                      .disableRecursiveValidation();
00628         // Interpolation Buffer
00629         interpolationBufferSelectionPL
00630           .sublist(defaultInterpolationBuffer_name, false,
00631                    defaultInterpolationBuffer_docs)
00632           .disableRecursiveValidation();
00633       interpolationBufferSelectionPL
00634         .setParameters(*(interpolationBufferBuilder_->getValidParameters()));
00635       // Interpolation Buffer Appender Selection
00636       ParameterList& interpolationBufferAppenderSelectionPL =
00637         interpolationBufferSettingsPL
00638           .sublist(interpolationBufferAppenderSelection_name, false,
00639                    interpolationBufferAppenderSelection_docs)
00640           .disableRecursiveValidation();
00641         // Pointwise Interpolation Buffer Appender
00642         interpolationBufferAppenderSelectionPL
00643           .sublist(pointwiseInterpolationBufferAppender_name,false,
00644                    pointwiseInterpolationBufferAppender_docs)
00645           .disableRecursiveValidation();
00646       interpolationBufferAppenderSelectionPL
00647         .setParameters(*(interpolationBufferAppenderBuilder_->getValidParameters()));
00648       // Interpolator Selection
00649       ParameterList& interpolatorSelectionPL =
00650         interpolationBufferSettingsPL.sublist(interpolatorSelection_name,false,
00651                                               interpolatorSelection_docs)
00652                                      .disableRecursiveValidation();
00653         // Linear Interpolator
00654         interpolatorSelectionPL.sublist(linearInterpolator_name, false,
00655                                         linearInterpolator_docs)
00656                                .disableRecursiveValidation();
00657         // Hermite Interpolator
00658         interpolatorSelectionPL.sublist(hermiteInterpolator_name, false,
00659                                         hermiteInterpolator_docs)
00660                                .disableRecursiveValidation();
00661         // Cubic Spline Interpolator
00662         interpolatorSelectionPL.sublist(cubicSplineInterpolator_name, false,
00663                                         cubicSplineInterpolator_docs)
00664                                .disableRecursiveValidation();
00665       interpolatorSelectionPL
00666         .setParameters(*(interpolatorBuilder_->getValidParameters()));
00667     }
00668 
00669     // Integration Observer Settings
00670 
00671     validPL_ = pl;
00672   }
00673   return validPL_;
00674 }
00675 
00676 
00677 template<class Scalar>
00678 RCP<ParameterList> IntegratorBuilder<Scalar>::getNonconstParameterList()
00679 {
00680   return paramList_;
00681 }
00682 
00683 
00684 template<class Scalar>
00685 RCP<ParameterList> IntegratorBuilder<Scalar>::unsetParameterList()
00686 {
00687   RCP<ParameterList> pl = paramList_;
00688   paramList_ = Teuchos::null;
00689   return pl;
00690 }
00691 
00692 
00693 template<class Scalar>
00694 RCP<const ParameterList> IntegratorBuilder<Scalar>::getParameterList() const
00695 {
00696   return paramList_;
00697 }
00698 
00699 
00700 // Where should we throw exceptions?
00701 // 1.  If the integrator comes back null (done)
00702 // 2.  If the stepper comes back null (done)
00703 // 3.  If model is null (done)
00704 // 4.  If the stepper is implicit and nlSolver is null (done)
00705 // 5.  If the stepper accepts an RKBT but "None" is selected (done)
00706 //
00707 // a.  Its okay if the integration control comes back null, the
00708 //     IntegrationControlStrategyAcceptingIntegratorBase will deal with it
00709 // b.  Its okay if the step control comes back null, the
00710 //     StepControlStrategyAcceptingStepperBase will deal with it
00711 template<class Scalar>
00712 RCP<IntegratorBase<Scalar> >
00713 IntegratorBuilder<Scalar>::create(
00714     const RCP<const Thyra::ModelEvaluator<Scalar> >& model,
00715     const Thyra::ModelEvaluatorBase::InArgs<Scalar>& initialCondition,
00716     const RCP<Thyra::NonlinearSolverBase<Scalar> >& nlSolver
00717     ) const
00718 {
00719   TEUCHOS_TEST_FOR_EXCEPTION( is_null(model), std::logic_error,
00720       "Error!  IntegratorBuilder::create(...)  The model passed in is null!"
00721       );
00722   TEUCHOS_TEST_FOR_EXCEPTION( is_null(paramList_), std::logic_error,
00723       "Error!  IntegratorBuilder::create(...)  Please set a parameter "
00724       "list on this class before calling create."
00725       );
00726   RCP<ParameterList> integratorSettingsPL = sublist(paramList_,
00727                                                     integratorSettings_name);
00728 
00729   // Create the integrator first
00730   RCP<ParameterList> integratorSelectionPL = sublist(integratorSettingsPL,
00731                                                      integratorSelection_name);
00732   integratorBuilder_->setParameterList(integratorSelectionPL);
00733   RCP<IntegratorBase<Scalar> > integrator = integratorBuilder_->create();
00734   TEUCHOS_TEST_FOR_EXCEPTION( is_null(integrator), std::logic_error,
00735       "Error!  IntegratorBuilder::create(...)  The integrator came back "
00736       "null from the ObjectBuilder!"
00737       );
00738 
00739   // Check for IntegrationControlStrategy and set it on the integrator
00740   RCP<IntegrationControlStrategyAcceptingIntegratorBase<Scalar> >
00741     icsaIntegrator =
00742       Teuchos::rcp_dynamic_cast<IntegrationControlStrategyAcceptingIntegratorBase<Scalar> >(integrator,false);
00743   if (!is_null(icsaIntegrator)) {
00744     RCP<ParameterList> integrationControlSelectionPL =
00745       sublist(paramList_,integrationControlSelection_name);
00746     integrationControlBuilder_->setParameterList(integrationControlSelectionPL);
00747     RCP<IntegrationControlStrategyBase<Scalar> > integrationControl =
00748       integrationControlBuilder_->create();
00749     if (!is_null(integrationControl)) {
00750       icsaIntegrator->setIntegrationControlStrategy(integrationControl);
00751     }
00752   }
00753   RCP<ParameterList> interpolationBufferSettingsPL =
00754     sublist(paramList_,interpolationBufferSettings_name);
00755 
00756   // Check for a trailing interpolation buffer and set it on the integrator
00757   RCP<TrailingInterpolationBufferAcceptingIntegratorBase<Scalar> >
00758     tibaIntegrator =
00759       Teuchos::rcp_dynamic_cast<TrailingInterpolationBufferAcceptingIntegratorBase<Scalar> >(integrator,false);
00760   if (!is_null(tibaIntegrator)) {
00761     RCP<ParameterList> interpolationBufferSelectionPL =
00762       sublist(interpolationBufferSettingsPL,interpolationBufferSelection_name);
00763     interpolationBufferBuilder_->setParameterList(interpolationBufferSelectionPL);
00764     RCP<InterpolationBufferBase<Scalar> > ib =
00765       interpolationBufferBuilder_->create();
00766     if (!is_null(ib)) {
00767       // Check for an interpolator
00768       RCP<InterpolatorAcceptingObjectBase<Scalar> > iaobIB =
00769         Teuchos::rcp_dynamic_cast<InterpolatorAcceptingObjectBase<Scalar> >(ib,false);
00770       if (!is_null(iaobIB)) {
00771         RCP<ParameterList> interpolatorSelectionPL =
00772           sublist(interpolationBufferSettingsPL,interpolatorSelection_name);
00773         interpolatorBuilder_->setParameterList(interpolatorSelectionPL);
00774         RCP<InterpolatorBase<Scalar> > interpolator =
00775           interpolatorBuilder_->create();
00776         if (!is_null(interpolator)) {
00777           iaobIB->setInterpolator(interpolator);
00778         }
00779       }
00780       tibaIntegrator->setTrailingInterpolationBuffer(ib);
00781     }
00782   }
00783 
00784   // Check for an InterpolationBufferAppender and set it on the integrator
00785   RCP<InterpolationBufferAppenderAcceptingIntegratorBase<Scalar> > ibaaIntegrator =
00786     Teuchos::rcp_dynamic_cast<InterpolationBufferAppenderAcceptingIntegratorBase<Scalar> >(integrator,false);
00787   if (!is_null(ibaaIntegrator)) {
00788     RCP<ParameterList> interpolationBufferAppenderSelectionPL =
00789       sublist(interpolationBufferSettingsPL,
00790               interpolationBufferAppenderSelection_name);
00791     interpolationBufferAppenderBuilder_->setParameterList(interpolationBufferAppenderSelectionPL);
00792     RCP<InterpolationBufferAppenderBase<Scalar> > interpolationBufferAppender =
00793        interpolationBufferAppenderBuilder_->create();
00794     if (!is_null(interpolationBufferAppender)) {
00795       ibaaIntegrator->setInterpolationBufferAppender(interpolationBufferAppender);
00796     }
00797   }
00798   RCP<ParameterList> stepperSettingsPL =
00799     sublist(paramList_,stepperSettings_name);
00800 
00801   // Create the Stepper
00802   RCP<ParameterList> stepperSelectionPL = sublist(stepperSettingsPL,
00803                                                   stepperSelection_name);
00804   stepperBuilder_->setParameterList(stepperSelectionPL);
00805   RCP<StepperBase<Scalar> > stepper = stepperBuilder_->create();
00806   TEUCHOS_TEST_FOR_EXCEPTION( is_null(stepper), std::logic_error,
00807       "Error!  IntegratorBuilder::create(...)  The stepper came back "
00808       "null from the StepperBuilder!");
00809 
00810   // Create the Step Control
00811   RCP<ParameterList> stepControlSettingsPL =
00812     sublist(stepperSettingsPL,stepControlSettings_name);
00813   RCP<StepControlStrategyAcceptingStepperBase<Scalar> > scsaStepper =
00814     Teuchos::rcp_dynamic_cast<StepControlStrategyAcceptingStepperBase<Scalar> >(stepper,false);
00815   if (!is_null(scsaStepper)) {
00816     RCP<ParameterList> stepControlSelectionPL =
00817       sublist(stepControlSettingsPL,stepControlSelection_name);
00818     stepControlBuilder_->setParameterList(stepControlSelectionPL);
00819     RCP<StepControlStrategyBase<Scalar> > stepControl =
00820       stepControlBuilder_->create();
00821     if (!is_null(stepControl)) {
00822       // Create the ErrWtVecCalc
00823       RCP<ErrWtVecCalcAcceptingStepControlStrategyBase<Scalar> >
00824         ewvcaStepControl =
00825           Teuchos::rcp_dynamic_cast<ErrWtVecCalcAcceptingStepControlStrategyBase<Scalar> >(stepControl,false);
00826       if (!is_null(ewvcaStepControl)) {
00827         RCP<ParameterList> errWtVecSelectionPL =
00828           sublist(stepControlSettingsPL,errWtVecSelection_name);
00829         errWtVecCalcBuilder_->setParameterList(errWtVecSelectionPL);
00830         RCP<ErrWtVecCalcBase<Scalar> > errWtVecCalc =
00831           errWtVecCalcBuilder_->create();
00832         if (!is_null(errWtVecCalc)) {
00833           ewvcaStepControl->setErrWtVecCalc(errWtVecCalc);
00834         }
00835       }
00836       scsaStepper->setStepControlStrategy(stepControl);
00837     }
00838   }
00839 
00840   // Check for an Interpolator
00841   RCP<InterpolatorAcceptingObjectBase<Scalar> > iaobStepper =
00842     Teuchos::rcp_dynamic_cast<InterpolatorAcceptingObjectBase<Scalar> >(stepper,
00843                                                                         false);
00844   if (!is_null(iaobStepper)) {
00845     RCP<ParameterList> interpolatorSelectionPL =
00846       sublist(stepperSettingsPL,interpolatorSelection_name);
00847     interpolatorBuilder_->setParameterList(interpolatorSelectionPL);
00848     RCP<InterpolatorBase<Scalar> > interpolator =
00849       interpolatorBuilder_->create();
00850     if (!is_null(interpolator)) {
00851       iaobStepper->setInterpolator(interpolator);
00852     }
00853   }
00854 
00855   // Check for an RKBT Selection
00856   RCP<RKButcherTableauAcceptingStepperBase<Scalar> > rkbtaStepper =
00857     Teuchos::rcp_dynamic_cast<RKButcherTableauAcceptingStepperBase<Scalar> >(stepper,false);
00858   if (!is_null(rkbtaStepper)) {
00859     RCP<ParameterList> rkButcherTableauSelectionPL =
00860       sublist(stepperSettingsPL,rkButcherTableauSelection_name);
00861     rkbtBuilder_->setParameterList(rkButcherTableauSelectionPL);
00862     RCP<RKButcherTableauBase<Scalar> > rkbt = rkbtBuilder_->create();
00863     TEUCHOS_TEST_FOR_EXCEPTION( is_null(rkbt), std::logic_error,
00864       "Error!  IntegratorBuilder::create(...)  The Stepper accepts a "
00865       "RK Butcher Tableau, but none were specified!"
00866       );
00867     rkbtaStepper->setRKButcherTableau(rkbt);
00868   }
00869 
00870   // Check for a W Factory
00871   RCP<ImplicitRKStepper<Scalar> > irkStepper =
00872     Teuchos::rcp_dynamic_cast<ImplicitRKStepper<Scalar> >(stepper,false);
00873   if (!is_null(irkStepper)) {
00874     if (!is_null(wFactoryObject_)) {
00875       irkStepper->set_W_factory(wFactoryObject_);
00876     }
00877   }
00878 
00879   // Check for Nonlinear Solver Selection (TODO)
00880   // Set model on stepper
00881   stepper->setModel(model);
00882   // Set initial condition on stepper
00883   stepper->setInitialCondition(initialCondition);
00884   // Set nonlinear solver on stepper
00885   RCP<SolverAcceptingStepperBase<Scalar> > saStepper =
00886     Teuchos::rcp_dynamic_cast<SolverAcceptingStepperBase<Scalar> >(stepper,
00887                                                                    false);
00888   if(!is_null(saStepper)) {
00889     TEUCHOS_TEST_FOR_EXCEPTION( is_null(nlSolver), std::logic_error,
00890       "Error!  IntegratorBuilder::create(...)  The nonlinear solver passed "
00891       "in is null and the stepper is implicit!"
00892       );
00893     saStepper->setSolver(nlSolver);
00894   }
00895   Scalar finalTime = integratorSettingsPL->get<Scalar>(
00896     finalTime_name, Teuchos::as<Scalar>(finalTime_default));
00897   bool landOnFinalTime = integratorSettingsPL->get<bool>(
00898     landOnFinalTime_name, landOnFinalTime_default);
00899   integrator->setStepper(stepper,finalTime,landOnFinalTime);
00900   return integrator;
00901 }
00902 
00903 template<class Scalar>
00904 void IntegratorBuilder<Scalar>::initializeDefaults_()
00905 {
00906 
00907   using Teuchos::abstractFactoryStd;
00908 
00909   // Integrator
00910   integratorBuilder_ = Teuchos::objectBuilder<IntegratorBase<Scalar> >();
00911   integratorBuilder_->setObjectName(integratorBuilder_name);
00912   integratorBuilder_->setObjectTypeName(integratorBuilderType_name);
00913   integratorBuilder_->setObjectFactory(
00914       abstractFactoryStd< IntegratorBase<Scalar>, DefaultIntegrator<Scalar> >(),
00915       defaultIntegrator_name);
00916 
00917   // Integration Control Strategy
00918   integrationControlBuilder_ =
00919     Teuchos::objectBuilder<IntegrationControlStrategyBase<Scalar> >();
00920   integrationControlBuilder_->setObjectName(integrationControlBuilder_name);
00921   integrationControlBuilder_->setObjectTypeName(integrationControlBuilderType_name);
00922   integrationControlBuilder_->setObjectFactory(
00923       abstractFactoryStd< IntegrationControlStrategyBase<Scalar>,
00924                           SimpleIntegrationControlStrategy<Scalar> >(),
00925       simpleIntegrationControl_name);
00926   integrationControlBuilder_->setObjectFactory(
00927       abstractFactoryStd< IntegrationControlStrategyBase<Scalar>,
00928                           RampingIntegrationControlStrategy<Scalar> >(),
00929       rampingIntegrationControl_name);
00930   integrationControlBuilder_->setDefaultObject("None");
00931 
00932   // Stepper Builder
00933   stepperBuilder_ = stepperBuilder<Scalar>();
00934 
00935   // RKBT Builder
00936   rkbtBuilder_ = rKButcherTableauBuilder<Scalar>();
00937 
00938   // Step Control Strategy
00939   stepControlBuilder_ =
00940     Teuchos::objectBuilder<StepControlStrategyBase<Scalar> >();
00941   stepControlBuilder_->setObjectName(stepControlBuilder_name);
00942   stepControlBuilder_->setObjectTypeName(stepControlBuilderType_name);
00943   stepControlBuilder_->setObjectFactory(
00944       abstractFactoryStd< StepControlStrategyBase<Scalar>,
00945                           FixedStepControlStrategy<Scalar> >(),
00946       fixedStepControl_name);
00947   stepControlBuilder_->setObjectFactory(
00948       abstractFactoryStd< StepControlStrategyBase<Scalar>,
00949                           SimpleStepControlStrategy<Scalar> >(),
00950       simpleStepControl_name);
00951   stepControlBuilder_->setObjectFactory(
00952       abstractFactoryStd< StepControlStrategyBase<Scalar>,
00953                           FirstOrderErrorStepControlStrategy<Scalar> >(),
00954       firstOrderErrorStepControl_name);
00955   stepControlBuilder_->setObjectFactory(
00956       abstractFactoryStd< StepControlStrategyBase<Scalar>,
00957                           ImplicitBDFStepperStepControl<Scalar> >(),
00958       implicitBDFStepControl_name);
00959   stepControlBuilder_->setObjectFactory(
00960       abstractFactoryStd< StepControlStrategyBase<Scalar>,
00961                           ImplicitBDFStepperRampingStepControl<Scalar> >(),
00962       implicitBDFRampingStepControl_name);
00963   stepControlBuilder_->setDefaultObject("None");
00964 
00965   // Trailing Interpolation Buffer
00966   interpolationBufferBuilder_ =
00967     Teuchos::objectBuilder<InterpolationBufferBase<Scalar> >();
00968   interpolationBufferBuilder_->setObjectName(interpolationBufferBuilder_name);
00969   interpolationBufferBuilder_->setObjectTypeName(
00970     interpolationBufferBuilderType_name);
00971   interpolationBufferBuilder_->setObjectFactory(
00972       abstractFactoryStd< InterpolationBufferBase<Scalar>,
00973                           InterpolationBuffer<Scalar> >(),
00974       defaultInterpolationBuffer_name);
00975   interpolationBufferBuilder_->setDefaultObject("None");
00976 
00977   // Interpolation Buffer Appender
00978   interpolationBufferAppenderBuilder_ =
00979     Teuchos::objectBuilder<InterpolationBufferAppenderBase<Scalar> >();
00980   interpolationBufferAppenderBuilder_->setObjectName(
00981     interpolationBufferAppenderBuilder_name);
00982   interpolationBufferAppenderBuilder_->setObjectTypeName(
00983     interpolationBufferAppenderBuilderType_name);
00984 //  interpolationBufferAppenderBuilder_->setObjectFactory(
00985 //      abstractFactoryStd< InterpolationBufferAppenderBase<Scalar>,
00986 //                          SmartInterpolationBufferAppender<Scalar> >(),
00987 //      smartInterpolationBufferAppender_name);
00988   interpolationBufferAppenderBuilder_->setObjectFactory(
00989       abstractFactoryStd< InterpolationBufferAppenderBase<Scalar>,
00990                           PointwiseInterpolationBufferAppender<Scalar> >(),
00991       pointwiseInterpolationBufferAppender_name
00992       );
00993   interpolationBufferAppenderBuilder_->setDefaultObject("None");
00994 
00995   // ErrWtVecCalc
00996   errWtVecCalcBuilder_ = Teuchos::objectBuilder<ErrWtVecCalcBase<Scalar> >();
00997   errWtVecCalcBuilder_->setObjectName(errWtVecCalcBuilder_name);
00998   errWtVecCalcBuilder_->setObjectTypeName(errWtVecCalcBuilderType_name);
00999   errWtVecCalcBuilder_->setObjectFactory(
01000       abstractFactoryStd< ErrWtVecCalcBase<Scalar>,
01001                           ImplicitBDFStepperErrWtVecCalc<Scalar> >(),
01002       implicitBDFStepperErrWtVecCalc_name);
01003   errWtVecCalcBuilder_->setDefaultObject("None");
01004 
01005   // Interpolator
01006   interpolatorBuilder_ = Teuchos::objectBuilder<InterpolatorBase<Scalar> >();
01007   interpolatorBuilder_->setObjectName(interpolatorBuilder_name);
01008   interpolatorBuilder_->setObjectTypeName(interpolatorBuilderType_name);
01009   interpolatorBuilder_->setObjectFactory(
01010       abstractFactoryStd< InterpolatorBase<Scalar>,
01011                           LinearInterpolator<Scalar> >(),
01012       linearInterpolator_name);
01013   interpolatorBuilder_->setObjectFactory(
01014       abstractFactoryStd< InterpolatorBase<Scalar>,
01015                           HermiteInterpolator<Scalar> >(),
01016       hermiteInterpolator_name);
01017   interpolatorBuilder_->setObjectFactory(
01018       abstractFactoryStd< InterpolatorBase<Scalar>,
01019                           CubicSplineInterpolator<Scalar> >(),
01020       cubicSplineInterpolator_name);
01021   interpolatorBuilder_->setDefaultObject("None");
01022 
01023 }
01024 
01025 
01026 } // namespace Rythmos
01027 
01028 
01029 template<class Scalar>
01030 Teuchos::RCP<Rythmos::IntegratorBuilder<Scalar> >
01031 Rythmos::integratorBuilder()
01032 {
01033   return rcp(new IntegratorBuilder<Scalar>);
01034 }
01035 
01036 
01037 template<class Scalar>
01038 Teuchos::RCP<Rythmos::IntegratorBuilder<Scalar> >
01039 Rythmos::integratorBuilder(const RCP<ParameterList> &paramList)
01040 {
01041   const RCP<IntegratorBuilder<Scalar> > ib = integratorBuilder<Scalar>();
01042   ib->setParameterList(paramList);
01043   return ib;
01044 }
01045 
01046 template<class Scalar>
01047 Teuchos::RCP<Rythmos::IntegratorBase<Scalar> > Rythmos::createForwardSensitivityIntegrator(
01048     const RCP<const Thyra::ModelEvaluator<Scalar> >& model,
01049     const int& p_index,
01050     const Thyra::ModelEvaluatorBase::InArgs<Scalar>& model_ic,
01051     const RCP<Thyra::NonlinearSolverBase<Scalar> >& nlSolver,
01052     const RCP<Teuchos::ParameterList>& integratorBuilderPL
01053     )
01054 {
01055   RCP<IntegratorBuilder<Scalar> > ib = integratorBuilder<Scalar>(integratorBuilderPL);
01056   RCP<IntegratorBase<Scalar> > sensIntegrator = ib->create(model,model_ic,nlSolver);
01057   RCP<ForwardSensitivityStepper<Scalar> > stateAndSensStepper =
01058     forwardSensitivityStepper<Scalar>();
01059   stateAndSensStepper->initializeSyncedSteppers(
01060     model, p_index, model_ic, sensIntegrator->getNonconstStepper(), nlSolver
01061     );
01062   typedef Thyra::ModelEvaluatorBase MEB;
01063   MEB::InArgs<Scalar> state_and_sens_ic =
01064     createStateAndSensInitialCondition(*stateAndSensStepper, model_ic);
01065   stateAndSensStepper->setInitialCondition(state_and_sens_ic);
01066   sensIntegrator->setStepper(stateAndSensStepper, sensIntegrator->getFwdTimeRange().upper());
01067   return sensIntegrator;
01068 }
01069 
01070 
01071 
01072 //
01073 // Explicit Instantiation macro
01074 //
01075 // Must be expanded from within the Rythmos namespace!
01076 //
01077 
01078 #define RYTHMOS_INTEGRATOR_BUILDER_INSTANT(SCALAR) \
01079   \
01080   template class IntegratorBuilder< SCALAR >; \
01081   \
01082   template RCP<IntegratorBuilder< SCALAR > > \
01083   integratorBuilder(); \
01084   \
01085   template RCP<IntegratorBuilder< SCALAR > > \
01086   integratorBuilder(const RCP<ParameterList> &paraList); \
01087   \
01088   template RCP<IntegratorBase< SCALAR > > \
01089   createForwardSensitivityIntegrator( \
01090     const RCP<const Thyra::ModelEvaluator< SCALAR > >& model, \
01091     const int& p_index, \
01092     const Thyra::ModelEvaluatorBase::InArgs< SCALAR >& model_ic, \
01093     const RCP<Thyra::NonlinearSolverBase< SCALAR > >& nlSolver, \
01094     const RCP<ParameterList>& integratorBuilderPL \
01095     );
01096 
01097 
01098 #endif //Rythmos_INTEGRATOR_BUILDER_DEF_H
 All Classes Functions Variables Typedefs Friends