| 1 |
// @HEADER |
| 2 |
// ***************************************************************************** |
| 3 |
// LOCA: Library of Continuation Algorithms Package |
| 4 |
// |
| 5 |
// Copyright 2001-2005 NTESS and the LOCA contributors. |
| 6 |
// SPDX-License-Identifier: BSD-3-Clause |
| 7 |
// ***************************************************************************** |
| 8 |
// @HEADER |
| 9 |
|
| 10 |
#ifndef BRUSSELATORPROBLEMINTERFACE_H |
| 11 |
#define BRUSSELATORPROBLEMINTERFACE_H |
| 12 |
|
| 13 |
#include "Teuchos_RCP.hpp" |
| 14 |
|
| 15 |
#include "LOCA_LAPACK_Interface.H" // base class |
| 16 |
#include "NOX_LAPACK_Vector.H" // class data element |
| 17 |
#include <fstream> |
| 18 |
|
| 19 |
namespace LOCA { |
| 20 |
class GlobalData; |
| 21 |
} |
| 22 |
|
| 23 |
/*! |
| 24 |
*\brief LOCA-LAPACK problem interface for the Brussselator problem. |
| 25 |
*/ |
| 26 |
/*! |
| 27 |
* %BrusselatorProblemInterface implements the LOCA::LAPACK::Interface for a |
| 28 |
* 1D finite-difference discretization of the Brusselator problem: |
| 29 |
* \f[ |
| 30 |
* \frac{\partial T}{\partial t} = D_1\frac{\partial^2 T}{\partial x^2} + |
| 31 |
* \alpha - (\beta + 1)T + T^2 C \\ |
| 32 |
* \frac{\partial C}{\partial t} = D_2\frac{\partial^2 C}{\partial x^2} + |
| 33 |
* \beta T - T^2 C |
| 34 |
* \f] |
| 35 |
* subject to the boundar conditions \f$T(0) = T(1) = \alpha\f$, |
| 36 |
* \f$C(0) = C(1) = \beta/\alpha\f$. The parameters are \f$\alpha\f$, |
| 37 |
* \f$\beta\f$, \f$D_1\f$, \f$D_2\f$ and \f$n\f$, the size of the |
| 38 |
* discretization. |
| 39 |
*/ |
| 40 |
class BrusselatorProblemInterface : |
| 41 |
public LOCA::LAPACK::Interface { |
| 42 |
|
| 43 |
public: |
| 44 |
|
| 45 |
//! Constructor. Also generates an initial guess |
| 46 |
BrusselatorProblemInterface( |
| 47 |
const Teuchos::RCP<LOCA::GlobalData>& global_data, |
| 48 |
int N, double a, double b, double d1, double d2, |
| 49 |
std::ofstream& file); |
| 50 |
|
| 51 |
//! Destructor |
| 52 |
~BrusselatorProblemInterface() {}; |
| 53 |
|
| 54 |
//! Returns initial guess |
| 55 |
const NOX::LAPACK::Vector& getInitialGuess(); |
| 56 |
|
| 57 |
//! Evaluates residual |
| 58 |
bool |
| 59 |
computeF(NOX::LAPACK::Vector& f, const NOX::LAPACK::Vector &x); |
| 60 |
|
| 61 |
//! Evalues jacobian |
| 62 |
bool |
| 63 |
computeJacobian(NOX::LAPACK::Matrix<double>& J, |
| 64 |
const NOX::LAPACK::Vector & x); |
| 65 |
|
| 66 |
/*! |
| 67 |
* \brief Compute shifted matrix alpha*J + beta*M where J is the |
| 68 |
* Jacobian matrix and M is the mass matrix. Returns true if |
| 69 |
* computation was successful. |
| 70 |
*/ |
| 71 |
virtual bool computeShiftedMatrix(double alpha, double beta, |
| 72 |
const NOX::LAPACK::Vector& x, |
| 73 |
NOX::LAPACK::Matrix<double>& A); |
| 74 |
|
| 75 |
//! Sets parameters |
| 76 |
void setParams(const LOCA::ParameterVector& p); |
| 77 |
|
| 78 |
//! Prints solution after successful step |
| 79 |
void printSolution(const NOX::LAPACK::Vector &x, const double conParam); |
| 80 |
|
| 81 |
private: |
| 82 |
|
| 83 |
//! Global data |
| 84 |
Teuchos::RCP<LOCA::GlobalData> globalData; |
| 85 |
|
| 86 |
//! Stores the initial guess |
| 87 |
NOX::LAPACK::Vector initialGuess; |
| 88 |
|
| 89 |
//! Stores \f$\alpha\f$ |
| 90 |
double alpha; |
| 91 |
|
| 92 |
//! Stores \f$\beta\f$ |
| 93 |
double beta; |
| 94 |
|
| 95 |
//! Stores \f$D_1\f$ |
| 96 |
double D1; |
| 97 |
|
| 98 |
//! Stores \f$D_2\f$ |
| 99 |
double D2; |
| 100 |
|
| 101 |
//! Stores the size of the discretization |
| 102 |
int n; |
| 103 |
|
| 104 |
//! Stores reference to output file stream |
| 105 |
std::ofstream& outputFile; |
| 106 |
|
| 107 |
}; |
| 108 |
|
| 109 |
#endif |