| 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_HEQ_DECL_HPP |
| 10 |
#define NOX_THYRA_MODEL_EVALUATOR_HEQ_DECL_HPP |
| 11 |
|
| 12 |
#include "Thyra_StateFuncModelEvaluatorBase.hpp" |
| 13 |
#include <vector> |
| 14 |
|
| 15 |
template<class Scalar> class ModelEvaluatorHeq; |
| 16 |
|
| 17 |
/** \brief Nonmember constuctor. |
| 18 |
* |
| 19 |
* \relates ModelEvaluatorHeq |
| 20 |
*/ |
| 21 |
template<class Scalar> |
| 22 |
Teuchos::RCP<ModelEvaluatorHeq<Scalar> > |
| 23 |
modelEvaluatorHeq(const Teuchos::RCP<const Epetra_Comm>& comm, |
| 24 |
const int NumGlobalElements, |
| 25 |
const Scalar paramC); |
| 26 |
|
| 27 |
|
| 28 |
/** \brief Chandrasekhar H-Equation |
| 29 |
* |
| 30 |
* The equation modeled is: |
| 31 |
|
| 32 |
\f$ F(x)_i = x_i - (1 - \frac{c}{2N}\sum_{j=1}^N \frac{\mu_ix_j}{\mu_i + \mu_j})^{-1} = 0, 1 <= i <= N\f$ |
| 33 |
|
| 34 |
* In this, \f$[0,1]\f$ is discretized into \f$N\f$ uniformly sized |
| 35 |
* cells and \f$\{\mu_j\}\f$ are the midpoints of these cells. |
| 36 |
*/ |
| 37 |
template<class Scalar> |
| 38 |
class ModelEvaluatorHeq |
| 39 |
: public ::Thyra::StateFuncModelEvaluatorBase<Scalar> |
| 40 |
{ |
| 41 |
public: |
| 42 |
|
| 43 |
ModelEvaluatorHeq(const Teuchos::RCP<const Epetra_Comm>& comm, |
| 44 |
const int num_global_elements, |
| 45 |
const Scalar paramC); |
| 46 |
|
| 47 |
/** \name Initializers/Accessors */ |
| 48 |
//@{ |
| 49 |
|
| 50 |
/** \brief . */ |
| 51 |
void set_x0(const Teuchos::ArrayView<const Scalar> &x0); |
| 52 |
|
| 53 |
/** \brief . */ |
| 54 |
void setShowGetInvalidArgs(bool showGetInvalidArg); |
| 55 |
|
| 56 |
void set_W_factory(const Teuchos::RCP<const ::Thyra::LinearOpWithSolveFactoryBase<Scalar> >& W_factory); |
| 57 |
|
| 58 |
//@} |
| 59 |
|
| 60 |
/** \name Public functions overridden from ModelEvaulator. */ |
| 61 |
//@{ |
| 62 |
|
| 63 |
/** \brief . */ |
| 64 |
Teuchos::RCP<const ::Thyra::VectorSpaceBase<Scalar> > get_x_space() const; |
| 65 |
/** \brief . */ |
| 66 |
Teuchos::RCP<const ::Thyra::VectorSpaceBase<Scalar> > get_f_space() const; |
| 67 |
/** \brief . */ |
| 68 |
::Thyra::ModelEvaluatorBase::InArgs<Scalar> getNominalValues() const; |
| 69 |
/** \brief . */ |
| 70 |
Teuchos::RCP< ::Thyra::LinearOpBase<Scalar> > create_W_op() const; |
| 71 |
/** \brief . */ |
| 72 |
Teuchos::RCP<const ::Thyra::LinearOpWithSolveFactoryBase<Scalar> > get_W_factory() const; |
| 73 |
/** \brief . */ |
| 74 |
::Thyra::ModelEvaluatorBase::InArgs<Scalar> createInArgs() const; |
| 75 |
/** \brief . */ |
| 76 |
Teuchos::RCP< ::Thyra::PreconditionerBase< Scalar > > create_W_prec() const; |
| 77 |
//@} |
| 78 |
|
| 79 |
private: |
| 80 |
|
| 81 |
/** \name Private functions overridden from ModelEvaulatorDefaultBase. */ |
| 82 |
//@{ |
| 83 |
|
| 84 |
/** \brief . */ |
| 85 |
::Thyra::ModelEvaluatorBase::OutArgs<Scalar> createOutArgsImpl() const; |
| 86 |
/** \brief . */ |
| 87 |
void evalModelImpl( |
| 88 |
const ::Thyra::ModelEvaluatorBase::InArgs<Scalar> &inArgs, |
| 89 |
const ::Thyra::ModelEvaluatorBase::OutArgs<Scalar> &outArgs |
| 90 |
) const; |
| 91 |
|
| 92 |
//@} |
| 93 |
|
| 94 |
private: // data members |
| 95 |
|
| 96 |
const Teuchos::RCP<const Epetra_Comm> comm_; |
| 97 |
const int num_global_elements_; |
| 98 |
const Scalar paramC_; |
| 99 |
|
| 100 |
Teuchos::RCP<const ::Thyra::VectorSpaceBase<Scalar> > x_space_; |
| 101 |
Teuchos::RCP<const Epetra_Map> x_map_; |
| 102 |
|
| 103 |
Teuchos::RCP<const ::Thyra::VectorSpaceBase<Scalar> > f_space_; |
| 104 |
Teuchos::RCP<const Epetra_Map> f_map_; |
| 105 |
|
| 106 |
Teuchos::RCP<const ::Thyra::LinearOpWithSolveFactoryBase<Scalar> > W_factory_; |
| 107 |
|
| 108 |
Teuchos::RCP<Epetra_CrsMatrix> A_heq_; |
| 109 |
|
| 110 |
mutable Teuchos::RCP<const Epetra_Vector> x_ptr_; |
| 111 |
|
| 112 |
std::vector<Scalar> node_coordinates_; |
| 113 |
|
| 114 |
Teuchos::RCP<Epetra_Vector> ones_; |
| 115 |
|
| 116 |
::Thyra::ModelEvaluatorBase::InArgs<Scalar> nominalValues_; |
| 117 |
Teuchos::RCP< ::Thyra::VectorBase<Scalar> > x0_; |
| 118 |
bool showGetInvalidArg_; |
| 119 |
::Thyra::ModelEvaluatorBase::InArgs<Scalar> prototypeInArgs_; |
| 120 |
::Thyra::ModelEvaluatorBase::OutArgs<Scalar> prototypeOutArgs_; |
| 121 |
|
| 122 |
}; |
| 123 |
|
| 124 |
//================================================================== |
| 125 |
#include "ModelEvaluatorHeq_def.hpp" |
| 126 |
//================================================================== |
| 127 |
|
| 128 |
#endif |