Debian Codegraph @

packages/nox/test/epetra/Thyra/ModelEvaluator1DFEM.hpp

raw
1 // @HEADER
2 // *****************************************************************************
3 // NOX: An Object-Oriented Nonlinear Solver Package
4 //
5 // Copyright 2002 NTESS and the NOX contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 #ifndef NOX_THYRA_MODEL_EVALUATOR_1DFEM_DECL_HPP
10 #define NOX_THYRA_MODEL_EVALUATOR_1DFEM_DECL_HPP
11
12 #include "Thyra_StateFuncModelEvaluatorBase.hpp"
13
14 template<class Scalar> class ModelEvaluator1DFEM;
15
16 /** \brief Nonmember constuctor.
17 *
18 * \relates ModelEvaluator1DFEM
19 */
20 template<class Scalar>
21 Teuchos::RCP<ModelEvaluator1DFEM<Scalar> >
22 modelEvaluator1DFEM(const Teuchos::RCP<const Epetra_Comm>& comm,
23 const int NumGlobalElements,
24 const Scalar z_min,
25 const Scalar z_max);
26
27
28 /** \brief 1D Finite Element model for nonlinear heat conduction
29 *
30 * The equation modeled is:
31
32 \verbatim
33
34 d2T
35 --- - K * T**2 = 0
36 dz2
37
38 subject to:
39 T = 1.0 @ z = z_min
40
41 \endverbatim
42
43 * The Matrix <tt>W = d(f)/d(x)</tt> is implemented as a
44 * <tt>Thyra::MultiVectorBase</tt> object and the class
45 * <tt>Thyra::DefaultSerialDenseLinearOpWithSolveFactory</tt> is used to
46 * create the linear solver.
47 */
48 template<class Scalar>
49 class ModelEvaluator1DFEM
50 : public ::Thyra::StateFuncModelEvaluatorBase<Scalar>
51 {
52 public:
53
54 ModelEvaluator1DFEM(const Teuchos::RCP<const Epetra_Comm>& comm,
55 const int num_global_elements,
56 const Scalar z_min,
57 const Scalar z_max);
58
59 /** \name Initializers/Accessors */
60 //@{
61
62 /** \brief . */
63 void set_x0(const Teuchos::ArrayView<const Scalar> &x0);
64
65 /** \brief . */
66 void setShowGetInvalidArgs(bool showGetInvalidArg);
67
68 void set_W_factory(const Teuchos::RCP<const ::Thyra::LinearOpWithSolveFactoryBase<Scalar> >& W_factory);
69
70 //@}
71
72 /** \name Public functions overridden from ModelEvaulator. */
73 //@{
74
75 /** \brief . */
76 Teuchos::RCP<const ::Thyra::VectorSpaceBase<Scalar> > get_x_space() const;
77 /** \brief . */
78 Teuchos::RCP<const ::Thyra::VectorSpaceBase<Scalar> > get_f_space() const;
79 /** \brief . */
80 ::Thyra::ModelEvaluatorBase::InArgs<Scalar> getNominalValues() const;
81 /** \brief . */
82 Teuchos::RCP< ::Thyra::LinearOpBase<Scalar> > create_W_op() const;
83 /** \brief . */
84 Teuchos::RCP<const ::Thyra::LinearOpWithSolveFactoryBase<Scalar> > get_W_factory() const;
85 /** \brief . */
86 ::Thyra::ModelEvaluatorBase::InArgs<Scalar> createInArgs() const;
87 /** \brief . */
88 Teuchos::RCP< ::Thyra::PreconditionerBase< Scalar > > create_W_prec() const;
89 //@}
90
91 private:
92
93 /** Allocates and returns the Jacobian matrix graph */
94 virtual Teuchos::RCP<Epetra_CrsGraph> createGraph();
95
96 /** \name Private functions overridden from ModelEvaulatorDefaultBase. */
97 //@{
98
99 /** \brief . */
100 ::Thyra::ModelEvaluatorBase::OutArgs<Scalar> createOutArgsImpl() const;
101 /** \brief . */
102 void evalModelImpl(
103 const ::Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs,
104 const ::Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs
105 ) const;
106
107 //@}
108
109 private: // data members
110
111 const Teuchos::RCP<const Epetra_Comm> comm_;
112 const int num_global_elements_;
113 const Scalar z_min_;
114 const Scalar z_max_;
115
116 Teuchos::RCP<const ::Thyra::VectorSpaceBase<Scalar> > x_space_;
117 Teuchos::RCP<const Epetra_Map> x_owned_map_;
118 Teuchos::RCP<const Epetra_Map> x_ghosted_map_;
119 Teuchos::RCP<const Epetra_Import> importer_;
120
121 Teuchos::RCP<const ::Thyra::VectorSpaceBase<Scalar> > f_space_;
122 Teuchos::RCP<const Epetra_Map> f_owned_map_;
123
124 Teuchos::RCP<Epetra_CrsGraph> W_graph_;
125
126 Teuchos::RCP<const ::Thyra::LinearOpWithSolveFactoryBase<Scalar> > W_factory_;
127
128 Teuchos::RCP<Epetra_Vector> node_coordinates_;
129 Teuchos::RCP<Epetra_Vector> ghosted_node_coordinates_;
130
131 mutable Teuchos::RCP<Epetra_Vector> u_ptr;
132 mutable Teuchos::RCP<Epetra_Vector> x_ptr;
133
134 mutable Teuchos::RCP<Epetra_Vector> J_diagonal_;
135
136 ::Thyra::ModelEvaluatorBase::InArgs<Scalar> nominalValues_;
137 Scalar k_;
138 Teuchos::RCP< ::Thyra::VectorBase<Scalar> > x0_;
139 Teuchos::Array<Scalar> p_;
140 bool showGetInvalidArg_;
141 ::Thyra::ModelEvaluatorBase::InArgs<Scalar> prototypeInArgs_;
142 ::Thyra::ModelEvaluatorBase::OutArgs<Scalar> prototypeOutArgs_;
143
144 };
145
146 //==================================================================
147 // Finite Element Basis Object
148 class Basis {
149
150 public:
151 // Constructor
152 Basis();
153
154 // Destructor
155 ~Basis();
156
157 // Calculates the values of u and x at the specified gauss point
158 void computeBasis(int gp, double *z, double *u, double *uold = 0);
159
160 public:
161 // Variables that are calculated at the gauss point
162 double *phi, *dphide;
163 double uu, zz, duu, eta, wt;
164 double dz;
165 // These are only needed for transient
166 double uuold, duuold;
167 };
168
169 //==================================================================
170 #include "ModelEvaluator1DFEM_def.hpp"
171 //==================================================================
172
173 #endif