Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_WrapCombinedFSAModelEvaluator.hpp
Go to the documentation of this file.
1 //@HEADER
2 // *****************************************************************************
3 // Tempus: Time Integration and Sensitivity Analysis Package
4 //
5 // Copyright 2017 NTESS and the Tempus contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 //@HEADER
9 
10 #ifndef Tempus_WrapCombinedFSAModelEvaluator_hpp
11 #define Tempus_WrapCombinedFSAModelEvaluator_hpp
12 
13 #include "Tempus_config.hpp"
15 #include "Tempus_WrapperModelEvaluatorPairPartIMEX_CombinedFSA.hpp"
16 
17 namespace Tempus {
18 
24 template <typename Scalar>
27  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
29  sens_residual_model,
30  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& sens_solve_model,
31  const Teuchos::RCP<const Teuchos::ParameterList>& pList = Teuchos::null)
32 {
33  using Teuchos::RCP;
34  using Teuchos::rcp_dynamic_cast;
35 
36  RCP<SensitivityModelEvaluatorBase<Scalar> > wrapped_model;
37 
38  // Test if model is an IMEX pair
39  RCP<const WrapperModelEvaluatorPairIMEX_Basic<Scalar> > modelPairIMEX =
40  rcp_dynamic_cast<const WrapperModelEvaluatorPairIMEX_Basic<Scalar> >(
41  model);
42  RCP<const WrapperModelEvaluatorPairPartIMEX_Basic<Scalar> >
43  modelPairPartIMEX = rcp_dynamic_cast<
45 
46  // It isn't clear how to handle separate sensitivity and solve model
47  // evaluators in the IMEX case, so punt for now. Would they also be IMEX MEs?
48  if ((modelPairIMEX != Teuchos::null || modelPairPartIMEX != Teuchos::null) &&
49  (model.ptr() != sens_residual_model.ptr()) &&
50  (model.ptr() != sens_solve_model.ptr()))
52  true, std::logic_error,
53  "Unique model evaluators for state, sensitivity residual, and "
54  "sensitivity solve is not supported for IMEX");
55 
56  if (modelPairIMEX != Teuchos::null) {
58  modelPairIMEX, pList));
59  }
60  else if (modelPairPartIMEX != Teuchos::null) {
61  wrapped_model =
63  modelPairPartIMEX, pList));
64  }
65  else {
67  model, sens_residual_model, sens_solve_model, pList));
68  }
69 
70  return wrapped_model;
71 }
72 
73 template <typename Scalar>
77  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar> >& sens_residual_model,
78  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar> >& sens_solve_model,
79  const Teuchos::RCP<const Teuchos::ParameterList>& pList = Teuchos::null)
80 {
83  sens_residual_model;
85  sens_solve_model;
86  return wrapCombinedFSAModelEvaluator(cmodel, csens_residual_model,
87  csens_solve_model, pList);
88 }
89 
90 } // namespace Tempus
91 
92 #endif
Transform a ModelEvaluator&#39;s sensitivity equations to its residual.
ModelEvaluator pair for implicit and explicit (IMEX) evaulations.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Specialization of IMEX ME for &quot;combined&quot; FSA method.
Specialization of IMEX-Part ME for &quot;combined&quot; FSA method.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
ModelEvaluator pair for implicit and explicit (IMEX) evaulations.
Teuchos::RCP< SensitivityModelEvaluatorBase< Scalar > > wrapCombinedFSAModelEvaluator(const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &model, const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &sens_residual_model, const Teuchos::RCP< const Thyra::ModelEvaluator< Scalar > > &sens_solve_model, const Teuchos::RCP< const Teuchos::ParameterList > &pList=Teuchos::null)