Debian Codegraph @

packages/stokhos/example/uq_handbook/SimpleME.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // Stokhos Package
4 //
5 // Copyright 2009 NTESS and the Stokhos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef SIMPLE_ME_HPP
11 #define SIMPLE_ME_HPP
12
13 #include "Teuchos_RCP.hpp"
14 #include "Teuchos_Array.hpp"
15
16 #include "EpetraExt_ModelEvaluator.h"
17
18 #include "Epetra_Map.h"
19 #include "Epetra_LocalMap.h"
20 #include "Epetra_Import.h"
21 #include "Epetra_CrsGraph.h"
22 #include "Epetra_CrsMatrix.h"
23
24 /* Simple model evaluator demonstrating how to use the Stokhos
25 * ModelEvaluator to solve a nonlinear stochastic Galerkin problem.
26 * It represents the simple function
27 *
28 * f(x,a) = | a^2 - x_0 |
29 * | x_1^2 - x_0 |
30 *
31 * where x = [x_0 x_1]^T and a is a parameter. It has a root at x = [ a^2, a ].
32 * The parameter a may be represented by a given polynomial chaos expansion,
33 * and the corresponding expansion for x computed by Stokhos.
34 */
35 class SimpleME : public EpetraExt::ModelEvaluator {
36 public:
37
38 //! Constructor
39 SimpleME(const Teuchos::RCP<const Epetra_Comm>& comm);
40
41 /** \name Overridden from EpetraExt::ModelEvaluator . */
42 //@{
43
44 //! Return solution vector map
45 Teuchos::RCP<const Epetra_Map> get_x_map() const;
46
47 //! Return residual vector map
48 Teuchos::RCP<const Epetra_Map> get_f_map() const;
49
50 //! Return parameter vector map
51 Teuchos::RCP<const Epetra_Map> get_p_map(int l) const;
52
53 //! Return array of parameter names
54 Teuchos::RCP<const Teuchos::Array<std::string> > get_p_names(int l) const;
55
56 //! Return initial solution
57 Teuchos::RCP<const Epetra_Vector> get_x_init() const;
58
59 //! Return initial parameters
60 Teuchos::RCP<const Epetra_Vector> get_p_init(int l) const;
61
62 //! Create W = alpha*M + beta*J matrix
63 Teuchos::RCP<Epetra_Operator> create_W() const;
64
65 //! Create InArgs
66 InArgs createInArgs() const;
67
68 //! Create OutArgs
69 OutArgs createOutArgs() const;
70
71 //! Evaluate model on InArgs
72 void evalModel(const InArgs& inArgs, const OutArgs& outArgs) const;
73
74 //@}
75
76 protected:
77
78 //! Solution vector map
79 Teuchos::RCP<Epetra_Map> x_map;
80
81 //! Overlapped solution vector map
82 Teuchos::RCP<Epetra_Map> x_overlapped_map;
83
84 //! Importer to overlapped distribution
85 Teuchos::RCP<Epetra_Import> importer;
86
87 //! Initial guess
88 Teuchos::RCP<Epetra_Vector> x_init;
89
90 //! Overlapped solution vector
91 Teuchos::RCP<Epetra_Vector> x_overlapped;
92
93 //! Parameter vector map
94 Teuchos::RCP<Epetra_Map> p_map;
95
96 //! Initial parameters
97 Teuchos::RCP<Epetra_Vector> p_init;
98
99 //! Parameter names
100 Teuchos::RCP< Teuchos::Array<std::string> > p_names;
101
102 //! Jacobian graph
103 Teuchos::RCP<Epetra_CrsGraph> graph;
104
105 };
106
107 #endif // SIMPLE_ME_HPP