Tempus  Version of the Day
Time Integration
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Tempus_WrapStaggeredFSAModelEvaluator.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_WrapStaggeredFSAModelEvaluator_hpp
11 #define Tempus_WrapStaggeredFSAModelEvaluator_hpp
12 
13 #include "Tempus_config.hpp"
15 #include "Tempus_StaggeredForwardSensitivityModelEvaluator.hpp"
16 #include "Tempus_WrapperModelEvaluatorPairIMEX_Basic.hpp"
18 #include "Tempus_WrapperModelEvaluatorPairPartIMEX_StaggeredFSA.hpp"
19 
20 namespace Tempus {
21 
27 template <typename Scalar>
30  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& model,
32  sens_residual_model,
33  const Teuchos::RCP<const Thyra::ModelEvaluator<Scalar> >& sens_solve_model,
34  const bool is_pseudotransient,
35  const Teuchos::RCP<const Teuchos::ParameterList>& pList = Teuchos::null)
36 {
37  using Teuchos::RCP;
38  using Teuchos::rcp_dynamic_cast;
39 
40  RCP<SensitivityModelEvaluatorBase<Scalar> > wrapped_model;
41 
42  // Test if model is an IMEX pair
43  RCP<const WrapperModelEvaluatorPairIMEX_Basic<Scalar> > modelPairIMEX =
44  rcp_dynamic_cast<const WrapperModelEvaluatorPairIMEX_Basic<Scalar> >(
45  model);
46  RCP<const WrapperModelEvaluatorPairPartIMEX_Basic<Scalar> >
47  modelPairPartIMEX = rcp_dynamic_cast<
49 
50  // It isn't clear how to handle separate sensitivity and solve model
51  // evaluators in the IMEX case, so punt for now. Would they also be IMEX MEs?
52  if ((modelPairIMEX != Teuchos::null || modelPairPartIMEX != Teuchos::null) &&
53  (model.ptr() != sens_residual_model.ptr()) &&
54  (model.ptr() != sens_solve_model.ptr()))
56  true, std::logic_error,
57  "Unique model evaluators for state, sensitivity residual, and "
58  "sensitivity solve is not supported for IMEX");
59 
60  if (modelPairIMEX != Teuchos::null) {
62  modelPairIMEX, is_pseudotransient, pList));
63  }
64  else if (modelPairPartIMEX != Teuchos::null) {
65  wrapped_model =
67  modelPairPartIMEX, is_pseudotransient, pList));
68  }
69  else {
71  model, sens_residual_model, sens_solve_model, is_pseudotransient,
72  pList));
73  }
74 
75  return wrapped_model;
76 }
77 
78 template <typename Scalar>
82  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar> >& sens_residual_model,
83  const Teuchos::RCP<Thyra::ModelEvaluator<Scalar> >& sens_solve_model,
84  const bool is_pseudotransient,
85  const Teuchos::RCP<const Teuchos::ParameterList>& pList = Teuchos::null)
86 {
89  sens_residual_model;
91  sens_solve_model;
92  return wrapStaggeredFSAModelEvaluator(cmodel, csens_residual_model,
93  csens_solve_model, is_pseudotransient,
94  pList);
95 }
96 
97 } // namespace Tempus
98 
99 #endif
Teuchos::RCP< SensitivityModelEvaluatorBase< Scalar > > wrapStaggeredFSAModelEvaluator(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 bool is_pseudotransient, const Teuchos::RCP< const Teuchos::ParameterList > &pList=Teuchos::null)
ModelEvaluator pair for implicit and explicit (IMEX) evaulations.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Specialization of IMEX ME for &quot;staggered&quot; FSA method.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
ModelEvaluator pair for implicit and explicit (IMEX) evaulations.
Transform a ModelEvaluator&#39;s sensitivity equations to its residual.
Specialization of IMEX-Part ME for &quot;combined&quot; FSA method.