| 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 |
|
| 10 |
// Finite Element Problem Class |
| 11 |
/* Provides function (F) and Jacobian evaluations for the following equation |
| 12 |
* via a 1D linear finite element discretization with Epetra objects. |
| 13 |
* |
| 14 |
* d2u |
| 15 |
* --- - k * u**2 = 0 |
| 16 |
* dx2 |
| 17 |
* |
| 18 |
* subject to @ x=0, u=1 |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef _NOX_TEST_CONVDIFF_PDE_EQUATION_H |
| 22 |
#define _NOX_TEST_CONVDIFF_PDE_EQUATION_H |
| 23 |
|
| 24 |
#include "GenericEpetraProblem.H" // Base class |
| 25 |
|
| 26 |
// Single PDE Equation Problem Class for HMX Cook-off problem |
| 27 |
|
| 28 |
class ConvDiff_PDE : public GenericEpetraProblem |
| 29 |
{ |
| 30 |
|
| 31 |
public: |
| 32 |
|
| 33 |
enum PAPER_SCENARIO { |
| 34 |
RVALUE_0_00 , |
| 35 |
RVALUE_0_30 , |
| 36 |
RVALUE_1_00 , |
| 37 |
RVALUE_2_50 , |
| 38 |
RVALUE_5_67 , |
| 39 |
NONE |
| 40 |
}; |
| 41 |
|
| 42 |
enum INTERFACE_LOCATION { |
| 43 |
LEFT , |
| 44 |
RIGHT |
| 45 |
}; |
| 46 |
|
| 47 |
// Constructor |
| 48 |
ConvDiff_PDE( |
| 49 |
Epetra_Comm & Comm , |
| 50 |
double peclet , |
| 51 |
double radiation , |
| 52 |
double kappa , |
| 53 |
double bcWeight , |
| 54 |
double xmin , |
| 55 |
double xmax , |
| 56 |
double Tleft , |
| 57 |
double Tright , |
| 58 |
int NumGlobalUnknowns = 0 , |
| 59 |
std::string name = "" ) ; |
| 60 |
|
| 61 |
// Destructor |
| 62 |
~ConvDiff_PDE(); |
| 63 |
|
| 64 |
// Method to compute exact interface temperature |
| 65 |
static double computeAnalyticInterfaceTemp( |
| 66 |
double Radiation , |
| 67 |
double T_left = 0.0 , |
| 68 |
double T_right = 1.0 , |
| 69 |
double kappa = 0.1 , |
| 70 |
double peclet = 9.0 ); |
| 71 |
|
| 72 |
|
| 73 |
// Set initial condition for solution vector |
| 74 |
void initializeSolution(double val = 0.0); |
| 75 |
|
| 76 |
// Compute and output analytic slution here |
| 77 |
void initialize(); |
| 78 |
|
| 79 |
// Evaluates the function (F) and/or the Jacobian using the solution |
| 80 |
// values in solnVector. |
| 81 |
bool evaluate( NOX::Epetra::Interface::Required::FillType fill, |
| 82 |
const Epetra_Vector *solnVector, |
| 83 |
Epetra_Vector *rhsVector); |
| 84 |
|
| 85 |
// Inherited method that allows us to explcitly provide off-block structural info |
| 86 |
// in the form of global composite equation indices |
| 87 |
bool suppliesOffBlockStructure() |
| 88 |
{ return expandJacobian; } |
| 89 |
|
| 90 |
// Inherited method that allows us to explcitly provide off-block structural info |
| 91 |
// in the form of global composite equation indices |
| 92 |
bool suppliesOffBlockStructure(int depID) |
| 93 |
{ return expandJacobian; } |
| 94 |
|
| 95 |
// Method to toggle expanded Jacobian option |
| 96 |
void setExpandJacobian( bool setting ) |
| 97 |
{ expandJacobian = setting; } |
| 98 |
|
| 99 |
// Method that allows us to provide off-block structural info |
| 100 |
void getOffBlockIndices( map<int, std::vector<int> > & ); |
| 101 |
|
| 102 |
// Inherited method that allows us to compute fluxes before transferring data |
| 103 |
void prepare_data_for_transfer(); |
| 104 |
|
| 105 |
// Compute the appropriate end heat flux |
| 106 |
void computeHeatFlux( const Epetra_Vector * pVec = NULL ); |
| 107 |
|
| 108 |
// Inherited method that allows us to tidy up transferred data |
| 109 |
void process_transferred_data(); |
| 110 |
|
| 111 |
// Inherited method that allows us to specialize transfers across an interface |
| 112 |
void doTransfer(); |
| 113 |
|
| 114 |
// Accessor |
| 115 |
double getHeatFlux() |
| 116 |
{ return myFlux; } |
| 117 |
|
| 118 |
// Accessor |
| 119 |
double getInterfaceTemp(); |
| 120 |
|
| 121 |
// Accessor |
| 122 |
Teuchos::RCP<Epetra_Vector> getExactSolution() |
| 123 |
{ return exactSolution; } |
| 124 |
|
| 125 |
// Additional status output |
| 126 |
virtual void outputStatus( std::ostream & os ); |
| 127 |
|
| 128 |
|
| 129 |
protected: |
| 130 |
|
| 131 |
// inserts the global column indices into the Graph |
| 132 |
void generateGraph(); |
| 133 |
|
| 134 |
protected: |
| 135 |
|
| 136 |
double xmin ; |
| 137 |
double xmax ; |
| 138 |
double Tleft ; |
| 139 |
double Tright ; |
| 140 |
double dx ; |
| 141 |
double T1_exact ; |
| 142 |
|
| 143 |
double peclet ; |
| 144 |
double radiation ; |
| 145 |
double kappa ; |
| 146 |
|
| 147 |
PAPER_SCENARIO paperScenario ; |
| 148 |
INTERFACE_LOCATION myInterface ; |
| 149 |
double dirScale ; |
| 150 |
double myFlux ; |
| 151 |
|
| 152 |
double bcWeight ; |
| 153 |
|
| 154 |
Teuchos::RCP<Epetra_Import> ColumnToOverlapImporter ; |
| 155 |
Teuchos::RCP<Epetra_Vector> oldSolution ; |
| 156 |
Teuchos::RCP<Epetra_Vector> exactSolution ; |
| 157 |
Teuchos::RCP<Epetra_Vector> dTdx ; |
| 158 |
|
| 159 |
int interface_elem ; |
| 160 |
int local_node ; |
| 161 |
int interface_node ; |
| 162 |
int opposite_node ; |
| 163 |
|
| 164 |
// Flag to enable off-block structure in compositeJacobian |
| 165 |
bool expandJacobian ; |
| 166 |
|
| 167 |
// Pointer to the other (assumed only one) problem |
| 168 |
ConvDiff_PDE * depProbPtr ; |
| 169 |
}; |
| 170 |
#endif |