| 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 ModelEvaluator1DPoisson; |
| 15 |
|
| 16 |
/** \brief Nonmember constuctor. |
| 17 |
* |
| 18 |
* \relates ModelEvaluator1DPoisson |
| 19 |
*/ |
| 20 |
template<class Scalar> |
| 21 |
Teuchos::RCP<ModelEvaluator1DPoisson<Scalar> > |
| 22 |
modelEvaluator1DPoisson(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 Poisson's equation |
| 29 |
* |
| 30 |
* The equation modeled is: |
| 31 |
|
| 32 |
\verbatim |
| 33 |
|
| 34 |
d2u |
| 35 |
--- = 0 |
| 36 |
dx2 |
| 37 |
|
| 38 |
subject to: |
| 39 |
u = a @ x = 0 |
| 40 |
u = b @ x = N |
| 41 |
|
| 42 |
\endverbatim |
| 43 |
|
| 44 |
* The Matrix <tt>W = d(f)/d(x)</tt> is implemented as a |
| 45 |
* <tt>Thyra::MultiVectorBase</tt> object |
| 46 |
*/ |
| 47 |
template<class Scalar> |
| 48 |
class ModelEvaluator1DPoisson |
| 49 |
: public ::Thyra::StateFuncModelEvaluatorBase<Scalar> |
| 50 |
{ |
| 51 |
public: |
| 52 |
|
| 53 |
ModelEvaluator1DPoisson(const Teuchos::RCP<const Epetra_Comm>& comm, |
| 54 |
const int num_global_elements, |
| 55 |
const Scalar a, |
| 56 |
const Scalar b); |
| 57 |
|
| 58 |
/** \name Initializers/Accessors */ |
| 59 |
//@{ |
| 60 |
|
| 61 |
/** \brief . */ |
| 62 |
void set_x0(const Teuchos::ArrayView<const Scalar> &x0); |
| 63 |
|
| 64 |
/** \brief . */ |
| 65 |
void setShowGetInvalidArgs(bool showGetInvalidArg); |
| 66 |
|
| 67 |
void set_W_factory(const Teuchos::RCP<const ::Thyra::LinearOpWithSolveFactoryBase<Scalar> >& W_factory); |
| 68 |
|
| 69 |
//@} |
| 70 |
|
| 71 |
/** \name Public functions overridden from ModelEvaulator. */ |
| 72 |
//@{ |
| 73 |
|
| 74 |
/** \brief . */ |
| 75 |
Teuchos::RCP<const ::Thyra::VectorSpaceBase<Scalar> > get_x_space() const; |
| 76 |
/** \brief . */ |
| 77 |
Teuchos::RCP<const ::Thyra::VectorSpaceBase<Scalar> > get_f_space() const; |
| 78 |
/** \brief . */ |
| 79 |
::Thyra::ModelEvaluatorBase::InArgs<Scalar> getNominalValues() const; |
| 80 |
/** \brief . */ |
| 81 |
Teuchos::RCP< ::Thyra::LinearOpBase<Scalar> > create_W_op() const; |
| 82 |
/** \brief . */ |
| 83 |
Teuchos::RCP<const ::Thyra::LinearOpWithSolveFactoryBase<Scalar> > get_W_factory() const; |
| 84 |
/** \brief . */ |
| 85 |
::Thyra::ModelEvaluatorBase::InArgs<Scalar> createInArgs() const; |
| 86 |
//@} |
| 87 |
|
| 88 |
private: |
| 89 |
|
| 90 |
/** Allocates and returns the Jacobian matrix graph */ |
| 91 |
virtual Teuchos::RCP<Epetra_CrsGraph> createGraph(); |
| 92 |
|
| 93 |
/** \name Private functions overridden from ModelEvaulatorDefaultBase. */ |
| 94 |
//@{ |
| 95 |
|
| 96 |
/** \brief . */ |
| 97 |
::Thyra::ModelEvaluatorBase::OutArgs<Scalar> createOutArgsImpl() const; |
| 98 |
/** \brief . */ |
| 99 |
void evalModelImpl( |
| 100 |
const ::Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs, |
| 101 |
const ::Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs |
| 102 |
) const; |
| 103 |
|
| 104 |
//@} |
| 105 |
|
| 106 |
private: // data members |
| 107 |
|
| 108 |
const Teuchos::RCP<const Epetra_Comm> comm_; |
| 109 |
const int num_global_elements_; |
| 110 |
const Scalar a_; |
| 111 |
const Scalar b_; |
| 112 |
|
| 113 |
Teuchos::RCP<const ::Thyra::VectorSpaceBase<Scalar> > x_space_; |
| 114 |
Teuchos::RCP<const Epetra_Map> x_owned_map_; |
| 115 |
Teuchos::RCP<const Epetra_Map> x_ghosted_map_; |
| 116 |
Teuchos::RCP<const Epetra_Import> importer_; |
| 117 |
|
| 118 |
Teuchos::RCP<const ::Thyra::VectorSpaceBase<Scalar> > f_space_; |
| 119 |
Teuchos::RCP<const Epetra_Map> f_owned_map_; |
| 120 |
|
| 121 |
Teuchos::RCP<Epetra_CrsGraph> W_graph_; |
| 122 |
|
| 123 |
Teuchos::RCP<const ::Thyra::LinearOpWithSolveFactoryBase<Scalar> > W_factory_; |
| 124 |
|
| 125 |
Teuchos::RCP<Epetra_Vector> node_coordinates_; |
| 126 |
Teuchos::RCP<Epetra_Vector> ghosted_node_coordinates_; |
| 127 |
|
| 128 |
mutable Teuchos::RCP<Epetra_Vector> u_ptr; |
| 129 |
mutable Teuchos::RCP<Epetra_Vector> x_ptr; |
| 130 |
|
| 131 |
mutable Teuchos::RCP<Epetra_Vector> J_diagonal_; |
| 132 |
|
| 133 |
::Thyra::ModelEvaluatorBase::InArgs<Scalar> nominalValues_; |
| 134 |
Teuchos::RCP< ::Thyra::VectorBase<Scalar> > x0_; |
| 135 |
Teuchos::Array<Scalar> p_; |
| 136 |
bool showGetInvalidArg_; |
| 137 |
::Thyra::ModelEvaluatorBase::InArgs<Scalar> prototypeInArgs_; |
| 138 |
::Thyra::ModelEvaluatorBase::OutArgs<Scalar> prototypeOutArgs_; |
| 139 |
|
| 140 |
}; |
| 141 |
|
| 142 |
//================================================================== |
| 143 |
#include "ModelEvaluator1DPoisson_def.hpp" |
| 144 |
//================================================================== |
| 145 |
|
| 146 |
#endif |